Skip to content

Commit

Permalink
Merge pull request #220 from nazarewk-iac/enable-exec
Browse files Browse the repository at this point in the history
support remaining Kustomize flags
  • Loading branch information
pst authored Jan 23, 2023
2 parents 67b5b31 + 8ccb83f commit 1957b1e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
42 changes: 28 additions & 14 deletions kustomize/data_source_kustomization.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,39 @@ func getKustomizeOptions(d *schema.ResourceData) (opts *krusty.Options) {

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

if len(kOptsList) == 1 {
kOpts := kOptsList[0].(map[string]interface{})
if len(kOptsList) == 0 {
return opts
}

if kOpts["load_restrictor"] != nil {
if kOpts["load_restrictor"].(string) == "none" {
opts.LoadRestrictions = types.LoadRestrictionsNone
}
}
kOpts := kOptsList[0].(map[string]interface{})
getBoolOpt := func(key string) bool {
return kOpts[key] != nil && kOpts[key].(bool)
}

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

if kOpts["helm_path"] != nil {
opts.PluginConfig.HelmConfig.Command = kOpts["helm_path"].(string)
}
}
enableAlphaPlugins := getBoolOpt("enable_alpha_plugins")
enableAlphaPlugins = enableAlphaPlugins || enableHelm || enableExec || enableStar

if enableAlphaPlugins {
opts.PluginConfig = types.EnabledPluginConfig(types.BploUseStaticallyLinked)
}

if kOpts["load_restrictor"] != nil {
if kOpts["load_restrictor"].(string) == "none" {
opts.LoadRestrictions = types.LoadRestrictionsNone
}
}

opts.PluginConfig.FnpLoadingOptions.EnableExec = enableExec
opts.PluginConfig.FnpLoadingOptions.EnableStar = enableStar
opts.PluginConfig.HelmConfig.Enabled = enableHelm

if enableHelm && kOpts["helm_path"] != nil {
opts.PluginConfig.HelmConfig.Command = kOpts["helm_path"].(string)
}

return opts
}
12 changes: 12 additions & 0 deletions kustomize/data_source_kustomization_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,22 @@ func dataSourceKustomization() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"enable_alpha_plugins": {
Type: schema.TypeBool,
Optional: true,
},
"enable_exec": {
Type: schema.TypeBool,
Optional: true,
},
"enable_helm": {
Type: schema.TypeBool,
Optional: true,
},
"enable_star": {
Type: schema.TypeBool,
Optional: true,
},
"helm_path": {
Type: schema.TypeString,
Optional: true,
Expand Down
12 changes: 12 additions & 0 deletions kustomize/data_source_kustomization_overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,22 @@ func dataSourceKustomizationOverlay() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"enable_alpha_plugins": {
Type: schema.TypeBool,
Optional: true,
},
"enable_exec": {
Type: schema.TypeBool,
Optional: true,
},
"enable_helm": {
Type: schema.TypeBool,
Optional: true,
},
"enable_star": {
Type: schema.TypeBool,
Optional: true,
},
"helm_path": {
Type: schema.TypeString,
Optional: true,
Expand Down

0 comments on commit 1957b1e

Please sign in to comment.