Skip to content

Commit 6233998

Browse files
committed
required sensitive token and default to cloud.onhatchet.run
1 parent 73eac76 commit 6233998

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ terraform {
4444
}
4545
4646
provider "hatchetcloud" {
47-
endpoint = "https://api.hatchet.cloud"
48-
token = "your-api-token-here"
47+
# endpoint is optional and defaults to "cloud.onhatchet.run"
48+
# token is required
49+
token = "your-api-token-here"
4950
}
5051
```
5152

@@ -79,8 +80,8 @@ make clean
7980

8081
The Hatchet Cloud provider supports the following configuration options:
8182

82-
- `endpoint` (Optional): The Hatchet Cloud API endpoint. Defaults to the production API.
83-
- `token` (Optional, Sensitive): Your Hatchet Cloud API token for authentication.
83+
- `endpoint` (Optional): The Hatchet Cloud API endpoint. Defaults to "cloud.onhatchet.run".
84+
- `token` (Required, Sensitive): Your Hatchet Cloud API token for authentication.
8485

8586
## Contributing
8687

examples/provider/provider.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ terraform {
88
}
99

1010
provider "hatchetcloud" {
11-
endpoint = "https://api.hatchet.cloud"
12-
token = "your-api-token-here"
11+
# endpoint is optional and defaults to "cloud.onhatchet.run"
12+
# token is required
13+
token = "your-api-token-here"
1314
}

internal/provider/provider.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (p *HatchetCloudProvider) Schema(ctx context.Context, req provider.SchemaRe
4444
},
4545
"token": schema.StringAttribute{
4646
MarkdownDescription: "Hatchet Cloud API token",
47-
Optional: true,
47+
Required: true,
4848
Sensitive: true,
4949
},
5050
},
@@ -60,12 +60,15 @@ func (p *HatchetCloudProvider) Configure(ctx context.Context, req provider.Confi
6060
return
6161
}
6262

63-
// Configuration values are now available.
64-
// if data.Endpoint.IsNull() { /* ... */ }
63+
// Set default endpoint if not provided
64+
endpoint := data.Endpoint.ValueString()
65+
if endpoint == "" {
66+
endpoint = "cloud.onhatchet.run"
67+
}
6568

6669
// Example client configuration for data sources and resources
6770
client := &HatchetCloudClient{
68-
Endpoint: data.Endpoint.ValueString(),
71+
Endpoint: endpoint,
6972
Token: data.Token.ValueString(),
7073
}
7174
resp.DataSourceData = client

main.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ import (
1818
// can be customized.
1919
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
2020

21-
var (
22-
// these will be set by the goreleaser configuration
23-
// to appropriate values for the compiled binary.
24-
version string = "dev"
25-
)
21+
// these will be set by the goreleaser configuration
22+
// to appropriate values for the compiled binary.
23+
var version string = "dev"
2624

2725
func main() {
2826
opts := providerserver.ServeOpts{

0 commit comments

Comments
 (0)