Skip to content

Commit

Permalink
Merge pull request #3188 from opsmill/pog-sdk-config-environment-prefix
Browse files Browse the repository at this point in the history
BREAKING: Change env prefix from INFRAHUB_SDK_ -> INFRAHUB_
  • Loading branch information
ogenstad authored May 3, 2024
2 parents 3fb7c80 + f7f8df5 commit c3211b6
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/demo-container/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"remoteUser": "vscode",
"remoteEnv": {
"INFRAHUB_SDK_API_TOKEN": "06438eb2-8019-4776-878c-0941b1f1d1ec",
"INFRAHUB_API_TOKEN": "06438eb2-8019-4776-878c-0941b1f1d1ec",
"INFRAHUB_DB_TYPE": "memgraph",
"INFRAHUB_IMAGE_VER": "local"
},
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"remoteUser": "vscode",
"remoteEnv": {
"INFRAHUB_SDK_API_TOKEN": "06438eb2-8019-4776-878c-0941b1f1d1ec",
"INFRAHUB_API_TOKEN": "06438eb2-8019-4776-878c-0941b1f1d1ec",
"INFRAHUB_DB_TYPE": "memgraph",
"INFRAHUB_IMAGE_VER": "local"
},
Expand Down
4 changes: 2 additions & 2 deletions development/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ services:
INFRAHUB_ADDRESS: http://infrahub-server:8000
INFRAHUB_PRODUCTION: false
INFRAHUB_LOG_LEVEL: DEBUG
INFRAHUB_SDK_API_TOKEN: 06438eb2-8019-4776-878c-0941b1f1d1ec
INFRAHUB_SDK_TIMEOUT: 20
INFRAHUB_API_TOKEN: 06438eb2-8019-4776-878c-0941b1f1d1ec
INFRAHUB_TIMEOUT: 20
volumes:
- "git_data:/opt/infrahub/git"
- "git_remote_data:/remote"
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/development/backend.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Most of Infrahub and tools around it rely on some settings. These settings are i
```bash
export INFRAHUB_PRODUCTION=false
export INFRAHUB_SECURITY_SECRET_KEY=super-secret
export INFRAHUB_SDK_USERNAME=admin
export INFRAHUB_SDK_PASSWORD=infrahub
export INFRAHUB_SDK_TIMEOUT=20
export INFRAHUB_USERNAME=admin
export INFRAHUB_PASSWORD=infrahub
export INFRAHUB_TIMEOUT=20
export INFRAHUB_METRICS_PORT=8001
export INFRAHUB_DB_TYPE=memgraph # Accepts neo4j or memgraph
export INFRAHUB_SECURITY_INITIAL_ADMIN_TOKEN="${ADMIN_TOKEN}" # Random string which can be generated using: openssl rand -hex 16
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/python-sdk/guides/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ client = InfrahubClientSync.init(address="http://localhost:8000")

## Authentication

The SDK is using a token-based authentication method to authenticate with the API and GraphQL. The token can be provided using a Config object or you can define it as the `INFRAHUB_SDK_API_TOKEN` environment variable.
The SDK is using a token-based authentication method to authenticate with the API and GraphQL. The token can be provided using a Config object or you can define it as the `INFRAHUB_API_TOKEN` environment variable.

<Tabs groupId="async-sync">
<TabItem value="Async" default>

```python
from infrahub_sdk import InfrahubClient
client = await InfrahubClient.init(config=Config(api_token="token"))
client = await InfrahubClient.init() # token is read from the INFRAHUB_SDK_API_TOKEN environment variable
client = await InfrahubClient.init() # token is read from the INFRAHUB_API_TOKEN environment variable
```

</TabItem>
Expand All @@ -47,7 +47,7 @@ The SDK is using a token-based authentication method to authenticate with the AP
```python
from infrahub_sdk import InfrahubClientSync
client = InfrahubClientSync.init(config=Config(api_token="token"))
client = InfrahubClientSync.init() # token is read from the INFRAHUB_SDK_API_TOKEN environment variable
client = InfrahubClientSync.init() # token is read from the INFRAHUB_API_TOKEN environment variable
```

</TabItem>
Expand Down
38 changes: 19 additions & 19 deletions docs/docs/python-sdk/reference/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,75 +31,75 @@ The following settings can be defined in the Config class
**Description**: The URL to use when connecting to Infrahub.<br />
**Type**: `string`<br />
**Default value**: http://localhost:8000<br />
**Environment variable**: `INFRAHUB_SDK_ADDRESS`<br />
**Environment variable**: `INFRAHUB_ADDRESS`<br />

## api_token

**Property**: api_token<br />
**Description**: API token for authentication against Infrahub.<br />
**Type**: `string`<br />
**Environment variable**: `INFRAHUB_SDK_API_TOKEN`<br />
**Environment variable**: `INFRAHUB_API_TOKEN`<br />

## echo_graphql_queries

**Property**: echo_graphql_queries<br />
**Description**: If set the GraphQL query and variables will be echoed to the screen<br />
**Type**: `boolean`<br />
**Default value**: False<br />
**Environment variable**: `INFRAHUB_SDK_ECHO_GRAPHQL_QUERIES`<br />
**Environment variable**: `INFRAHUB_ECHO_GRAPHQL_QUERIES`<br />

## username

**Property**: username<br />
**Description**: Username for accessing Infrahub<br />
**Type**: `string`<br />
**Environment variable**: `INFRAHUB_SDK_USERNAME`<br />
**Environment variable**: `INFRAHUB_USERNAME`<br />

## password

**Property**: password<br />
**Description**: Password for accessing Infrahub<br />
**Type**: `string`<br />
**Environment variable**: `INFRAHUB_SDK_PASSWORD`<br />
**Environment variable**: `INFRAHUB_PASSWORD`<br />

## default_branch

**Property**: default_branch<br />
**Description**: Default branch to target if not specified for each request.<br />
**Type**: `string`<br />
**Default value**: main<br />
**Environment variable**: `INFRAHUB_SDK_DEFAULT_BRANCH`<br />
**Environment variable**: `INFRAHUB_DEFAULT_BRANCH`<br />

## default_branch_from_git

**Property**: default_branch_from_git<br />
**Description**: Indicates if the default Infrahub branch to target should come from the active branch in the local Git repository.<br />
**Type**: `boolean`<br />
**Default value**: False<br />
**Environment variable**: `INFRAHUB_SDK_DEFAULT_BRANCH_FROM_GIT`<br />
**Environment variable**: `INFRAHUB_DEFAULT_BRANCH_FROM_GIT`<br />

## identifier

**Property**: identifier<br />
**Description**: Tracker identifier<br />
**Type**: `string`<br />
**Environment variable**: `INFRAHUB_SDK_IDENTIFIER`<br />
**Environment variable**: `INFRAHUB_IDENTIFIER`<br />

## insert_tracker

**Property**: insert_tracker<br />
**Description**: Insert a tracker on queries to the server<br />
**Type**: `boolean`<br />
**Default value**: False<br />
**Environment variable**: `INFRAHUB_SDK_INSERT_TRACKER`<br />
**Environment variable**: `INFRAHUB_INSERT_TRACKER`<br />

## max_concurrent_execution

**Property**: max_concurrent_execution<br />
**Description**: Max concurrent execution in batch mode<br />
**Type**: `integer`<br />
**Default value**: 5<br />
**Environment variable**: `INFRAHUB_SDK_MAX_CONCURRENT_EXECUTION`<br />
**Environment variable**: `INFRAHUB_MAX_CONCURRENT_EXECUTION`<br />

## mode

Expand All @@ -108,39 +108,39 @@ The following settings can be defined in the Config class
**Type**: `string`<br />
**Default value**: default<br />
**Choices**: default, tracking<br />
**Environment variable**: `INFRAHUB_SDK_MODE`<br />
**Environment variable**: `INFRAHUB_MODE`<br />

## pagination_size

**Property**: pagination_size<br />
**Description**: Page size for queries to the server<br />
**Type**: `integer`<br />
**Default value**: 50<br />
**Environment variable**: `INFRAHUB_SDK_PAGINATION_SIZE`<br />
**Environment variable**: `INFRAHUB_PAGINATION_SIZE`<br />

## retry_delay

**Property**: retry_delay<br />
**Description**: Number of seconds to wait until attempting a retry.<br />
**Type**: `integer`<br />
**Default value**: 5<br />
**Environment variable**: `INFRAHUB_SDK_RETRY_DELAY`<br />
**Environment variable**: `INFRAHUB_RETRY_DELAY`<br />

## retry_on_failure

**Property**: retry_on_failure<br />
**Description**: Retry operation in case of failure<br />
**Type**: `boolean`<br />
**Default value**: False<br />
**Environment variable**: `INFRAHUB_SDK_RETRY_ON_FAILURE`<br />
**Environment variable**: `INFRAHUB_RETRY_ON_FAILURE`<br />

## timeout

**Property**: timeout<br />
**Description**: Default connection timeout in seconds<br />
**Type**: `integer`<br />
**Default value**: 10<br />
**Environment variable**: `INFRAHUB_SDK_TIMEOUT`<br />
**Environment variable**: `INFRAHUB_TIMEOUT`<br />

## transport

Expand All @@ -149,29 +149,29 @@ The following settings can be defined in the Config class
**Type**: `string`<br />
**Default value**: httpx<br />
**Choices**: httpx, json<br />
**Environment variable**: `INFRAHUB_SDK_TRANSPORT`<br />
**Environment variable**: `INFRAHUB_TRANSPORT`<br />

## proxy

**Property**: proxy<br />
**Description**: Proxy address<br />
**Type**: `string`<br />
**Environment variable**: `INFRAHUB_SDK_PROXY`<br />
**Environment variable**: `INFRAHUB_PROXY`<br />

## proxy_mounts

**Property**: proxy_mounts<br />
**Description**: Proxy mounts configuration<br />
**Type**: `object`<br />
**Environment variable**: `INFRAHUB_SDK_PROXY_MOUNTS`<br />
**Environment variable**: `INFRAHUB_PROXY_MOUNTS`<br />

## update_group_context

**Property**: update_group_context<br />
**Description**: Update GraphQL query groups<br />
**Type**: `boolean`<br />
**Default value**: False<br />
**Environment variable**: `INFRAHUB_SDK_UPDATE_GROUP_CONTEXT`<br />
**Environment variable**: `INFRAHUB_UPDATE_GROUP_CONTEXT`<br />

## recorder

Expand Down
4 changes: 2 additions & 2 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ infrahubGit:
INFRAHUB_DB_TYPE: neo4j
INFRAHUB_LOG_LEVEL: DEBUG
INFRAHUB_PRODUCTION: "false"
INFRAHUB_SDK_API_TOKEN: 06438eb2-8019-4776-878c-0941b1f1d1ec
INFRAHUB_SDK_TIMEOUT: "20"
INFRAHUB_API_TOKEN: 06438eb2-8019-4776-878c-0941b1f1d1ec
INFRAHUB_TIMEOUT: "20"
imagePullPolicy: Always
waitForInfrahubServer:
image:
Expand Down
6 changes: 3 additions & 3 deletions python_sdk/infrahub_sdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

class ProxyMountsConfig(pydantic.BaseSettings):
http: str = pydantic.Field(
default=None, description="Proxy for HTTP requests", alias="http://", env="INFRAHUB_SDK_PROXY_MOUNTS_HTTP"
default=None, description="Proxy for HTTP requests", alias="http://", env="INFRAHUB_PROXY_MOUNTS_HTTP"
)
https: str = pydantic.Field(
default=None, description="Proxy for HTTPS requests", alias="https://", env="INFRAHUB_SDK_PROXY_MOUNTS_HTTPS"
default=None, description="Proxy for HTTPS requests", alias="https://", env="INFRAHUB_PROXY_MOUNTS_HTTPS"
)

class Config:
Expand Down Expand Up @@ -61,7 +61,7 @@ class ConfigBase(pydantic.BaseSettings):
update_group_context: bool = pydantic.Field(default=False, description="Update GraphQL query groups")

class Config:
env_prefix = "INFRAHUB_SDK_"
env_prefix = "INFRAHUB_"
case_sensitive = False
validate_assignment = True

Expand Down
2 changes: 1 addition & 1 deletion python_sdk/infrahub_sdk/playback.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ def _read_request(
return response

class Config:
env_prefix = "INFRAHUB_SDK_PLAYBACK_"
env_prefix = "INFRAHUB_PLAYBACK_"
case_sensitive = False
2 changes: 1 addition & 1 deletion python_sdk/infrahub_sdk/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ def _set_url_host(self, response: httpx.Response) -> None:
response.request.url = httpx.URL(url=modified)

class Config:
env_prefix = "INFRAHUB_SDK_JSON_RECORDER_"
env_prefix = "INFRAHUB_JSON_RECORDER_"
case_sensitive = False

0 comments on commit c3211b6

Please sign in to comment.