Skip to content

Commit 2061ee3

Browse files
authored
Make endpoint and token as optional from provider configuration (#43)
It seems the Configure function is invoked after schema initiation, by setting the two fields as required Terraform asks for endpoint and token without checking the environment variables as coded in `Provider.Configure`
1 parent 0710e2b commit 2061ee3

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

docs/index.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ provider "terrakube" {
3131
<!-- schema generated by tfplugindocs -->
3232
## Schema
3333

34-
### Required
35-
36-
- `endpoint` (String) Terrakube API Endpoint. Example: https://terrakube-api.minikube.net
37-
- `token` (String) Personal Access Token generated in Terrakube UI (https://docs.terrakube.io/user-guide/organizations/api-tokens)
38-
3934
### Optional
4035

41-
- `insecure_http_client` (Boolean) Disable https certificate validation
36+
- `endpoint` (String) Terrakube API Endpoint. Example: https://terrakube-api.minikube.net, can also be specified with environment variable `TERRAKUBE_ENDPOINT`.
37+
- `insecure_http_client` (Boolean) Disable https certificate validation, default is `false`.
38+
- `token` (String) Access Token generated in Terrakube UI (https://docs.terrakube.io/user-guide/organizations/api-tokens), can also be specificed with environment variable `TERRAKUBE_TOKEN`.

internal/provider/provider.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ package provider
55

66
import (
77
"context"
8+
"os"
9+
810
"github.com/hashicorp/terraform-plugin-framework/path"
911
"github.com/hashicorp/terraform-plugin-log/tflog"
10-
"os"
1112

1213
"github.com/hashicorp/terraform-plugin-framework/datasource"
1314
"github.com/hashicorp/terraform-plugin-framework/provider"
@@ -57,16 +58,16 @@ func (p *TerrakubeProvider) Schema(ctx context.Context, req provider.SchemaReque
5758
resp.Schema = schema.Schema{
5859
Attributes: map[string]schema.Attribute{
5960
"endpoint": schema.StringAttribute{
60-
Required: true,
61-
Description: "Terrakube API Endpoint. Example: https://terrakube-api.minikube.net",
61+
Optional: true,
62+
Description: "Terrakube API Endpoint. Example: https://terrakube-api.minikube.net, can also be specified with environment variable `TERRAKUBE_ENDPOINT`.",
6263
},
6364
"token": schema.StringAttribute{
64-
Required: true,
65-
Description: "Personal Access Token generated in Terrakube UI (https://docs.terrakube.io/user-guide/organizations/api-tokens)",
65+
Optional: true,
66+
Description: "Access Token generated in Terrakube UI (https://docs.terrakube.io/user-guide/organizations/api-tokens), can also be specificed with environment variable `TERRAKUBE_TOKEN`.",
6667
},
6768
"insecure_http_client": schema.BoolAttribute{
6869
Optional: true,
69-
Description: "Disable https certificate validation",
70+
Description: "Disable https certificate validation, default is `false`.",
7071
},
7172
},
7273
}

0 commit comments

Comments
 (0)