Skip to content

Commit 4c9b895

Browse files
committed
Do not fail the planning phase if the custom template name specified 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>
1 parent abea42c commit 4c9b895

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/resources/policy/kind/custom/recipe/tmc_custom_schema.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
policyrecipecustomcommonmodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/policy/recipe/custom/common"
2121
recipemodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/recipe"
2222
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/policy/kind/common"
23+
clienterrors "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/errors"
2324
)
2425

2526
var TMCCustomSchema = &schema.Schema{
@@ -117,7 +118,11 @@ func ValidateCustomRecipe(config authctx.TanzuContext, customRecipe map[string]i
117118
recipeData, err := config.TMCConnection.RecipeResourceService.RecipeResourceServiceGet(recipeModel)
118119

119120
if err != nil {
120-
errMessages = append(errMessages, err.Error())
121+
// 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
122+
// 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.
123+
if !clienterrors.IsNotFoundError(err) {
124+
errMessages = append(errMessages, err.Error())
125+
}
121126
} else {
122127
errs := ValidateRecipeParameters(recipeData.Recipe.Spec.InputSchema, customRecipe[ParametersKey].(string))
123128

0 commit comments

Comments
 (0)