Skip to content

Commit 1957b1e

Browse files
authored
Merge pull request #220 from nazarewk-iac/enable-exec
support remaining Kustomize flags
2 parents 67b5b31 + 8ccb83f commit 1957b1e

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed

kustomize/data_source_kustomization.go

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,39 @@ func getKustomizeOptions(d *schema.ResourceData) (opts *krusty.Options) {
122122

123123
kOptsList := d.Get("kustomize_options").([]interface{})
124124

125-
if len(kOptsList) == 1 {
126-
kOpts := kOptsList[0].(map[string]interface{})
125+
if len(kOptsList) == 0 {
126+
return opts
127+
}
127128

128-
if kOpts["load_restrictor"] != nil {
129-
if kOpts["load_restrictor"].(string) == "none" {
130-
opts.LoadRestrictions = types.LoadRestrictionsNone
131-
}
132-
}
129+
kOpts := kOptsList[0].(map[string]interface{})
130+
getBoolOpt := func(key string) bool {
131+
return kOpts[key] != nil && kOpts[key].(bool)
132+
}
133133

134-
if kOpts["enable_helm"] != nil {
135-
if kOpts["enable_helm"].(bool) == true {
136-
opts.PluginConfig = types.EnabledPluginConfig(types.BploUseStaticallyLinked)
134+
enableHelm := getBoolOpt("enable_helm")
135+
enableExec := getBoolOpt("enable_exec")
136+
enableStar := getBoolOpt("enable_star")
137137

138-
if kOpts["helm_path"] != nil {
139-
opts.PluginConfig.HelmConfig.Command = kOpts["helm_path"].(string)
140-
}
141-
}
138+
enableAlphaPlugins := getBoolOpt("enable_alpha_plugins")
139+
enableAlphaPlugins = enableAlphaPlugins || enableHelm || enableExec || enableStar
140+
141+
if enableAlphaPlugins {
142+
opts.PluginConfig = types.EnabledPluginConfig(types.BploUseStaticallyLinked)
143+
}
144+
145+
if kOpts["load_restrictor"] != nil {
146+
if kOpts["load_restrictor"].(string) == "none" {
147+
opts.LoadRestrictions = types.LoadRestrictionsNone
142148
}
143149
}
144150

151+
opts.PluginConfig.FnpLoadingOptions.EnableExec = enableExec
152+
opts.PluginConfig.FnpLoadingOptions.EnableStar = enableStar
153+
opts.PluginConfig.HelmConfig.Enabled = enableHelm
154+
155+
if enableHelm && kOpts["helm_path"] != nil {
156+
opts.PluginConfig.HelmConfig.Command = kOpts["helm_path"].(string)
157+
}
158+
145159
return opts
146160
}

kustomize/data_source_kustomization_build.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,22 @@ func dataSourceKustomization() *schema.Resource {
2727
Type: schema.TypeString,
2828
Optional: true,
2929
},
30+
"enable_alpha_plugins": {
31+
Type: schema.TypeBool,
32+
Optional: true,
33+
},
34+
"enable_exec": {
35+
Type: schema.TypeBool,
36+
Optional: true,
37+
},
3038
"enable_helm": {
3139
Type: schema.TypeBool,
3240
Optional: true,
3341
},
42+
"enable_star": {
43+
Type: schema.TypeBool,
44+
Optional: true,
45+
},
3446
"helm_path": {
3547
Type: schema.TypeString,
3648
Optional: true,

kustomize/data_source_kustomization_overlay.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,22 @@ func dataSourceKustomizationOverlay() *schema.Resource {
643643
Type: schema.TypeString,
644644
Optional: true,
645645
},
646+
"enable_alpha_plugins": {
647+
Type: schema.TypeBool,
648+
Optional: true,
649+
},
650+
"enable_exec": {
651+
Type: schema.TypeBool,
652+
Optional: true,
653+
},
646654
"enable_helm": {
647655
Type: schema.TypeBool,
648656
Optional: true,
649657
},
658+
"enable_star": {
659+
Type: schema.TypeBool,
660+
Optional: true,
661+
},
650662
"helm_path": {
651663
Type: schema.TypeString,
652664
Optional: true,

0 commit comments

Comments
 (0)