Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow KustomizationRef.Path and PolicyRef.Path to be template #533

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion controllers/handlers_kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion controllers/handlers_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down