Skip to content

Commit

Permalink
Do not fail the planning phase if the custom template name specified …
Browse files Browse the repository at this point in the history
…in the custom policy assignment is not found

Initially this check was added as the custom template creation via TMC TF provider was not supported. Now since the provider supports creation of the custom template removing this check,
to let user create the custom template and assign it to custom policy on the fly.

Signed-off-by: Ramya Bangera <bangerar@vmware.com>
  • Loading branch information
ramya-bangera committed Feb 12, 2024
1 parent abea42c commit 7df2dcd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/pkg/errors"

"github.com/vmware/terraform-provider-tanzu-mission-control/internal/authctx"
clienterrors "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/errors"
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper"
openapiv3 "github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper/openapi_v3_schema_validator"
policyrecipecustommodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/policy/recipe/custom"
Expand Down Expand Up @@ -117,7 +118,11 @@ func ValidateCustomRecipe(config authctx.TanzuContext, customRecipe map[string]i
recipeData, err := config.TMCConnection.RecipeResourceService.RecipeResourceServiceGet(recipeModel)

if err != nil {
errMessages = append(errMessages, err.Error())
// NOTE: If error is 404 not found then do not fail the planning. This fix ensures that if user tries to create the new custom template
// and assign the same template to the custom policy in a single terraform apply operation will be able to proceed, instead of failing in the planning phase.
if !clienterrors.IsNotFoundError(err) {
errMessages = append(errMessages, err.Error())
}
} else {
errs := ValidateRecipeParameters(recipeData.Recipe.Spec.InputSchema, customRecipe[ParametersKey].(string))

Expand Down

0 comments on commit 7df2dcd

Please sign in to comment.