kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

Run kustomize build with kustomize localize and add a no-verify flag.

Open sanaasy opened this issue 1 year ago • 9 comments

Context

Closes issue: https://github.com/kubernetes-sigs/kustomize/issues/5276

This PR adds functionality to auto-run kustomize build when the kustomize localize command is run. . This will run when --no-verify is not specified as false by the user or not specified at all when running the localize command. When the --no-verify flag is added, this check will be skipped.

🎩 Tophatted by doing:

  1. make kustomize
  2. ~/go/bin/kustomize localize . localized-results
  3. ~/go/bin/kustomize localize . localized-results --no-verify
  4. ~/go/bin/kustomize localize . localized-results --scope "/Desktop"

Questions for reviewers

  1. Does the way I approached this issue align with what was in mind when the original issue was created?

sanaasy avatar Feb 18 '24 20:02 sanaasy

This PR has multiple commits, and the default merge method is: merge. You can request commits to be squashed using the label: tide/merge-method-squash

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-ci-robot avatar Feb 18 '24 20:02 k8s-ci-robot

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: sanaasy / name: Sanaa Syed (37ff927b8d04c73726b85ddbbc9dce7530ffa90a, af17fb80986f1cb8b25568734baa862769b588bb, 70e1b710e50a118a74fa53e461810c86540ae7b6, facafce83865888b3c3898356c3f58cb3fb65af6, 3e0e54aca681d6d33293b4c7209aa7c578bb9ccb, 232004241028d23abe748d72b78f2759fa765958, 81503cbf7ef368a013f2f991837f465b5af951e6, b71c4d15b898180ae7298b3f5d669bdfc2d6128a, 2ccdf4e82918693cef1fa992652592724716d482, cdd73c1cf18def21f6a9fe8bc56deea5eae979c2)

Welcome @sanaasy!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kustomize has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

k8s-ci-robot avatar Feb 18 '24 20:02 k8s-ci-robot

Hi @sanaasy. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-ci-robot avatar Feb 18 '24 20:02 k8s-ci-robot

I'm still working on tests for this issue so keeping this in draft!

Edit: this is done!

sanaasy avatar Feb 18 '24 20:02 sanaasy

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: christianh814, sanaasy Once this PR has been reviewed and has the lgtm label, please assign stormqueen1990 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 avatar Feb 27 '24 03:02 k8s-ci-robot

With regards to using exec.Command, I am not sure if I understand the reasoning for choosing it over invoking the build command function directly, since localize and build are relatively co-located in the codebase. Would you mind elaborating on that decision?

Sure! When I first wrote the code, I didn't see that the build command makeBuildCommand from the commands package was exported to be used anywhere in the code. I chose to exec this way to remove the dependency on building the command itself in the localize file and executing the Run command. If this is the preferred method though, I am happy to change it!

sanaasy avatar Feb 28 '24 03:02 sanaasy

Sure! When I first wrote the code, I didn't see that the build command makeBuildCommand from the commands package was exported to be used anywhere in the code. I chose to exec this way to remove the dependency on building the command itself in the localize file and executing the Run command. If this is the preferred method though, I am happy to change it!

Hi there, @sanaasy! Sorry for the delay in responding!

I have some concerns with the exec.Command() approach. Specifically, this approach requires the executable to be present in $PATH, and because it shells out to a separate command, it might be running build in a version that yields a result different from what the caller would yield.

The scenario I have in mind is something like this:

  • I have a system-wide installation of Kustomize that exists under /usr/bin/kustomize, which is at version v4.5.7.
  • I downloaded v5.3.0 to /home/myuser/bin/kustomize.
  • I run /home/myuser/bin/kustomize localize, expecting that build will also be run from this instance.
  • Instead, kustomize localize shells out to /usr/bin/kustomize (the $PATH installation), which could have a different API (and might yield a different result).

Please let me know if my understanding is incorrect, or if this scenario doesn't make sense!

stormqueen1990 avatar Mar 05 '24 00:03 stormqueen1990

I have some concerns with the exec.Command() approach. Specifically, this approach requires the executable to be present in $PATH, and because it shells out to a separate command, it might be running build in a version that yields a result different from what the caller would yield.

That's a fair callout! I have updated the PR to use the local build commands instead and have verified that things work as expected. If you could take another look please!

sanaasy avatar Mar 05 '24 16:03 sanaasy

/test all

stormqueen1990 avatar May 06 '24 02:05 stormqueen1990

/label tide/merge-method-squash

stormqueen1990 avatar May 06 '24 02:05 stormqueen1990