Skip to content

Commit

Permalink
ENG-8693: Add value_type support to tf provider
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-bulger committed Jan 13, 2025
1 parent dc86e7f commit 16d4fe9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/resources/secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ output "resource_value" {

### Optional

- `value_type` (String) The value type of the secret
- `visibility` (String) The visibility of the secret

### Read-Only
Expand Down
19 changes: 12 additions & 7 deletions doppler/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ func parseSecretId(id string) (project string, config string, name string, err e
}

type ChangeRequest struct {
OriginalName *string `json:"originalName,omitempty"`
OriginalValue *string `json:"originalValue,omitempty"`
OriginalVisibility *string `json:"originalVisibility,omitempty"`
Name string `json:"name"`
Value *string `json:"value"`
ShouldDelete bool `json:"shouldDelete"`
Visibility string `json:"visibility,omitempty"`
OriginalName *string `json:"originalName,omitempty"`
OriginalValue *string `json:"originalValue,omitempty"`
OriginalVisibility *string `json:"originalVisibility,omitempty"`
Name string `json:"name"`
Value *string `json:"value"`
ShouldDelete bool `json:"shouldDelete"`
Visibility string `json:"visibility,omitempty"`
ValueType ValueType `json:"valueType,omitempty"`
}

type ValueType struct {
Type string `json:"type"`
}

type Project struct {
Expand Down
11 changes: 11 additions & 0 deletions doppler/resource_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ func resourceSecret() *schema.Resource {
Computed: true,
Sensitive: true,
},
"value_type": {
Description: "The value type of the secret",
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"string", "json", "json5", "boolean", "integer", "decimal", "email",
"url", "uuidv4", "cuid2", "ulid", "datetime8601", "date8601", "yaml",
}, false),
},
},
CustomizeDiff: customdiff.ComputedIf("computed", func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) bool {
return d.HasChange("value")
Expand All @@ -75,11 +84,13 @@ func resourceSecretUpdate(ctx context.Context, d *schema.ResourceData, m interfa
name := d.Get("name").(string)
value := d.Get("value").(string)
visibility := d.Get("visibility").(string)
valueType := d.Get("value_type").(string)

changeRequest := ChangeRequest{
Name: name,
Value: &value,
Visibility: visibility,
ValueType: ValueType{Type: valueType},
}
if !d.IsNewResource() {
previousNameValue, _ := d.GetChange("name")
Expand Down

0 comments on commit 16d4fe9

Please sign in to comment.