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

SHIP-0004: Build Environment Variables #27

Merged
merged 3 commits into from
Oct 8, 2021
Merged

SHIP-0004: Build Environment Variables #27

merged 3 commits into from
Oct 8, 2021

Conversation

coreydaley
Copy link
Contributor

@coreydaley coreydaley commented Jun 23, 2021

Changes

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

Adds the ability to specify environment variables for Builds and BuildRuns as a key=value pair via the command line using the --env flag.
Environment variables specified for a BuildRun will override those in the Build.

Example:  
    $ shp build create my-build --env VAR_1=value-1  
    $ shp buildrun create my-buildrun --env VAR_2=value-2

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note labels Jun 23, 2021
@openshift-ci openshift-ci bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 23, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 4, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 10, 2021
@coreydaley coreydaley added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 13, 2021
@openshift-ci openshift-ci bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 23, 2021
@coreydaley coreydaley changed the title [WIP] SHIP-0004: Build Environment Variables SHIP-0004: Build Environment Variables Sep 27, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2021
@coreydaley coreydaley added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 27, 2021
@coreydaley
Copy link
Contributor Author

/hold
depends on shipwright-io/build#817 and removing line from go.mod

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2021
@gabemontero
Copy link
Member

Changes

Submitter Checklist

* [x]  Includes tests if functionality changed/was added

* [ ]  Includes docs if changes are user-facing

* [ ]  [Set a kind label on this PR](https://prow.k8s.io/command-help#kind)

* [ ]  Release notes block has been filled in, or marked NONE

See the contributor guide for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

release note formattting is not quite right ... nothing is rendoring underneath the heading as I currently view it

@gabemontero
Copy link
Member

otherwise, since I see no one assigned, am I correct @coreydaley that in addition to the hold you have here, this is still a work in progress item, and we should hold off on reviewing?

Or should I add this to the queue and dive in?

thanks

@coreydaley
Copy link
Contributor Author

@gabemontero

  • I have updated the Release Notes section.
  • Yes, you can go ahead and do a review, keeping in mind the comments that you left on shipwright-io/build and that we are waiting on @adambkaplan to make a decision in regards to the afformentioned.

@coreydaley
Copy link
Contributor Author

These tests won't pass until shipwright-io/build#817 merges

Copy link
Member

@gabemontero gabemontero left a comment

Choose a reason for hiding this comment

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

Yeah pending the type for the env var array per my comments in your associated build PR nothing immediate that I see @coreydaley

I did ask a question around the kind / local registry thing ... maybe a change needed there based on the answer (but I'm guessing no)

and lots of useful libs around BATS and the e2e's .... I plan to wait until all that merges so I can build off of it for adding an e2e for ship build run <name> --follow :-)

buildrun_name=$(random_name)

# create a Build with two environment variables
run shp build create ${build_name} --source-url=https://github.com/shipwright-io/sample-go --output-image=my-image --env=VAR_1=build-value-1 --env=VAR_2=build-value-2
Copy link
Member

Choose a reason for hiding this comment

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

@otaviof @coreydaley - I have not tried it yet, but perhaps you all have. With the kind/local registry stuff we are employing, is it correct to say that by default we do NOT need credentials to push images to it?

And hence why I don't see cred creation here?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can assume the registry won't have any authentication, since we are in complete control of the container registry in use after #43 👍🏼

@gabemontero
Copy link
Member

/approve

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 28, 2021
@gabemontero
Copy link
Member

/hold

just in case, as we need to vendor in the associated build PR

@gabemontero
Copy link
Member

@gabemontero

* I have updated the Release Notes section.

* Yes, you can go ahead and do a review, keeping in mind the comments that you left on shipwright-io/build and that we are waiting on @adambkaplan to make a decision in regards to the afformentioned.

some cross referencing with shipwright-io/build#817 (comment) and shipwright-io/build#817 (comment)

summary

  • @coreydaley thinks he'll be able to add all the k8s corev1.envvar *valuefrom related doc and tests, so his change will continue to use that k8s type
  • most likely this cli pr will not take on creating env vars from those supplied sources ... we'll track that as a potential add on based on user feedback, with the history that with the analogous support in openshift builds, we never took on cli level support for adding valuefrom env vars

Copy link
Member

@otaviof otaviof left a comment

Choose a reason for hiding this comment

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

Some comments left on the pull-request, and I'm having issues with the Go modules changed. As per:

$ go mod vendor
go: github.com/shipwright-io/build@v0.5.2-0.20210715083206-5d8fb411a1eb (replaced by github.com/coreydaley/shipwright-io-build@v0.0.0-20210927153915-3175d47a83e4): version "v0.0.0-20210927153915-3175d47a83e4" invalid: unknown revision 3175d47a83e4
go: downloading github.com/coreydaley/shipwright-io-build v0.0.0-20210927153915-3175d47a83e4
go: downloading github.com/spf13/cobra v1.2.1
go: downloading k8s.io/apimachinery v0.20.6
go: downloading k8s.io/client-go v0.20.2
go: downloading k8s.io/api v0.20.6
go: downloading github.com/onsi/gomega v1.10.3
go: downloading k8s.io/cli-runtime v0.20.2
go: downloading github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c
go: downloading k8s.io/utils v0.0.0-20210111153108-fddb29f9d009
go: github.com/shipwright-io/build@v0.5.2-0.20210715083206-5d8fb411a1eb (replaced by github.com/coreydaley/shipwright-io-build@v0.0.0-20210927153915-3175d47a83e4): version "v0.0.0-20210927153915-3175d47a83e4" invalid: unknown revision 3175d47a83e4

Same with go mod tidy, for the record.

@@ -2,25 +2,82 @@

source test/e2e/helpers.sh

setup() {
load 'helpers/bats-support/load'
Copy link
Member

Choose a reason for hiding this comment

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

As much as I like the syntax and the practical effects of the "bats-support" helper functions, I don't like the idea of copying the whole project. I think we could create our own helper functions and make use local tools like grep, awk and others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems a bit silly to basically re-write a library that is provided by the framework that we want to use.
I would be open to adding it as a submodule.

Copy link
Member

Choose a reason for hiding this comment

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

hmmm ... I see both sides here

don't know the answer to this question: even though bats is not a go project, can we use go mod to vendor the repo in, and then load from the vendored location?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems a bit sketchy to me, I think I would rather the submodule.

Copy link
Member

Choose a reason for hiding this comment

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

sorry multitasking too much this AM ... can you clarify / further explain what you mean by submodule ?

Copy link
Member

Choose a reason for hiding this comment

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

looking at @coreydaley 's 2150530 I actually agree with him @otaviof that we should use git submodules for this ... I agree go mod vendoring should not be used for a project like BATS which is not go based

Copy link
Member

Choose a reason for hiding this comment

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

I think vendoring the external dependency is easier due being part of regular commits, we include the vendor directory in the project itself, as usual, and it makes everything simpler IMO. Git submodule is something I only have bad memories, and compared to the vendor option, it does require extra steps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Git sub-modules are really the de-facto way to include external libraries like this in your repository.
Vendoring a project that has absolutely no Go code seems pretty sketchy.

Copy link
Member

Choose a reason for hiding this comment

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

Then, I think we can benefit from a more in-depth discussion about the git-submodules, @coreydaley. Seems a bit too much given we need a couple of assertions we can easily achieve with shell-script.

Copy link
Member

Choose a reason for hiding this comment

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

sounds like another topic for Monday / community meeting

pkg/shp/cmd/buildrun/create.go Show resolved Hide resolved
pkg/shp/cmd/buildrun/create.go Show resolved Hide resolved
@@ -14,14 +15,14 @@ func BuildSpecFromFlags(flags *pflag.FlagSet) *buildv1alpha1.BuildSpec {
spec := &buildv1alpha1.BuildSpec{
Source: buildv1alpha1.Source{
Credentials: &corev1.LocalObjectReference{},
Revision: pointer.String(""),
ContextDir: pointer.String(""),
Revision: pointer.StringPtr(""),
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there was an issue when one of the dependencies was updated.

@coreydaley
Copy link
Contributor Author

Some comments left on the pull-request, and I'm having issues with the Go modules changed. As per:

$ go mod vendor
go: github.com/shipwright-io/build@v0.5.2-0.20210715083206-5d8fb411a1eb (replaced by github.com/coreydaley/shipwright-io-build@v0.0.0-20210927153915-3175d47a83e4): version "v0.0.0-20210927153915-3175d47a83e4" invalid: unknown revision 3175d47a83e4
go: downloading github.com/coreydaley/shipwright-io-build v0.0.0-20210927153915-3175d47a83e4
go: downloading github.com/spf13/cobra v1.2.1
go: downloading k8s.io/apimachinery v0.20.6
go: downloading k8s.io/client-go v0.20.2
go: downloading k8s.io/api v0.20.6
go: downloading github.com/onsi/gomega v1.10.3
go: downloading k8s.io/cli-runtime v0.20.2
go: downloading github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c
go: downloading k8s.io/utils v0.0.0-20210111153108-fddb29f9d009
go: github.com/shipwright-io/build@v0.5.2-0.20210715083206-5d8fb411a1eb (replaced by github.com/coreydaley/shipwright-io-build@v0.0.0-20210927153915-3175d47a83e4): version "v0.0.0-20210927153915-3175d47a83e4" invalid: unknown revision 3175d47a83e4

Same with go mod tidy, for the record.

Correct, since I am pulling in source from my own branch until my other api changes merge in shipwright-io/build.

Copy link
Member

@gabemontero gabemontero left a comment

Choose a reason for hiding this comment

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

so @coreydaley do you plan to add any valueFrom secret/configmap related options on the build/buildrun creates you added ... i.e. a --valueFromSecret= sort of thing

@coreydaley
Copy link
Contributor Author

so @coreydaley do you plan to add any valueFrom secret/configmap related options on the build/buildrun creates you added ... i.e. a --valueFromSecret= sort of thing

No, @adambkaplan and I discussed it yesterday. I also don't think that oc ever added that capability (probably due to complexity)

@gabemontero
Copy link
Member

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 7, 2021
@gabemontero
Copy link
Member

CI is green, including the e2e's

I'll

/approve

and will let @otaviof or @adambkaplan make the final pass for lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 7, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gabemontero

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

go.mod Outdated Show resolved Hide resolved
@coreydaley
Copy link
Contributor Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 7, 2021
@gabemontero
Copy link
Member

/hold

oops / apologies .... you want #51 to merge first ?

@coreydaley
Copy link
Contributor Author

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 7, 2021
@gabemontero
Copy link
Member

ok, now @otaviof @adambkaplan with everything vendored in at the right levels and green tests, I'll wait on an lgtm and let one of you sign off since I already put the approve label previously

@otaviof otaviof self-requested a review October 8, 2021 02:38
Copy link
Member

@otaviof otaviof left a comment

Choose a reason for hiding this comment

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

On the final pass I found a couple of items, overall it looks good though!

docs/testing.md Show resolved Hide resolved
hack/run-e2e.sh Outdated Show resolved Hide resolved
test/e2e/e2e.bats Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 8, 2021
removing dependency for user to have to install BATS
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 8, 2021
@coreydaley
Copy link
Contributor Author

coreydaley commented Oct 8, 2021

@otaviof updates have been made per your suggestions. ptal

docs/testing.md Outdated Show resolved Hide resolved
@otaviof otaviof self-requested a review October 8, 2021 15:10
@otaviof
Copy link
Member

otaviof commented Oct 8, 2021

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 8, 2021
@openshift-merge-robot openshift-merge-robot merged commit 4831482 into shipwright-io:main Oct 8, 2021
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants