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

Provide --cache-repo as OCI image layout path #2250

Merged
merged 3 commits into from
Sep 28, 2022

Conversation

natalieparellano
Copy link
Contributor

Description

Adds the ability to provide --cache-repo as an OCI image layout path to cache layers on disk.

This is useful if you want to avoid providing registry credentials to kaniko (when used together with --cache-dir.

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

  • kaniko adds the ability to provide --cache-repo as an OCI image layout path to cache layers on disk

- Adds cache.LayoutCache to implement cache.LayerCache interface
- When opts.CacheRepo has "oci:" prefix, instantiates a LayoutCache

Signed-off-by: Natalie Arellano <[email protected]>
imageRepo, serviceAccount := config.imageRepo, config.serviceAccount
_, ex, _, _ := runtime.Caller(0)
cwd := filepath.Dir(ex)

cacheFlag := "--cache=true"

for dockerfile := range d.TestCacheDockerfiles {
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 may be missing something, but this function is called inside a for loop that also ranges over TestCacheDockerfiles.

@@ -252,74 +252,99 @@ func TestImageNameTagDigestFile(t *testing.T) {
testutil.CheckErrorAndDeepEqual(t, false, err, want, got)
}

var calledExecCommand = []bool{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was never getting mutated anywhere except setCalledFalse

}
if test.ExistingConfig {
afero.WriteFile(fs, util.DockerConfLocation(), []byte(""), os.FileMode(0644))
defer fs.Remove(util.DockerConfLocation())
}
CheckPushPermissions(&opts)
for i, shdCall := range test.ShouldCallExecCommand {
if i < len(calledExecCommand) && shdCall != calledExecCommand[i] {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because calledExecCommand is never mutated, it is always 0 length, and this statement is always false; I wasn't exactly sure what this was originally supposed to be testing, but I added checkPushPermsCallCount to give some more coverage.

Copy link
Collaborator

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

LGTM, some small nits that you can choose to ignore if you'd rather not.

Thanks for your patience, and sorry this took so long to get around to.

pkg/executor/build_test.go Outdated Show resolved Hide resolved
pkg/executor/push_test.go Outdated Show resolved Hide resolved
@natalieparellano
Copy link
Contributor Author

Thanks @imjasonh! I'll make the changes you suggested... will push up a new commit shortly.

Signed-off-by: Natalie Arellano <[email protected]>
@imjasonh imjasonh merged commit 4d077e2 into GoogleContainerTools:main Sep 28, 2022
@natalieparellano natalieparellano deleted the oci-layout-cache branch September 28, 2022 16:16
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.

2 participants