Skip to content

Commit

Permalink
Update client id and secret desc (#48)
Browse files Browse the repository at this point in the history
* Update client id and secret desc

* Update docs

* Generate docs

* Generate docs
  • Loading branch information
tuteng authored May 17, 2024
1 parent d0564d4 commit e8daba7
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 49 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@ lint:
tools:
go install github.com/bflad/tfproviderlint/cmd/[email protected]
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs

docs:
tfplugindocs

.PHONY: build
30 changes: 23 additions & 7 deletions cloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ var descriptions map[string]string

func init() {
descriptions = map[string]string{
"key_file_path": "The path of the private key file",
"key_file_path": "The path of the private key file, you can set it to 'KEY_FILE_PATH' " +
"environment variable, find it in the cloud console under the service account with admin permission",
"client_id": "Client ID of the service account, " +
"you can set it to 'GLOBAL_DEFAULT_CLIENT_ID' environment variable",
"client_secret": "Client Secret of the service account, " +
"you can set it to 'GLOBAL_DEFAULT_CLIENT_SECRET' environment variable",
"organization": "The organization name",
"service_account_name": "The service account name",
"service_account_binding_name": "The service account binding name",
Expand Down Expand Up @@ -129,6 +134,18 @@ func Provider() *schema.Provider {
DefaultFunc: schema.EnvDefaultFunc("KEY_FILE_PATH", nil),
Description: descriptions["key_file_path"],
},
"client_id": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("GLOBAL_DEFAULT_CLIENT_ID", nil),
Description: descriptions["client_id"],
},
"client_secret": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("GLOBAL_DEFAULT_CLIENT_SECRET", nil),
Description: descriptions["client_secret"],
},
},
ResourcesMap: map[string]*schema.Resource{
"streamnative_service_account": resourceServiceAccount(),
Expand Down Expand Up @@ -180,17 +197,16 @@ func providerConfigure(d *schema.ResourceData, terraformVersion string) (interfa
if defaultAPIServer == "" {
defaultAPIServer = GlobalDefaultAPIServer
}
defaultClientId := os.Getenv("GLOBAL_DEFAULT_CLIENT_ID")
defaultClientSecret := os.Getenv("GLOBAL_DEFAULT_CLIENT_SECRET")
//defaultClientEmail := os.Getenv("GLOBAL_DEFAULT_CLIENT_EMAIL")
clientId := d.Get("client_id").(string)
clientSecret := d.Get("client_secret").(string)
var keyFile *auth.KeyFile
var flow *auth.ClientCredentialsFlow
var grant *auth.AuthorizationGrant
var issuer auth.Issuer
if defaultClientId != "" && defaultClientSecret != "" {
if clientId != "" && clientSecret != "" {
keyFile = &auth.KeyFile{
ClientID: defaultClientId,
ClientSecret: defaultClientSecret,
ClientID: clientId,
ClientSecret: clientSecret,
}
issuer = auth.Issuer{
IssuerEndpoint: defaultIssuer,
Expand Down
2 changes: 0 additions & 2 deletions docs/data-sources/apikey.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ description: |-
- `revoked_at` (String) The timestamp of when the key was revoked
- `service_account_name` (String) The service account name
- `token` (String) The token of the api key


2 changes: 0 additions & 2 deletions docs/data-sources/cloud_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,3 @@ Read-Only:
Read-Only:

- `project_id` (String)


2 changes: 0 additions & 2 deletions docs/data-sources/cloud_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ Read-Only:

- `cidr` (String)
- `id` (String)


2 changes: 0 additions & 2 deletions docs/data-sources/pulsar_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,3 @@ Read-Only:

- `kafka` (Map of String)
- `mqtt` (Map of String)


2 changes: 0 additions & 2 deletions docs/data-sources/pulsar_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ description: |-
- `pool_name` (String) The infrastructure pool name to use, supported pool 'shared-aws', 'shared-gcp'
- `pool_namespace` (String) The infrastructure pool namespace to use, supported 'streamnative'
- `ready` (String) Pulsar instance is ready, it will be set to 'True' after the instance is ready


2 changes: 0 additions & 2 deletions docs/data-sources/service_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ description: |-
- `admin` (Boolean) Whether the service account is admin
- `id` (String) The ID of this resource.
- `private_key_data` (String) The private key data


29 changes: 23 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "streamnative Provider"
subcategory: ""
layout: ""
page_title: "Provider: StreamNative Cloud"
description: |-
The Datadog provider allows you to interact with the Datadog API.
---

# streamnative Provider
# StreamNative Cloud Provider

Use the StreamNative Cloud provider to interact with the many resources supported by StreamNative Cloud. You must configure the provider with the proper credentials before you can use it.

## Example Usage

```terraform
terraform {
required_providers {
streamnative = {
version = "0.4.0"
source = "streamnative/streamnative"
}
}
}
provider "streamnative" {
# Please replace path use your own key file path
key_file_path = "<your-key-file-path>"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `key_file_path` (String) The path of the private key file
- `client_id` (String) Client ID of the service account, you can set it to 'GLOBAL_DEFAULT_CLIENT_ID' environment variable
- `client_secret` (String) Client Secret of the service account, you can set it to 'GLOBAL_DEFAULT_CLIENT_SECRET' environment variable
- `key_file_path` (String) The path of the private key file, you can set it to 'KEY_FILE_PATH' environment variable, find it in the cloud console under the service account with admin permission
2 changes: 0 additions & 2 deletions docs/resources/apikey.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,3 @@ description: |-
- `private_key` (String) The private key for decrypting the encrypted token
- `ready` (String) Apikey is ready, it will be set to 'True' after the api key is ready
- `revoked_at` (String) The timestamp of when the key was revoked


2 changes: 0 additions & 2 deletions docs/resources/cloud_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,3 @@ Optional:
Optional:

- `project_id` (String)


2 changes: 0 additions & 2 deletions docs/resources/cloud_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,3 @@ Optional:

- `create` (String)
- `delete` (String)


2 changes: 0 additions & 2 deletions docs/resources/pulsar_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,3 @@ Optional:

- `kafka` (Map of String) Controls the kafka protocol config of pulsar cluster
- `mqtt` (Map of String) Controls the mqtt protocol config of pulsar cluster


2 changes: 0 additions & 2 deletions docs/resources/pulsar_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ description: |-

- `id` (String) The ID of this resource.
- `ready` (String) Pulsar instance is ready, it will be set to 'True' after the instance is ready


2 changes: 0 additions & 2 deletions docs/resources/service_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ description: |-

- `id` (String) The ID of this resource.
- `private_key_data` (String) The private key data


12 changes: 12 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
streamnative = {
source = "streamnative/streamnative"
}
}
}

provider "streamnative" {
# Please replace path use your own key file path
key_file_path = "<your-key-file-path>"
}
20 changes: 16 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.19

require (
github.com/99designs/keyring v1.2.0
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0
github.com/lestrrat-go/jwx/v2 v2.0.21
github.com/mitchellh/go-homedir v1.1.0
Expand All @@ -22,11 +23,16 @@ require (
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
Expand Down Expand Up @@ -65,7 +71,7 @@ require (
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
Expand All @@ -84,6 +90,7 @@ require (
github.com/hashicorp/terraform-registry-address v0.2.1 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
Expand All @@ -96,9 +103,10 @@ require (
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
Expand All @@ -114,12 +122,15 @@ require (
github.com/oklog/run v1.0.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/russross/blackfriday v1.5.2 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.9.0 // indirect
Expand All @@ -145,6 +156,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
Expand Down
Loading

0 comments on commit e8daba7

Please sign in to comment.