-
Notifications
You must be signed in to change notification settings - Fork 65
/
schema_sensitive_value.go
54 lines (44 loc) · 1.23 KB
/
schema_sensitive_value.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package octopusdeploy
import (
"github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func expandSensitiveValue(values interface{}) *octopusdeploy.SensitiveValue {
if values == nil {
return nil
}
flattenedValues := values.([]interface{})
if len(flattenedValues) == 0 {
return nil
}
flattenedSensitiveValue := flattenedValues[0].(map[string]interface{})
newValue := flattenedSensitiveValue["new_value"].(string)
expandedSensitiveValue := octopusdeploy.NewSensitiveValue(newValue)
if hint, ok := flattenedSensitiveValue["hint"]; ok {
hintString := hint.(string)
expandedSensitiveValue.Hint = &hintString
}
return expandedSensitiveValue
}
func flattenSensitiveValue(sensitiveValue *octopusdeploy.SensitiveValue) []interface{} {
if sensitiveValue == nil {
return nil
}
return []interface{}{map[string]interface{}{
"hint": sensitiveValue.Hint,
"new_value": sensitiveValue.NewValue,
}}
}
func getSensitiveValueSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"hint": {
Optional: true,
Type: schema.TypeString,
},
"new_value": {
Optional: true,
Sensitive: true,
Type: schema.TypeString,
},
}
}