Skip to content

Commit

Permalink
Merge pull request #534 from gianlucam76/paths
Browse files Browse the repository at this point in the history
This allow Sveltos to decide which path to use at run-time.
  • Loading branch information
gianlucam76 authored May 8, 2024
2 parents 6251bae + b64d256 commit 7d7ae33
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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

0 comments on commit 7d7ae33

Please sign in to comment.