Skip to content

Commit

Permalink
corrected per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshmimsft committed Feb 26, 2024
1 parent 0a7d6a8 commit 063bfec
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions pkg/recipes/terraform/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func newModuleConfig(moduleSource string, moduleVersion string, params ...Recipe
// providers and the provider configurations registered with UCP. The environment level recipe configuration for providers takes precedence over UCP provider configurations.
func getProviderConfigs(ctx context.Context, requiredProviders []string, ucpConfiguredProviders map[string]providers.Provider, envConfig *recipes.Configuration) (map[string]any, error) {
// Get recipe provider configurations from the environment configuration
providerConfigs := getRecipeProviderConfigs(ctx, envConfig)
providerConfigs := providers.GetRecipeProviderConfigs(ctx, envConfig)

// Build provider configurations for required providers excluding the ones already present in providerConfigs
for _, provider := range requiredProviders {
Expand Down Expand Up @@ -197,32 +197,6 @@ func getProviderConfigs(ctx context.Context, requiredProviders []string, ucpConf
return providerConfigs, nil
}

// getRecipeProviderConfigs returns the Terraform provider configurations for Terraform providers
// specified under the RecipeConfig/Terraform/Providers section under environment configuration.
func getRecipeProviderConfigs(ctx context.Context, envConfig *recipes.Configuration) map[string]any {
providerConfigs := make(map[string]any)

// If the provider is not configured, or has empty configuration, skip this iteration
if envConfig != nil && envConfig.RecipeConfig.Terraform.Providers != nil {
for provider, config := range envConfig.RecipeConfig.Terraform.Providers {
if len(config) > 0 {
configList := make([]any, 0)

for _, configDetails := range config {
//for _, additionalProperty := range configDetails.AdditionalProperties {
// configList = append(configList, additionalProperty)
//}
configList = append(configList, configDetails.AdditionalProperties)
}

providerConfigs[provider] = configList
}
}
}

return providerConfigs
}

// AddTerraformBackend adds backend configurations to store Terraform state file for the deployment.
// Save() must be called to save the generated backend config.
// Currently, the supported backend for Terraform Recipes is Kubernetes secret. https://developer.hashicorp.com/terraform/language/settings/backends/kubernetes
Expand Down

0 comments on commit 063bfec

Please sign in to comment.