diff --git a/controllers/handlers_kustomize.go b/controllers/handlers_kustomize.go index 9d145286..ae7fd79f 100644 --- a/controllers/handlers_kustomize.go +++ b/controllers/handlers_kustomize.go @@ -434,8 +434,18 @@ func deployKustomizeRef(ctx context.Context, c client.Client, remoteRestConfig * defer os.RemoveAll(tmpDir) + // Path can be expressed as a template and instantiate using Cluster fields. + instantiatedPath, err := instantiateTemplateValues(ctx, getManagementClusterConfig(), getManagementClusterClient(), + clusterSummary.Spec.ClusterType, clusterSummary.Spec.ClusterNamespace, clusterSummary.Spec.ClusterName, + clusterSummary.GetName(), kustomizationRef.Path, nil, logger) + if err != nil { + return nil, nil, err + } + + logger.V(logs.LogDebug).Info(fmt.Sprintf("using path %s", instantiatedPath)) + // check build path exists - dirPath := filepath.Join(tmpDir, kustomizationRef.Path) + dirPath := filepath.Join(tmpDir, instantiatedPath) _, err = os.Stat(dirPath) if err != nil { err = fmt.Errorf("kustomization path not found: %w", err) diff --git a/controllers/handlers_utils.go b/controllers/handlers_utils.go index a98176ea..3a076aed 100644 --- a/controllers/handlers_utils.go +++ b/controllers/handlers_utils.go @@ -145,8 +145,18 @@ func deployContentOfSource(ctx context.Context, deployingToMgmtCluster bool, des defer os.RemoveAll(tmpDir) + // Path can be expressed as a template and instantiate using Cluster fields. + instantiatedPath, err := instantiateTemplateValues(ctx, getManagementClusterConfig(), getManagementClusterClient(), + clusterSummary.Spec.ClusterType, clusterSummary.Spec.ClusterNamespace, clusterSummary.Spec.ClusterName, + clusterSummary.GetName(), path, nil, logger) + if err != nil { + return nil, err + } + + logger.V(logs.LogDebug).Info(fmt.Sprintf("using path %s", instantiatedPath)) + // check build path exists - dirPath := filepath.Join(tmpDir, path) + dirPath := filepath.Join(tmpDir, instantiatedPath) _, err = os.Stat(dirPath) if err != nil { logger.Error(err, "source path not found")