From 16d4fe9781cb9afabf352d0419c2f03fb0808bd6 Mon Sep 17 00:00:00 2001 From: christopher-bulger Date: Mon, 13 Jan 2025 15:38:31 -0800 Subject: [PATCH 1/2] ENG-8693: Add value_type support to tf provider --- docs/resources/secret.md | 1 + doppler/models.go | 19 ++++++++++++------- doppler/resource_secret.go | 11 +++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/resources/secret.md b/docs/resources/secret.md index 57dd5e9..3ae3f61 100644 --- a/docs/resources/secret.md +++ b/docs/resources/secret.md @@ -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 diff --git a/doppler/models.go b/doppler/models.go index 3f53e0a..b64e91e 100644 --- a/doppler/models.go +++ b/doppler/models.go @@ -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 { diff --git a/doppler/resource_secret.go b/doppler/resource_secret.go index 0f95bce..1b5a430 100644 --- a/doppler/resource_secret.go +++ b/doppler/resource_secret.go @@ -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") @@ -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") From 2110597b3ba3b3de07c40e1df38299f0f8532bdb Mon Sep 17 00:00:00 2001 From: christopher-bulger Date: Fri, 17 Jan 2025 08:25:27 -0800 Subject: [PATCH 2/2] ENG-8693: update resourceSecretRead to use valueType --- doppler/models.go | 10 ++++++---- doppler/resource_secret.go | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doppler/models.go b/doppler/models.go index b64e91e..e89473a 100644 --- a/doppler/models.go +++ b/doppler/models.go @@ -36,10 +36,12 @@ type Secret struct { } type SecretValue struct { - Raw *string `json:"raw,omitempty"` - Computed *string `json:"computed,omitempty"` - RawVisibility *string `json:"rawVisibility,omitempty"` - ComputedVisibility *string `json:"computedVisibility,omitempty"` + Raw *string `json:"raw,omitempty"` + Computed *string `json:"computed,omitempty"` + RawVisibility *string `json:"rawVisibility,omitempty"` + ComputedVisibility *string `json:"computedVisibility,omitempty"` + RawValueType *ValueType `json:"rawValueType,omitempty"` + ComputedValueType *ValueType `json:"computedValueType,omitempty"` } func getSecretId(project string, config string, name string) string { diff --git a/doppler/resource_secret.go b/doppler/resource_secret.go index 1b5a430..632850c 100644 --- a/doppler/resource_secret.go +++ b/doppler/resource_secret.go @@ -170,6 +170,10 @@ func resourceSecretRead(ctx context.Context, d *schema.ResourceData, m interface return diag.FromErr(err) } + if err = d.Set("value_type", secret.Value.RawValueType.Type); err != nil { + return diag.FromErr(err) + } + return diags }