Skip to content

Commit

Permalink
Add token as env var
Browse files Browse the repository at this point in the history
  • Loading branch information
philipkrueck committed Apr 2, 2024
1 parent e7c7150 commit 70c3d3d
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
- nodejs
- python
- go
- dotnet
# - dotnet
goversion:
- 1.22.x
nodeversion:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ VERSION_PATH := ${PROVIDER_PATH}/pkg/version.Version
TFGEN := pulumi-tfgen-${PACK}
PROVIDER := pulumi-resource-${PACK}

VERSION := v0.0.10
VERSION := v0.0.11

TESTPARALLELISM := 4

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dotnet add package GenesisCloud.PulumiGenesisCloud
The following configuration points are available:

- `genesiscloud:token` - (Required) This is the Genesis Cloud API Token, can also be specified with the `GENESISCLOUD_TOKEN` environment variable.
- `genesiscloud:endpoint` - (Optional) Genesis Cloud API endpoint, can be used to override the default API Endpoint `https://api.genesiscloud.com`.
- `genesiscloud:endpoint` - (Optional) This is the Genesis Cloud API endpoint, can be used to override the default API Endpoint `https://api.genesiscloud.com`. It can also be specified with the `GENESISCLOUD_ENDPOINT` environment variable.

## Reference

Expand Down
2 changes: 1 addition & 1 deletion docs/installation_configuration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Genesis Cloud Installation & Configuration
meta_desc: Information on how to install the Genesis Cloud provider.
layout: installation
layout: package
---

## Installation
Expand Down
4 changes: 3 additions & 1 deletion provider/cmd/pulumi-resource-genesiscloud/schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "genesiscloud",
"displayName": "Genesis Cloud",
"version": "v0.0.10",
"version": "v0.0.11",
"description": "A Pulumi package for creating and managing genesiscloud cloud resources.",
"keywords": ["pulumi", "genesiscloud", "category/cloud"],
"homepage": "https://www.pulumi.io",
Expand Down Expand Up @@ -51,6 +51,7 @@
"token": {
"type": "string",
"description": "Genesis Cloud API token. May also be provided via `GENESISCLOUD_TOKEN` environment variable.\n",
"defaultInfo": { "environment": ["GENESISCLOUD_TOKEN"] },
"secret": true
}
}
Expand Down Expand Up @@ -324,6 +325,7 @@
"token": {
"type": "string",
"description": "Genesis Cloud API token. May also be provided via `GENESISCLOUD_TOKEN` environment variable.\n",
"defaultInfo": { "environment": ["GENESISCLOUD_TOKEN"] },
"secret": true
}
}
Expand Down
7 changes: 6 additions & 1 deletion provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ func Provider() tfbridge.ProviderInfo {
Version: Version,
GitHubOrg: "genesiscloud",
MetadataInfo: tfbridge.NewProviderMetadata(metadata),
Config: map[string]*tfbridge.SchemaInfo{
Config: map[string]*tfbridge.SchemaInfo{
"token": {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"GENESISCLOUD_TOKEN"},
},
},
// Add any rquired configuration here, or remove the example below if
// no additional points are required.
// "region": {
Expand Down
10 changes: 9 additions & 1 deletion sdk/go/genesiscloud/config/config.go

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

5 changes: 5 additions & 0 deletions sdk/go/genesiscloud/provider.go

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

2 changes: 1 addition & 1 deletion sdk/nodejs/config/vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Object.defineProperty(exports, "pollingInterval", {
export declare const token: string | undefined;
Object.defineProperty(exports, "token", {
get() {
return __config.get("token");
return __config.get("token") ?? utilities.getEnv("GENESISCLOUD_TOKEN");
},
enumerable: true,
});
Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class Provider extends pulumi.ProviderResource {
{
resourceInputs["endpoint"] = args ? args.endpoint : undefined;
resourceInputs["pollingInterval"] = args ? args.pollingInterval : undefined;
resourceInputs["token"] = args?.token ? pulumi.secret(args.token) : undefined;
resourceInputs["token"] = (args?.token ? pulumi.secret(args.token) : undefined) ?? utilities.getEnv("GENESISCLOUD_TOKEN");
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["token"] };
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dotnet add package GenesisCloud.PulumiGenesisCloud
The following configuration points are available:

- `genesiscloud:token` - (Required) This is the Genesis Cloud API Token, can also be specified with the `GENESISCLOUD_TOKEN` environment variable.
- `genesiscloud:endpoint` - (Optional) Genesis Cloud API endpoint, can be used to override the default API Endpoint `https://api.genesiscloud.com`.
- `genesiscloud:endpoint` - (Optional) This is the Genesis Cloud API endpoint, can be used to override the default API Endpoint `https://api.genesiscloud.com`. It can also be specified with the `GENESISCLOUD_ENDPOINT` environment variable.

## Reference

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/pulumi_genesiscloud/config/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ def token(self) -> Optional[str]:
"""
Genesis Cloud API token. May also be provided via `GENESISCLOUD_TOKEN` environment variable.
"""
return __config__.get('token')
return __config__.get('token') or _utilities.get_env('GENESISCLOUD_TOKEN')

4 changes: 4 additions & 0 deletions sdk/python/pulumi_genesiscloud/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def __init__(__self__, *,
pulumi.set(__self__, "endpoint", endpoint)
if polling_interval is not None:
pulumi.set(__self__, "polling_interval", polling_interval)
if token is None:
token = _utilities.get_env('GENESISCLOUD_TOKEN')
if token is not None:
pulumi.set(__self__, "token", token)

Expand Down Expand Up @@ -135,6 +137,8 @@ def _internal_init(__self__,

__props__.__dict__["endpoint"] = endpoint
__props__.__dict__["polling_interval"] = polling_interval
if token is None:
token = _utilities.get_env('GENESISCLOUD_TOKEN')
__props__.__dict__["token"] = None if token is None else pulumi.Output.secret(token)
secret_opts = pulumi.ResourceOptions(additional_secret_outputs=["token"])
opts = pulumi.ResourceOptions.merge(opts, secret_opts)
Expand Down

0 comments on commit 70c3d3d

Please sign in to comment.