Skip to content

Commit

Permalink
Merge pull request #175 from pulumiverse/provider-config-tf-v3
Browse files Browse the repository at this point in the history
Update provider config to align with upstream TF v3 provider
  • Loading branch information
ringods authored Jun 27, 2024
2 parents b5c4006 + cdcbc16 commit f5350b2
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 40 deletions.
24 changes: 22 additions & 2 deletions provider/cmd/pulumi-resource-grafana/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
"cloudAccessPolicyToken": {
"type": "string",
"description": "Access Policy Token for Grafana Cloud. May alternatively be set via the `GRAFANA_CLOUD_ACCESS_POLICY_TOKEN` environment\nvariable.\n",
"defaultInfo": {
"environment": [
"GRAFANA_CLOUD_ACCESS_POLICY_TOKEN"
]
},
"secret": true
},
"cloudApiUrl": {
Expand Down Expand Up @@ -135,7 +140,12 @@
},
"retryWait": {
"type": "integer",
"description": "The amount of time in seconds to wait between retries for Grafana API and Grafana Cloud API calls. May alternatively be\nset via the `GRAFANA_RETRY_WAIT` environment variable.\n"
"description": "The amount of time in seconds to wait between retries for Grafana API and Grafana Cloud API calls. May alternatively be\nset via the `GRAFANA_RETRY_WAIT` environment variable.\n",
"defaultInfo": {
"environment": [
"GRAFANA_RETRY_WAIT"
]
}
},
"smAccessToken": {
"type": "string",
Expand Down Expand Up @@ -8528,6 +8538,11 @@
"cloudAccessPolicyToken": {
"type": "string",
"description": "Access Policy Token for Grafana Cloud. May alternatively be set via the `GRAFANA_CLOUD_ACCESS_POLICY_TOKEN` environment\nvariable.\n",
"defaultInfo": {
"environment": [
"GRAFANA_CLOUD_ACCESS_POLICY_TOKEN"
]
},
"secret": true
},
"cloudApiUrl": {
Expand Down Expand Up @@ -8585,7 +8600,12 @@
},
"retryWait": {
"type": "integer",
"description": "The amount of time in seconds to wait between retries for Grafana API and Grafana Cloud API calls. May alternatively be\nset via the `GRAFANA_RETRY_WAIT` environment variable.\n"
"description": "The amount of time in seconds to wait between retries for Grafana API and Grafana Cloud API calls. May alternatively be\nset via the `GRAFANA_RETRY_WAIT` environment variable.\n",
"defaultInfo": {
"environment": [
"GRAFANA_RETRY_WAIT"
]
}
},
"smAccessToken": {
"type": "string",
Expand Down
68 changes: 40 additions & 28 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,57 +105,63 @@ func Provider() tfbridge.ProviderInfo {
GitHubOrg: "grafana",
TFProviderModuleVersion: "v3",
Config: map[string]*tfbridge.SchemaInfo{
"url": {
Type: "string",
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_URL"},
},
},
"auth": {
Type: "string",
Secret: boolRef(true),
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_AUTH"},
},
},
"http_headers": {
SuppressEmptyMapElements: boolRef(true),
Omit: true,
"ca_cert": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_CA_CERT"},
},
},
"retries": {
"cloud_access_policy_token": {
Type: "string",
Secret: boolRef(true),
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_RETRIES"},
EnvVars: []string{"GRAFANA_CLOUD_ACCESS_POLICY_TOKEN"},
},
},
"org_id": {
"cloud_api_url": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_ORG_ID"},
EnvVars: []string{"GRAFANA_CLOUD_API_URL"},
},
},
"tls_key": {
Secret: boolRef(true),
"http_headers": {
SuppressEmptyMapElements: boolRef(true),
Omit: true,
},
"insecure_skip_verify": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_TLS_KEY"},
EnvVars: []string{"GRAFANA_INSECURE_SKIP_VERIFY"},
},
},
"tls_cert": {
"oncall_access_token": {
Secret: boolRef(true),
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_TLS_CERT"},
EnvVars: []string{"GRAFANA_ONCALL_ACCESS_TOKEN"},
},
},
"ca_cert": {
"oncall_url": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_CA_CERT"},
EnvVars: []string{"GRAFANA_ONCALL_URL"},
},
},
"insecure_skip_verify": {
"retries": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_INSECURE_SKIP_VERIFY"},
EnvVars: []string{"GRAFANA_RETRIES"},
},
},
"cloud_api_url": {
// "retry_status_codes": {
// Default: &tfbridge.DefaultInfo{
// EnvVars: []string{"GRAFANA_RETRY_STATUS_CODES"},
// },
// },
"retry_wait": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_CLOUD_API_URL"},
EnvVars: []string{"GRAFANA_RETRY_WAIT"},
},
},
"sm_access_token": {
Expand All @@ -174,15 +180,21 @@ func Provider() tfbridge.ProviderInfo {
EnvVars: []string{"GRAFANA_STORE_DASHBOARD_SHA256"},
},
},
"oncall_access_token": {
"tls_cert": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_TLS_CERT"},
},
},
"tls_key": {
Secret: boolRef(true),
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_ONCALL_ACCESS_TOKEN"},
EnvVars: []string{"GRAFANA_TLS_KEY"},
},
},
"oncall_url": {
"url": {
Type: "string",
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GRAFANA_ONCALL_URL"},
EnvVars: []string{"GRAFANA_URL"},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static string? CaCert
set => _caCert.Set(value);
}

private static readonly __Value<string?> _cloudAccessPolicyToken = new __Value<string?>(() => __config.Get("cloudAccessPolicyToken"));
private static readonly __Value<string?> _cloudAccessPolicyToken = new __Value<string?>(() => __config.Get("cloudAccessPolicyToken") ?? Utilities.GetEnv("GRAFANA_CLOUD_ACCESS_POLICY_TOKEN"));
/// <summary>
/// Access Policy Token for Grafana Cloud. May alternatively be set via the `GRAFANA_CLOUD_ACCESS_POLICY_TOKEN` environment
/// variable.
Expand Down Expand Up @@ -127,7 +127,7 @@ public static ImmutableArray<string> RetryStatusCodes
set => _retryStatusCodes.Set(value);
}

private static readonly __Value<int?> _retryWait = new __Value<int?>(() => __config.GetInt32("retryWait"));
private static readonly __Value<int?> _retryWait = new __Value<int?>(() => __config.GetInt32("retryWait") ?? Utilities.GetEnvInt32("GRAFANA_RETRY_WAIT"));
/// <summary>
/// The amount of time in seconds to wait between retries for Grafana API and Grafana Cloud API calls. May alternatively be
/// set via the `GRAFANA_RETRY_WAIT` environment variable.
Expand Down
2 changes: 2 additions & 0 deletions sdk/dotnet/Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,13 @@ public ProviderArgs()
{
Auth = Utilities.GetEnv("GRAFANA_AUTH");

Check warning on line 286 in sdk/dotnet/Provider.cs

View workflow job for this annotation

GitHub Actions / build_sdk (dotnet)

Possible null reference argument for parameter 'value' in 'Input<string>.implicit operator Input<string>(string value)'.
CaCert = Utilities.GetEnv("GRAFANA_CA_CERT");

Check warning on line 287 in sdk/dotnet/Provider.cs

View workflow job for this annotation

GitHub Actions / build_sdk (dotnet)

Possible null reference argument for parameter 'value' in 'Input<string>.implicit operator Input<string>(string value)'.
CloudAccessPolicyToken = Utilities.GetEnv("GRAFANA_CLOUD_ACCESS_POLICY_TOKEN");

Check warning on line 288 in sdk/dotnet/Provider.cs

View workflow job for this annotation

GitHub Actions / build_sdk (dotnet)

Possible null reference argument for parameter 'value' in 'Input<string>.implicit operator Input<string>(string value)'.
CloudApiUrl = Utilities.GetEnv("GRAFANA_CLOUD_API_URL");

Check warning on line 289 in sdk/dotnet/Provider.cs

View workflow job for this annotation

GitHub Actions / build_sdk (dotnet)

Possible null reference argument for parameter 'value' in 'Input<string>.implicit operator Input<string>(string value)'.
InsecureSkipVerify = Utilities.GetEnvBoolean("GRAFANA_INSECURE_SKIP_VERIFY");
OncallAccessToken = Utilities.GetEnv("GRAFANA_ONCALL_ACCESS_TOKEN");

Check warning on line 291 in sdk/dotnet/Provider.cs

View workflow job for this annotation

GitHub Actions / build_sdk (dotnet)

Possible null reference argument for parameter 'value' in 'Input<string>.implicit operator Input<string>(string value)'.
OncallUrl = Utilities.GetEnv("GRAFANA_ONCALL_URL");

Check warning on line 292 in sdk/dotnet/Provider.cs

View workflow job for this annotation

GitHub Actions / build_sdk (dotnet)

Possible null reference argument for parameter 'value' in 'Input<string>.implicit operator Input<string>(string value)'.
Retries = Utilities.GetEnvInt32("GRAFANA_RETRIES");
RetryWait = Utilities.GetEnvInt32("GRAFANA_RETRY_WAIT");
SmAccessToken = Utilities.GetEnv("GRAFANA_SM_ACCESS_TOKEN");

Check warning on line 295 in sdk/dotnet/Provider.cs

View workflow job for this annotation

GitHub Actions / build_sdk (dotnet)

Possible null reference argument for parameter 'value' in 'Input<string>.implicit operator Input<string>(string value)'.
SmUrl = Utilities.GetEnv("GRAFANA_SM_URL");

Check warning on line 296 in sdk/dotnet/Provider.cs

View workflow job for this annotation

GitHub Actions / build_sdk (dotnet)

Possible null reference argument for parameter 'value' in 'Input<string>.implicit operator Input<string>(string value)'.
StoreDashboardSha256 = Utilities.GetEnvBoolean("GRAFANA_STORE_DASHBOARD_SHA256");
Expand Down
20 changes: 18 additions & 2 deletions sdk/go/grafana/config/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions sdk/go/grafana/provider.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/nodejs/config/vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Object.defineProperty(exports, "caCert", {
export declare const cloudAccessPolicyToken: string | undefined;
Object.defineProperty(exports, "cloudAccessPolicyToken", {
get() {
return __config.get("cloudAccessPolicyToken");
return __config.get("cloudAccessPolicyToken") ?? utilities.getEnv("GRAFANA_CLOUD_ACCESS_POLICY_TOKEN");
},
enumerable: true,
});
Expand Down Expand Up @@ -118,7 +118,7 @@ Object.defineProperty(exports, "retryStatusCodes", {
export declare const retryWait: number | undefined;
Object.defineProperty(exports, "retryWait", {
get() {
return __config.getObject<number>("retryWait");
return __config.getObject<number>("retryWait") ?? utilities.getEnvNumber("GRAFANA_RETRY_WAIT");
},
enumerable: true,
});
Expand Down
4 changes: 2 additions & 2 deletions sdk/nodejs/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ export class Provider extends pulumi.ProviderResource {
{
resourceInputs["auth"] = (args?.auth ? pulumi.secret(args.auth) : undefined) ?? utilities.getEnv("GRAFANA_AUTH");
resourceInputs["caCert"] = (args ? args.caCert : undefined) ?? utilities.getEnv("GRAFANA_CA_CERT");
resourceInputs["cloudAccessPolicyToken"] = args?.cloudAccessPolicyToken ? pulumi.secret(args.cloudAccessPolicyToken) : undefined;
resourceInputs["cloudAccessPolicyToken"] = (args?.cloudAccessPolicyToken ? pulumi.secret(args.cloudAccessPolicyToken) : undefined) ?? utilities.getEnv("GRAFANA_CLOUD_ACCESS_POLICY_TOKEN");
resourceInputs["cloudApiUrl"] = (args ? args.cloudApiUrl : undefined) ?? utilities.getEnv("GRAFANA_CLOUD_API_URL");
resourceInputs["insecureSkipVerify"] = pulumi.output((args ? args.insecureSkipVerify : undefined) ?? utilities.getEnvBoolean("GRAFANA_INSECURE_SKIP_VERIFY")).apply(JSON.stringify);
resourceInputs["oncallAccessToken"] = (args?.oncallAccessToken ? pulumi.secret(args.oncallAccessToken) : undefined) ?? utilities.getEnv("GRAFANA_ONCALL_ACCESS_TOKEN");
resourceInputs["oncallUrl"] = (args ? args.oncallUrl : undefined) ?? utilities.getEnv("GRAFANA_ONCALL_URL");
resourceInputs["retries"] = pulumi.output((args ? args.retries : undefined) ?? utilities.getEnvNumber("GRAFANA_RETRIES")).apply(JSON.stringify);
resourceInputs["retryStatusCodes"] = pulumi.output(args ? args.retryStatusCodes : undefined).apply(JSON.stringify);
resourceInputs["retryWait"] = pulumi.output(args ? args.retryWait : undefined).apply(JSON.stringify);
resourceInputs["retryWait"] = pulumi.output((args ? args.retryWait : undefined) ?? utilities.getEnvNumber("GRAFANA_RETRY_WAIT")).apply(JSON.stringify);
resourceInputs["smAccessToken"] = (args?.smAccessToken ? pulumi.secret(args.smAccessToken) : undefined) ?? utilities.getEnv("GRAFANA_SM_ACCESS_TOKEN");
resourceInputs["smUrl"] = (args ? args.smUrl : undefined) ?? utilities.getEnv("GRAFANA_SM_URL");
resourceInputs["storeDashboardSha256"] = pulumi.output((args ? args.storeDashboardSha256 : undefined) ?? utilities.getEnvBoolean("GRAFANA_STORE_DASHBOARD_SHA256")).apply(JSON.stringify);
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/pulumiverse_grafana/config/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def cloud_access_policy_token(self) -> Optional[str]:
Access Policy Token for Grafana Cloud. May alternatively be set via the `GRAFANA_CLOUD_ACCESS_POLICY_TOKEN` environment
variable.
"""
return __config__.get('cloudAccessPolicyToken')
return __config__.get('cloudAccessPolicyToken') or _utilities.get_env('GRAFANA_CLOUD_ACCESS_POLICY_TOKEN')

@property
def cloud_api_url(self) -> Optional[str]:
Expand Down Expand Up @@ -89,7 +89,7 @@ def retry_wait(self) -> Optional[int]:
The amount of time in seconds to wait between retries for Grafana API and Grafana Cloud API calls. May alternatively be
set via the `GRAFANA_RETRY_WAIT` environment variable.
"""
return __config__.get_int('retryWait')
return __config__.get_int('retryWait') or _utilities.get_env_int('GRAFANA_RETRY_WAIT')

@property
def sm_access_token(self) -> Optional[str]:
Expand Down
8 changes: 8 additions & 0 deletions sdk/python/pulumiverse_grafana/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def __init__(__self__, *,
ca_cert = _utilities.get_env('GRAFANA_CA_CERT')
if ca_cert is not None:
pulumi.set(__self__, "ca_cert", ca_cert)
if cloud_access_policy_token is None:
cloud_access_policy_token = _utilities.get_env('GRAFANA_CLOUD_ACCESS_POLICY_TOKEN')
if cloud_access_policy_token is not None:
pulumi.set(__self__, "cloud_access_policy_token", cloud_access_policy_token)
if cloud_api_url is None:
Expand All @@ -88,6 +90,8 @@ def __init__(__self__, *,
pulumi.set(__self__, "retries", retries)
if retry_status_codes is not None:
pulumi.set(__self__, "retry_status_codes", retry_status_codes)
if retry_wait is None:
retry_wait = _utilities.get_env_int('GRAFANA_RETRY_WAIT')
if retry_wait is not None:
pulumi.set(__self__, "retry_wait", retry_wait)
if sm_access_token is None:
Expand Down Expand Up @@ -425,6 +429,8 @@ def _internal_init(__self__,
if ca_cert is None:
ca_cert = _utilities.get_env('GRAFANA_CA_CERT')
__props__.__dict__["ca_cert"] = ca_cert
if cloud_access_policy_token is None:
cloud_access_policy_token = _utilities.get_env('GRAFANA_CLOUD_ACCESS_POLICY_TOKEN')
__props__.__dict__["cloud_access_policy_token"] = None if cloud_access_policy_token is None else pulumi.Output.secret(cloud_access_policy_token)
if cloud_api_url is None:
cloud_api_url = _utilities.get_env('GRAFANA_CLOUD_API_URL')
Expand All @@ -442,6 +448,8 @@ def _internal_init(__self__,
retries = _utilities.get_env_int('GRAFANA_RETRIES')
__props__.__dict__["retries"] = pulumi.Output.from_input(retries).apply(pulumi.runtime.to_json) if retries is not None else None
__props__.__dict__["retry_status_codes"] = pulumi.Output.from_input(retry_status_codes).apply(pulumi.runtime.to_json) if retry_status_codes is not None else None
if retry_wait is None:
retry_wait = _utilities.get_env_int('GRAFANA_RETRY_WAIT')
__props__.__dict__["retry_wait"] = pulumi.Output.from_input(retry_wait).apply(pulumi.runtime.to_json) if retry_wait is not None else None
if sm_access_token is None:
sm_access_token = _utilities.get_env('GRAFANA_SM_ACCESS_TOKEN')
Expand Down

0 comments on commit f5350b2

Please sign in to comment.