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

fix: ARG/ENV used in script does not invalidate build cache (#1688) #1693

Merged
merged 1 commit into from
Dec 30, 2021

Conversation

madawei2699
Copy link
Contributor

Fixes #1688

Description

In this PR, I added a change:

  1. build compositeKey with args or envs.

This can ensure consistency with docker's behavior which is:

  • docker use args/envs and cmd to build compositeKey
func TestPrependEnvOnCmd(t *testing.T) {
	buildArgs := NewBuildArgs(nil)
	buildArgs.AddArg("NO_PROXY", nil)

	args := []string{"sorted=nope", "args=not", "http_proxy=foo", "NO_PROXY=YA"}
	cmd := []string{"foo", "bar"}
	cmdWithEnv := prependEnvOnCmd(buildArgs, args, cmd)
	expected := strslice.StrSlice([]string{
		"|3", "NO_PROXY=YA", "args=not", "sorted=nope", "foo", "bar"})
	assert.Check(t, is.DeepEqual(expected, cmdWithEnv))
}

and also this can solved not expect cached command which run scripts that used args/envs.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
  • Adds integration tests if needed.

See the contribution guide for more details.

Reviewer Notes

  • The code flow looks good.
  • Unit tests and or integration tests added.

Release Notes

Describe any changes here so maintainer can include it in the release notes, or delete this block.

Examples of user facing changes:
- kaniko adds a new flag `--registry-repo` to override registry

@google-cla
Copy link

google-cla bot commented Jul 10, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no CLA not signed by all commit authors label Jul 10, 2021
@madawei2699
Copy link
Contributor Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes CLA signed by all commit authors and removed cla: no CLA not signed by all commit authors labels Jul 10, 2021
@imjasonh
Copy link
Collaborator

Please rebase to get recent CI runs.

@madawei2699
Copy link
Contributor Author

@imjasonh done

@imjasonh imjasonh merged commit ee2249b into GoogleContainerTools:master Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes CLA signed by all commit authors needs-rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ARG/ENV used in script does not invalidate build cache
2 participants