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

Extend the Buildpack strategy to work with the environment variables #906

Merged

Conversation

shahulsonhal
Copy link
Member

@shahulsonhal shahulsonhal commented Oct 18, 2021

Changes

We noticed a shortcoming of the Buildpacks build strategy: as we bypass pack, the environment variables are not working.

Extend the buildstrategy_buildpacks-v3_cr.yaml with the script to process environment variables.

Add a test case to verify the environment variables working with the Buildpack build strategy.

Note: This PR has a dependency with shipwright-io/sample-go#6. The test cases will only pass after merging the shipwright-io/sample-go#6.

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

The Buildpacks sample build strategies now pass environment variables to the the Buildpacks allowing users to customize their behavior

We noticed a shortcoming of the Buildpacks build strategy: as we bypass pack, the environment variables are not working.

Extend the buildstrategy_buildpacks-v3_cr.yaml with the script to process environment variables.

Add a test case to verify the environment variables working with Buildpack.
@openshift-ci openshift-ci bot added the release-note-none Label for when a PR does not need a release note label Oct 18, 2021
@shahulsonhal shahulsonhal added the kind/bug Categorizes issue or PR as related to a bug. label Oct 18, 2021
@shahulsonhal shahulsonhal changed the title Extend the Buildpack strategy to work with the environment variables. Extend the Buildpack strategy to work with the environment variables Oct 18, 2021
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

Please also update the other build strategy files for buildpacks (heroku and the namespaced samples). I'd say no additional test necessary for them assuming we run the exact same code.


for env in "${envs[@]}"; do
IFS='=' read -r key value string <<< "$env"
if [[ "$key" != "" && "$value" != "" ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

Let's not ignore empty values. There might be theoretic use cases where "not present" vs "empty string" makes a difference.

Suggested change
if [[ "$key" != "" && "$value" != "" ]]; then
if [[ "$key" != "" ]]; then

IFS='=' read -r key value string <<< "$env"
if [[ "$key" != "" && "$value" != "" ]]; then
path="${ENV_DIR}/${key}"
echo "--> Writing ${path}..."
Copy link
Member

Choose a reason for hiding this comment

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

This might be very noisy. I personally would remove the echos.

@coreydaley
Copy link
Contributor

I do not feel good about having a + in this file name test/data/build_buildpacks-v3_golang_cr+env.yaml, can we choose something else instead?

@gabemontero
Copy link
Member

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 18, 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

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

I do not feel good about having a + in this file name test/data/build_buildpacks-v3_golang_cr+env.yaml, can we choose something else instead?

@coreydaley Thanks. I have replaced + with _ in the file name.

@SaschaSchwarze0 SaschaSchwarze0 added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Oct 19, 2021
@openshift-ci openshift-ci bot added release-note Label for when a PR has specified a release note and removed release-note-none Label for when a PR does not need a release note labels Oct 19, 2021
@shahulsonhal
Copy link
Member Author

/retest

Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 20, 2021
@openshift-merge-robot openshift-merge-robot merged commit 3d6ec4c into shipwright-io:main Oct 20, 2021
@SaschaSchwarze0 SaschaSchwarze0 added this to the release-v0.7.0 milestone Dec 9, 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 Label for when a PR has specified a release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants