/
schema_action_run_kubectl_script.go
58 lines (46 loc) · 1.74 KB
/
schema_action_run_kubectl_script.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
package octopusdeploy
import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func getRunKubectlScriptSchema() *schema.Schema {
actionSchema, element := getActionSchema()
addExecutionLocationSchema(element)
addScriptFromPackageSchema(element)
addPackagesSchema(element, false)
addWorkerPoolSchema(element)
addWorkerPoolVariableSchema(element)
element.Schema["namespace"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
}
element.Schema["script_body"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
}
element.Schema["script_syntax"] = &schema.Schema{
Computed: true,
Optional: true,
Type: schema.TypeString,
}
element.Schema["variable_substitution_in_files"] = &schema.Schema{
Description: "A newline-separated list of file names to transform, relative to the package contents. Extended wildcard syntax is supported.",
Optional: true,
Type: schema.TypeString,
}
return actionSchema
}
func expandRunKubectlScriptAction(flattenedAction map[string]interface{}) *deployments.DeploymentAction {
action := expandRunScriptAction(flattenedAction)
action.ActionType = "Octopus.KubernetesRunScript"
action.Properties["Octopus.Action.KubernetesContainers.Namespace"] = core.NewPropertyValue(flattenedAction["namespace"].(string), false)
return action
}
func flattenKubernetesRunScriptAction(action *deployments.DeploymentAction) map[string]interface{} {
flattenedAction := flattenRunScriptAction(action)
if v, ok := action.Properties["Octopus.Action.KubernetesContainers.Namespace"]; ok {
flattenedAction["namespace"] = v.Value
}
return flattenedAction
}