-
Notifications
You must be signed in to change notification settings - Fork 63
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
Saving bundles as an intermediate ocitar #612
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: ashpect <[email protected]>
Signed-off-by: ashpect <[email protected]>
Signed-off-by: ashpect <[email protected]>
Signed-off-by: ashpect <[email protected]>
Signed-off-by: ashpect <[email protected]>
Signed-off-by: ashpect <[email protected]>
Signed-off-by: ashpect <[email protected]>
Signed-off-by: ashpect <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, made some comments in the code.
On a more generic note:
- We need to add some tests to this new feature
- Can we use ggcr to read/write the tarballs for us, since this is a regular OCI tar we should be able to use something like https://github.com/google/go-containerregistry/tree/main/pkg/v1/tarball to do this work.
- In terms of form, I think I would prefer us to provide variables like
ociTarPath
to the Push functions instead of providing them to the constructors since that has been the pattern we have been using. The idea here is that when you call the function you choose the Repository/location where you want to store the result. Another option that might make more sense here is instead of calling NewContents().Push maybe we should have a new function function called NewContents().PushToTar() since we do not need the majority of the code in Push because we are not building tags or writing them
processedImages, err = c.tarImageSet.Import(tempDir, importRepo, c.registry, true) | ||
if err != nil { | ||
return nil, fmt.Errorf("Importing OCI tar: %s", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is similar to the else case, maybe we can move this outside the if statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err != nil { | ||
return nil, err | ||
} | ||
err = image.ExtractOciTarGz(c.OciFlags.OcitoReg, tempDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us make sure we clean up after ourselves
err = image.ExtractOciTarGz(c.OciFlags.OcitoReg, tempDir) | |
defer os.RemoveAll(tempDir) | |
err = image.ExtractOciTarGz(c.OciFlags.OcitoReg, tempDir) |
pkg/imgpkg/cmd/copy_repo_src.go
Outdated
if processedImage.ImageIndex != nil { | ||
continue | ||
} | ||
// This is added to not read the lockfile and change the ref for oci-flag. Will be removed once we add an inflate option to copy the refs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this commented out because if we copy from oci-tar to the repository, we do not have all the images? If that is the case, we should change the comment to highlight something like:
// When copying images from an oci-tar to a repository, imgpkg will not try to access the origin repositories and will only copy the OCI Image to the registry, similar to the behavior we currently have on the `imgpkg push` command.
pkg/imgpkg/cmd/copy_repo_src.go
Outdated
err = os.RemoveAll(tempDir) | ||
if err != nil { | ||
fmt.Println("Error cleaning up temporary directory:", err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a prior comment that I think it would be better to use than this part of the code. Because if anything fails in the meanwhile we will leave the folder back
err = os.RemoveAll(tempDir) | |
if err != nil { | |
fmt.Println("Error cleaning up temporary directory:", err) | |
} |
pkg/imgpkg/cmd/oci_flags.go
Outdated
@@ -0,0 +1,23 @@ | |||
// Copyright 2023 The Carvel Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Copyright 2023 The Carvel Authors. | |
// Copyright 2024 The Carvel Authors. |
pkg/imgpkg/image/tar_image.go
Outdated
|
||
// CreateOciTarFileAndDeleteFolder creates a oci tar file from the source folder and deletes the source folder. Used while pushing the oci-tar | ||
func CreateOciTarFileAndDeleteFolder(source, target string) error { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/imgpkg/image/tar_image.go
Outdated
@@ -180,3 +181,119 @@ func (i *TarImage) isExcluded(relPath string) bool { | |||
} | |||
return false | |||
} | |||
|
|||
// CreateOciTarFileAndDeleteFolder creates a oci tar file from the source folder and deletes the source folder. Used while pushing the oci-tar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we deleting the source folder?
If I do imgpkg push -b repo/app1-config -f config/ --to-oci-tar /path/to/file.tar
is my config
folder going to be deleted? We should not do that
pkg/imgpkg/image/tar_image.go
Outdated
|
||
// ExtractOciTarGz extracts the oci tar file to the extractDir | ||
func ExtractOciTarGz(inputDir, extractDir string) error { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,156 @@ | |||
// Copyright 2023 The Carvel Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Copyright 2023 The Carvel Authors. | |
// Copyright 2024 The Carvel Authors. |
Signed-off-by: ashpect <[email protected]>
Implements this proposal.
Implemented except writing the tests, waiting for initial review, after which e2e tests can be written.