-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 fix tilt with envsubst #3361
🌱 fix tilt with envsubst #3361
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alexeldeib for porting this fix in CAPI
Makefile
Outdated
@@ -173,6 +176,11 @@ $(LINK_CHECKER): $(TOOLS_DIR)/go.mod | |||
$(GO_APIDIFF): $(TOOLS_DIR)/go.mod | |||
cd $(TOOLS_DIR) && go build -tags=tools -o $(GO_APIDIFF_BIN) github.com/joelanford/go-apidiff | |||
|
|||
$(ENVSUBST): $(TOOLS_DIR)/go.mod | |||
cd $(TOOLS_DIR) && go build -tags=tools -o $(ENVSUBST_BIN) github.com/a8m/envsubst/cmd/envsubst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not wrong we should add a new import
cluster-api/hack/tools/tools.go
Line 23 in 5596ab2
_ "github.com/go-bindata/go-bindata" |
Also, why are we using github.com/a8m/envsubst
instead of github.com/drone/envsubst
? my concern is that there will be subtle differences between how those library behaves...
cc @wfernandes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drone doesn't offer a binary, I think they are good enough in compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benmoss drone doesn't offer a binary as part of it's releases but there is a cmd/envsubst
in drone that can be built. So I believe we can build the binary if we needed to.
There are some subtle differences between drone/envsubst
and a8m/envsubst
. The one difference I know of is that a8m handles the differences with operators such as :=, =, :-
whereas drone treats them all the same. Also drone documents that it doesn't support :+
notation as a8m does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oversight on the package differences, I'll grab drone/envsubst
and build the binary
@@ -231,6 +234,9 @@ def enable_providers(): | |||
for name in union_enable_providers: | |||
enable_provider(name) | |||
|
|||
def kustomize(path): | |||
return str(local("kustomize build {} | {}".format(path, envsubst_cmd), quiet = True)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about running local("make envsubst")
before this so we install envsusbt if it hasn't already been? Should be a no-op if it's already there from Make's logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, if this method is being added now what was the tilt script calling before? Or is this overriding some kustomize(path)
function that's defined elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should probably rename the func, tilt provides a function with the same name which does its own handling (that's what was invoked before)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, Tilt's falls back to kubectl kustomize
if kustomize
isn't on the PATH, but that fails with our usage of kustomize (as I learned on my newly provisioned machine today)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, TIL. Yeah, you don't have to change the name of the method if you don't want to. Perhaps a commenting explaining above would do just fine. Or both 🤷 🙂
Great work, I was trying to do this yesterday too and got very close but you figured out the remaining bit of piping kustomize to envsubst 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @alexeldeib!
docs/book/src/developer/tilt.md
Outdated
@@ -13,9 +13,16 @@ workflow that offers easy deployments and rapid iterative builds. | |||
1. [kustomize](https://github.com/kubernetes-sigs/kustomize/blob/master/docs/INSTALL.md) standalone | |||
(`kubectl kustomize` does not work because it is missing some features of kustomize v3) | |||
1. [Tilt](https://docs.tilt.dev/install.html) v0.12.0 or newer | |||
1. [envsubst](https://github.com/a8m/envsubst) v1.1.0 or similar to handle clusterctl var replacement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we really are unable to use drone/envsubst
as a binary here, I suggest we document that drone/envsubst
and a8m/envsubst
have similar behavior because the docs in https://cluster-api.sigs.k8s.io/clusterctl/provider-contract.html#variables call out our usage of drone/envsubst
.
This inconsistency may be confusing to users.
@@ -231,6 +234,9 @@ def enable_providers(): | |||
for name in union_enable_providers: | |||
enable_provider(name) | |||
|
|||
def kustomize(path): | |||
return str(local("kustomize build {} | {}".format(path, envsubst_cmd), quiet = True)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, if this method is being added now what was the tilt script calling before? Or is this overriding some kustomize(path)
function that's defined elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor thing but this LGTM. I haven't tested this out myself so I'll leave approval for @benmoss
docs/book/src/developer/tilt.md
Outdated
1. Clone the [Cluster API](https://github.com/kubernetes-sigs/cluster-api) repository locally | ||
1. Clone the provider(s) you want to deploy locally as well | ||
|
||
We provider a make target to generate the envsubst binary if desired. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
We provider a make target to generate the envsubst binary if desired. | |
We provide a make target to generate the envsubst binary if desired. |
@@ -173,6 +176,11 @@ $(LINK_CHECKER): $(TOOLS_DIR)/go.mod | |||
$(GO_APIDIFF): $(TOOLS_DIR)/go.mod | |||
cd $(TOOLS_DIR) && go build -tags=tools -o $(GO_APIDIFF_BIN) github.com/joelanford/go-apidiff | |||
|
|||
$(ENVSUBST): $(TOOLS_DIR)/go.mod | |||
cd $(TOOLS_DIR) && go build -tags=tools -o $(ENVSUBST_BIN) github.com/drone/envsubst/cmd/envsubst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should do the same in capz, was wondering about the impact the subtle differences between the two could have as well.
27dea82
to
428091c
Compare
Signed-off-by: Alexander Eldeib <[email protected]>
added a quick note about drone/envsubst binary since it's only available on untagged commits |
/test pull-cluster-api-e2e |
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon 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 |
/milestone v0.3.x |
@CecileRobertMichon: You must be a member of the kubernetes-sigs/cluster-api-maintainers GitHub team to set the milestone. If you believe you should be able to issue the /milestone command, please contact your Cluster API Maintainers and have them propose you as an additional delegate for this responsibility. In response to this:
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. |
Thanks for fixing this 😄 ! In the future, should we have a sub-command that exposes our implementation of It'd make a better UX both for clusterctl users, and for developers when using Tilt. Today, we only return an error which isn't clear https://github.com/kubernetes-sigs/cluster-api/blob/master/Tiltfile#L203 |
FYI, I think this breaks
replaces all |
I wonder if we can copy all the |
I was just noticing the same thing yesterday with machine pool feature flags, I think what you suggested is correct. I can make a PR a little later this morning if you don’t beat me to it. |
1 similar comment
I was just noticing the same thing yesterday with machine pool feature flags, I think what you suggested is correct. I can make a PR a little later this morning if you don’t beat me to it. |
I'll let you know if I get started on it; otherwise, I'll wait for you. Thanks! |
I filed #3375 for this |
Signed-off-by: Alexander Eldeib [email protected]
What this PR does / why we need it:
Make tilt work with envsubst
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 #3326