-
Notifications
You must be signed in to change notification settings - Fork 67
/
schema_tentacle_version_details.go
62 lines (54 loc) · 1.71 KB
/
schema_tentacle_version_details.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
55
56
57
58
59
60
61
62
package octopusdeploy
import (
"github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func expandTentacleVersionDetails(values interface{}) *octopusdeploy.TentacleVersionDetails {
if values == nil {
return nil
}
flattenedValues := values.([]interface{})
flattenedTentacleVersionDetails := flattenedValues[0].(map[string]interface{})
version := flattenedTentacleVersionDetails["version"].(string)
return &octopusdeploy.TentacleVersionDetails{
UpgradeLocked: flattenedTentacleVersionDetails["upgrade_locked"].(bool),
UpgradeRequired: flattenedTentacleVersionDetails["upgrade_required"].(bool),
UpgradeSuggested: flattenedTentacleVersionDetails["upgrade_suggested"].(bool),
Version: &version,
}
}
func flattenTentacleVersionDetails(tentacleVersionDetails *octopusdeploy.TentacleVersionDetails) []interface{} {
if tentacleVersionDetails == nil {
return nil
}
return []interface{}{map[string]interface{}{
"upgrade_locked": tentacleVersionDetails.UpgradeLocked,
"upgrade_required": tentacleVersionDetails.UpgradeRequired,
"upgrade_suggested": tentacleVersionDetails.UpgradeSuggested,
"version": tentacleVersionDetails.Version,
}}
}
func getTentacleVersionDetailsSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"upgrade_locked": {
Computed: true,
Optional: true,
Type: schema.TypeBool,
},
"upgrade_required": {
Computed: true,
Optional: true,
Type: schema.TypeBool,
},
"upgrade_suggested": {
Computed: true,
Optional: true,
Type: schema.TypeBool,
},
"version": {
Computed: true,
Optional: true,
Type: schema.TypeString,
},
}
}