-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathschema_deployment_action_package.go
80 lines (68 loc) · 2.45 KB
/
schema_deployment_action_package.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package octopusdeploy
import (
"github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func expandDeploymentActionPackage(values interface{}) *octopusdeploy.DeploymentActionPackage {
if values == nil {
return nil
}
flattenedValues := values.([]interface{})
if len(flattenedValues) == 0 {
return nil
}
flattenedMap := flattenedValues[0].(map[string]interface{})
return &octopusdeploy.DeploymentActionPackage{
DeploymentAction: flattenedMap["deployment_action"].(string),
PackageReference: flattenedMap["package_reference"].(string),
}
}
func expandDeploymentActionPackages(values interface{}) []octopusdeploy.DeploymentActionPackage {
if values == nil {
return nil
}
actionPackages := []octopusdeploy.DeploymentActionPackage{}
for _, v := range values.([]interface{}) {
flattenedMap := v.(map[string]interface{})
actionPackages = append(actionPackages, octopusdeploy.DeploymentActionPackage{
DeploymentAction: flattenedMap["deployment_action"].(string),
PackageReference: flattenedMap["package_reference"].(string),
})
}
return actionPackages
}
func flattenDeploymentActionPackage(deploymentActionPackage *octopusdeploy.DeploymentActionPackage) []interface{} {
if deploymentActionPackage == nil {
return nil
}
flattenedDeploymentActionPackage := make(map[string]interface{})
flattenedDeploymentActionPackage["deployment_action"] = deploymentActionPackage.DeploymentAction
flattenedDeploymentActionPackage["package_reference"] = deploymentActionPackage.PackageReference
return []interface{}{flattenedDeploymentActionPackage}
}
func flattenDeploymentActionPackages(deploymentActionPackages []octopusdeploy.DeploymentActionPackage) []interface{} {
if len(deploymentActionPackages) == 0 {
return nil
}
flattenedDeploymentActionPackages := []interface{}{}
for _, v := range deploymentActionPackages {
flattenedDeploymentActionPackage := map[string]interface{}{
"deployment_action": v.DeploymentAction,
"package_reference": v.PackageReference,
}
flattenedDeploymentActionPackages = append(flattenedDeploymentActionPackages, flattenedDeploymentActionPackage)
}
return flattenedDeploymentActionPackages
}
func getDeploymentActionPackageSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"deployment_action": {
Optional: true,
Type: schema.TypeString,
},
"package_reference": {
Optional: true,
Type: schema.TypeString,
},
}
}