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

Add missing autobuild-disabled flag to publish command #2733

Merged
merged 7 commits into from
Apr 24, 2023
Merged

Add missing autobuild-disabled flag to publish command #2733

merged 7 commits into from
Apr 24, 2023

Conversation

alekseybb197
Copy link
Contributor

@alekseybb197 alekseybb197 commented Apr 19, 2023

What does this change

Added cli flag and configuration key for prevent unexpected autobuild invocation image during publish command because it crush pipelines execute.

Use as "porter publish ... --autobuild-disable" in cli or insert "autobuild-disable: true" into config.yaml.

What issue does it fix

Follow-up to #2573 which missed adding the flag to publish

Notes for the reviewer

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

Reviewer Checklist

  • Comment with /azp run test-porter-release if a magefile or build script was modified
  • Comment with /azp run porter-integration if it's a non-trivial PR

@carolynvs
Copy link
Member

Closing as this was already implemented in #2573. You can find more open issues that are good for new contributors at https://getporter.org/find-issue

@carolynvs carolynvs closed this Apr 19, 2023
@alekseybb197
Copy link
Contributor Author

Sorry, as I saw this flag is absent into publish code! And it crush our pipelines which build and publish cnab. Because we can not able send build-arg when autobuild appeared. But let it be)

@carolynvs
Copy link
Member

Oops, thanks for pushing back, I thought I had updated the publish command in that pull request and see now that it was missed. I'll reopen and review.

@carolynvs carolynvs reopened this Apr 19, 2023
* The flag doesn't need to be manually configured with viper because the flag is defined on publish.
* The flag doesn't need to be defined on Config.DataStore because the flag is defined on publish.
* Update example to use --autobuild-disabled without =true, since that is the default when the flag is specified.

Signed-off-by: Carolyn Van Slyck <[email protected]>
Add a test to validate that we can disable autobuild for the publish command.

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs
Copy link
Member

@alekseybb197 Thank you for the fix! I have pushed 2 commits to your pull request to simplify how --autobuild-disabled is defined on publish and added a test to validate that the flag is working.

Before I can merge, can you push a commit to your branch that includes the following text

Signed-off-by: Aleksey Barabanov <[email protected]>

This indicates you agree to our repository's DCO requirement. https://getporter.org/contribute/guide/#signing-your-commits

@carolynvs
Copy link
Member

/azp run porter-integration

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@alekseybb197
Copy link
Contributor Author

Thanks @carolynvs , I try ...
I was upset and merged as is for my fork)

@alekseybb197
Copy link
Contributor Author

@carolynvs I see you remove "autobuild-disabled" from config file. Is it right? I'm only asking about the accepted decision. In other words, I do not need to return it with my commit?

@carolynvs
Copy link
Member

Correct, I removed AutoBuildDisabled from datastore.go because it is not necessary. The additional viper configuration in the cmd/porter package and declaring a config setting in DataStore is only needed for configuration values that are not defined as flags on a command. So please do not add it back.

You can validate this locally by running mage build install and then editing your ~/.porter/config.yaml file to set autobuild-disabled: true. Then try to publish a bundle without building it first and you should see it stop immediately because autobuild is disabled.

@alekseybb197
Copy link
Contributor Author

Carolyn, with all due respect, I can't do this.

ansible@test-vm:/local$ git clone https://github.com/getporter/porter.git
ansible@test-vm:
/local$ cd porter
ansible@test-vm:/local/porter$ mage build
ansible@test-vm:
/local/porter$ LC_ALL=C ll bin
total 62088
drwxrwx--- 5 ansible ansible 4096 Apr 19 23:33 ./
drwxrwxr-x 16 ansible ansible 4096 Apr 19 23:33 ../
drwxrwx--- 9 ansible ansible 4096 Apr 19 23:33 mixins/
-rwxrwxr-x 1 ansible ansible 63555130 Apr 19 23:33 porter*
drwxrwx--- 2 ansible ansible 4096 Apr 19 23:33 runtimes/
drwxrwx--- 2 ansible ansible 4096 Apr 19 23:33 v1.0.13-14-gc0dcb287/
ansible@test-vm:/local/porter$
ansible@test-vm:
/local/porter$ mage install
installing Porter from bin to /home/ansible/.porter
ansible@test-vm:/local/porter$ echo "autobuild-disabled: true" >/.porter/config.yaml
ansible@test-vm:/local/porter$ cd ../examples/helm-multiarch/
ansible@test-vm:
/local/examples/helm-multiarch$ porter publish -r far.far.away
Changes have been detected and the previously built bundle is out-of-date, rebuilding the bundle before proceeding...
Building bundle ===>
Copying porter runtime ===>
Copying mixins ===>
Copying mixin exec ===>
Copying mixin helm3 ===>
Building invocation image
[+] Building 1.9s (5/5)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.26kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 227B 0.0s
=> resolve image config for docker.io/docker/dockerfile-upstream:1.4.0 1.0s
=> CACHED docker-image:https://docker.io/docker/dockerfile-upstream:1.4.0@sha256:178c4e4a93795b9365dbf6cf10da8fcf517fcb4a17f1943a775c0f548e9fc2ff 0.0s
=> [internal] load metadata for docker.io/library/debian:stretch-slim 0.7s
^Ccancel requested

Maybe I'm wrong about something. Maybe I'm missing something

@carolynvs
Copy link
Member

Let me double check locally. I can also update the test to explicitly use config instead of the flag.

@carolynvs
Copy link
Member

I found a regression in binding config file values to flags in some circumstances. #2735

Once that is fixed (in-progress), then the autobuild-disabled config file setting should work as expected without the additional configuration (defining it on DataStore).

@alekseybb197
Copy link
Contributor Author

Great! But on the other hand, I don’t know how to fill a commit with a signature :)
I admit it's my fault that I didn't set up dco in time

@carolynvs
Copy link
Member

One of your commits does have a signature, so I have marked the DCO as passing. When I merge, I will squash the commits into a single signed commit, co-authored by both of us. So everything is fine.

I should have that config file regression fixed soon. Once that's merged, I'll update my publish test to use a config file (instead of a flag), and we can be sure that the original issue that you raised is addressed before I merge this PR.

@alekseybb197
Copy link
Contributor Author

Thanks a lot Carolyn! Have a nice day!

This adds a regression test for setting autobuild-disabled to true in a config file and having the CLI correctly pick up the setting.

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs
Copy link
Member

/azp run porter-integration

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Thank you for your patience on this one! I appreciate the bug report and fix 👍

@@ -80,3 +80,4 @@ and we will add you. **All** contributors belong here. 💯
* [James Blair](https://github.com/jmhbnz)
* [Chengwei Guo](https://github.com/cw-Guo)
* [Sarah Christoff](https://github.com/hypernovasunnix)
* [Aleksey Barabanov](https://github.com/alekseybb197)
Copy link
Member

Choose a reason for hiding this comment

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

🎉

@carolynvs carolynvs changed the title Alekseybb197/disable autobuild Add missing autobuild-disable flag to publish command Apr 24, 2023
@carolynvs carolynvs merged commit 0e739d8 into getporter:main Apr 24, 2023
@carolynvs carolynvs changed the title Add missing autobuild-disable flag to publish command Add missing autobuild-disabled flag to publish command Apr 24, 2023
bdegeeter pushed a commit to bdegeeter/porter that referenced this pull request May 11, 2023
* add addBundleDefinitionFlags to publish cmd

* add AutoBuildDisabled to publish cmd

* fix docs

Signed-off-by: Aleksey Barabanov <[email protected]>

* Correct how --autobuild-disabled is defined on publish

* The flag doesn't need to be manually configured with viper because the flag is defined on publish.
* The flag doesn't need to be defined on Config.DataStore because the flag is defined on publish.
* Update example to use --autobuild-disabled without =true, since that is the default when the flag is specified.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Add test for publish --autobuild-disabled

Add a test to validate that we can disable autobuild for the publish command.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Add regression test for autobuild-disabled via config

This adds a regression test for setting autobuild-disabled to true in a config file and having the CLI correctly pick up the setting.

Signed-off-by: Carolyn Van Slyck <[email protected]>

---------

Signed-off-by: Aleksey Barabanov <[email protected]>
Signed-off-by: Carolyn Van Slyck <[email protected]>
Co-authored-by: Aleksey Barabanov <[email protected]>
Co-authored-by: Carolyn Van Slyck <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants