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

🌱 clusterctl: support envsubst in clusterctl config #7343

Merged
merged 1 commit into from
Oct 7, 2022

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Oct 5, 2022

What this PR does / why we need it:
This PR adds support for envsubst for the URL/ file path variables in the clusterctl config.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #5457

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 5, 2022
@sbueringer sbueringer changed the title [WIP] clusterctl: support relative path and HOME/CLUSTERCTL_REPO_PATH env vars [WIP] 🌱 clusterctl: support relative path and HOME/CLUSTERCTL_REPO_PATH env vars Oct 5, 2022
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 5, 2022
@sbueringer sbueringer changed the title [WIP] 🌱 clusterctl: support relative path and HOME/CLUSTERCTL_REPO_PATH env vars 🌱 clusterctl: support ${HOME} and ${CLUSTERCTL_REPOSITORY_HOME} in clusterctl config Oct 5, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 5, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 5, 2022
@sbueringer sbueringer changed the title 🌱 clusterctl: support ${HOME} and ${CLUSTERCTL_REPOSITORY_HOME} in clusterctl config 🌱 clusterctl: support envsubst in clusterctl config Oct 5, 2022
@sbueringer
Copy link
Member Author

@CecileRobertMichon @enxebre @fabriziopandini @vincepri

Hey folks,
It would be really nice to get this PR merged & cherry-picked to release-1.2 as we would like to use it for the ClusterAPI KubeCon tutorial based on CAPI v1.2.3. It would really make the tutorial a lot smoother as we wouldn't have to tell folks to
customize their local clusterctl repository with their Windows/macOS/Linux file paths.

WDYT?

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

@@ -69,6 +70,11 @@ func (o *overrides) Path() string {
f, err := o.configVariablesClient.Get(overrideFolderKey)
if err == nil && strings.TrimSpace(f) != "" {
basepath = f

evaluatedBasePath, err := envsubst.Eval(basepath, os.Getenv)
if err == nil {
Copy link
Member Author

@sbueringer sbueringer Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabriziopandini We have a few options here:

  • log the error
  • silently ignore the error
  • change the interface so the Path() func can return an error

What would you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we are backporting, let's log the error; the we can eventually made a followup PR to change the interface in main

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, done ptal :)

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 5, 2022
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm pending adding the log line in Path

@k8s-ci-robot k8s-ci-robot removed the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 6, 2022
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 6, 2022
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

@fabriziopandini
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 7, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 7, 2022
@k8s-ci-robot k8s-ci-robot merged commit 8d7585a into kubernetes-sigs:main Oct 7, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.3 milestone Oct 7, 2022
@sbueringer sbueringer deleted the pr-clusterctl-path branch October 7, 2022 11:46
@sbueringer
Copy link
Member Author

/cherry-pick release-1.2

@k8s-infra-cherrypick-robot

@sbueringer: cannot checkout release 1-2: error checking out release 1-2: exit status 1. output: error: pathspec 'release 1-2' did not match any file(s) known to git

In response to this:

/cherry-pick release 1-2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-infra-cherrypick-robot

@sbueringer: #7343 failed to apply on top of branch "release-1.2":

Applying: clusterctl: support envsubst in clusterctl config
Using index info to reconstruct a base tree...
M	cmd/clusterctl/client/config/providers_client.go
M	docs/book/src/clusterctl/configuration.md
Falling back to patching base and 3-way merge...
Auto-merging docs/book/src/clusterctl/configuration.md
CONFLICT (content): Merge conflict in docs/book/src/clusterctl/configuration.md
Auto-merging cmd/clusterctl/client/config/providers_client.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 clusterctl: support envsubst in clusterctl config
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Substitute environment variables in clusterctl.yaml
4 participants