Skip to content

Commit

Permalink
Merge pull request #9 from ksoclabs/set_default_in_provider_schema
Browse files Browse the repository at this point in the history
Updates provider to use the default field instead of computing it
  • Loading branch information
maximillianbrain1 authored Sep 5, 2023
2 parents 1481c68 + 713a6b9 commit 8b03023
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
7 changes: 5 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ description: |-
## Example Usage

```terraform
provider "ksoc" {}
provider "ksoc" {
access_key_id = "ksoc_access_key"
secret_key = "ksoc_secret_key"
}
```

<!-- schema generated by tfplugindocs -->
Expand All @@ -24,6 +27,6 @@ provider "ksoc" {}
- `access_key_id` (String, Sensitive) Ksoc Customer Access ID
- `secret_key` (String, Sensitive) Ksoc Customer Secret Key

### Read-Only
### Optional

- `ksoc_api_url` (String) Ksoc API to target. Defaults to https://api.ksoc.com
5 changes: 4 additions & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
provider "ksoc" {}
provider "ksoc" {
access_key_id = "ksoc_access_key"
secret_key = "ksoc_secret_key"
}
3 changes: 0 additions & 3 deletions examples/resources/aws_register/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
resource "ksoc_aws_register" "this" {
ksoc_api_url = "<api endpoint>"
ksoc_assumed_role_arn = "arn:aws:iam::<aws_account_number>:role/ksoc-connector"
access_key_id = "ksoc_access_key"
secret_key = "ksoc_secret_key"
aws_account_id = "aws_account_id"
}
11 changes: 3 additions & 8 deletions internal/ksoc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func New(version string) func() *schema.Provider {
"ksoc_api_url": {
Type: schema.TypeString,
Description: "Ksoc API to target. Defaults to https://api.ksoc.com",
Computed: true,
Required: false,
Default: "https://api.ksoc.com",
Optional: true,
},
"access_key_id": {
Type: schema.TypeString,
Expand Down Expand Up @@ -53,13 +53,8 @@ type Config struct {
}

func configureProvider(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
ksocApiUrl := d.Get("ksoc_api_url").(string)
if ksocApiUrl == "" {
ksocApiUrl = "https://api.ksoc.com"
}

config := Config{
KsocApiUrl: ksocApiUrl,
KsocApiUrl: d.Get("ksoc_api_url").(string),
AccessKeyId: d.Get("access_key_id").(string),
SecretKey: d.Get("secret_key").(string),
}
Expand Down

0 comments on commit 8b03023

Please sign in to comment.