diff --git a/kustomize/data_source_kustomization.go b/kustomize/data_source_kustomization.go index 3882b41..e869b21 100644 --- a/kustomize/data_source_kustomization.go +++ b/kustomize/data_source_kustomization.go @@ -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 } diff --git a/kustomize/data_source_kustomization_build.go b/kustomize/data_source_kustomization_build.go index 3af5318..274c95b 100644 --- a/kustomize/data_source_kustomization_build.go +++ b/kustomize/data_source_kustomization_build.go @@ -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, diff --git a/kustomize/data_source_kustomization_overlay.go b/kustomize/data_source_kustomization_overlay.go index 9c49633..dbb7a25 100644 --- a/kustomize/data_source_kustomization_overlay.go +++ b/kustomize/data_source_kustomization_overlay.go @@ -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,