Skip to content

Commit

Permalink
[mirror] Support pushing of unpacked bundles
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Vasilenko <[email protected]>
  • Loading branch information
Maxim Vasilenko committed Jul 22, 2024
1 parent 8e7d774 commit fcb2663
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
21 changes: 13 additions & 8 deletions internal/mirror/cmd/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ func push(_ *cobra.Command, _ []string) error {
})
}

defer os.RemoveAll(mirrorCtx.UnpackedImagesPath)

if err := auth.ValidateWriteAccessForRepo(
mirrorCtx.RegistryHost+mirrorCtx.RegistryPath,
mirrorCtx.RegistryAuth,
Expand All @@ -122,14 +120,21 @@ func push(_ *cobra.Command, _ []string) error {
}
}

err := log.Process("mirror", "Unpacking Deckhouse bundle", func() error {
return bundle.Unpack(&mirrorCtx.BaseContext)
})
if err != nil {
return err
if filepath.Ext(mirrorCtx.BundlePath) == ".tar" {
err := log.Process("mirror", "Unpacking Deckhouse bundle", func() error {
return bundle.Unpack(&mirrorCtx.BaseContext)
})
if err != nil {
return err
}
defer os.RemoveAll(mirrorCtx.UnpackedImagesPath)
} else {
log.InfoLn("Using bundle at", mirrorCtx.BundlePath)
mirrorCtx.UnpackedImagesPath = mirrorCtx.BundlePath
// todo validate bundle
}

err = log.Process("mirror", "Push Deckhouse images to registry", func() error {
err := log.Process("mirror", "Push Deckhouse images to registry", func() error {
return PushDeckhouseToRegistry(mirrorCtx)
})
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions internal/mirror/cmd/push/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ func parseAndValidateParameters(_ *cobra.Command, args []string) error {

func validateImagesBundlePathArg(args []string) error {
ImagesBundlePath = filepath.Clean(args[0])
if filepath.Ext(ImagesBundlePath) != ".tar" {
return errors.New("--images-bundle-path should be a path to tar archive (.tar)")
bundleExtension := filepath.Ext(ImagesBundlePath)
if bundleExtension != ".tar" && bundleExtension != "" {
return errors.New("images-bundle-path argument should be a path to tar archive (.tar) or a directory with unpacked bundle")
}

_, err := os.Stat(ImagesBundlePath)
Expand Down

0 comments on commit fcb2663

Please sign in to comment.