From 4d771175eeee0eaa26689a869d83644e44da94c8 Mon Sep 17 00:00:00 2001 From: Timofey Kirillov Date: Tue, 14 Jun 2022 14:13:50 +0300 Subject: [PATCH] fix(bundles): cleanup --final-repo param usage in bundles * support --final-repo in the "werf bundle publish" param: * store all images in the final repo and the bundle itself; * remove --final-repo for "werf bundle apply/download/render" commands. Signed-off-by: Timofey Kirillov --- cmd/werf/bundle/apply/apply.go | 1 - cmd/werf/bundle/download/download.go | 1 - cmd/werf/bundle/publish/publish.go | 23 +++++++++++++---------- cmd/werf/bundle/render/render.go | 4 ---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/cmd/werf/bundle/apply/apply.go b/cmd/werf/bundle/apply/apply.go index f55b1a90c2..0c28c63a24 100644 --- a/cmd/werf/bundle/apply/apply.go +++ b/cmd/werf/bundle/apply/apply.go @@ -63,7 +63,6 @@ func NewCmd() *cobra.Command { common.SetupHomeDir(&commonCmdData, cmd, common.SetupHomeDirOptions{}) common.SetupRepoOptions(&commonCmdData, cmd, common.RepoDataOptions{}) - common.SetupFinalRepo(&commonCmdData, cmd) common.SetupDockerConfig(&commonCmdData, cmd, "Command needs granted permissions to read, pull and push images into the specified repo, to pull base images") common.SetupInsecureRegistry(&commonCmdData, cmd) diff --git a/cmd/werf/bundle/download/download.go b/cmd/werf/bundle/download/download.go index 99385c5292..39b088b4ef 100644 --- a/cmd/werf/bundle/download/download.go +++ b/cmd/werf/bundle/download/download.go @@ -51,7 +51,6 @@ func NewCmd() *cobra.Command { common.SetupSkipTlsVerifyRegistry(&commonCmdData, cmd) common.SetupRepoOptions(&commonCmdData, cmd, common.RepoDataOptions{}) - common.SetupFinalRepo(&commonCmdData, cmd) common.SetupLogOptions(&commonCmdData, cmd) common.SetupLogProjectDir(&commonCmdData, cmd) diff --git a/cmd/werf/bundle/publish/publish.go b/cmd/werf/bundle/publish/publish.go index e6dc55f7a7..7975072720 100644 --- a/cmd/werf/bundle/publish/publish.go +++ b/cmd/werf/bundle/publish/publish.go @@ -239,7 +239,11 @@ func runPublish(ctx context.Context) error { logboek.LogOptionalLn() - repoAddress, err := commonCmdData.Repo.GetAddress() + stagesStorage, err := common.GetStagesStorage(containerBackend, &commonCmdData) + if err != nil { + return err + } + finalStagesStorage, err := common.GetOptionalFinalStagesStorage(containerBackend, &commonCmdData) if err != nil { return err } @@ -253,14 +257,6 @@ func runPublish(ctx context.Context) error { var imagesRepo string if len(werfConfig.StapelImages) != 0 || len(werfConfig.ImagesFromDockerfile) != 0 { - stagesStorage, err := common.GetStagesStorage(containerBackend, &commonCmdData) - if err != nil { - return err - } - finalStagesStorage, err := common.GetOptionalFinalStagesStorage(containerBackend, &commonCmdData) - if err != nil { - return err - } synchronization, err := common.GetSynchronization(ctx, &commonCmdData, projectName, stagesStorage) if err != nil { return err @@ -401,5 +397,12 @@ func runPublish(ctx context.Context) error { return fmt.Errorf("unable to create bundle: %w", err) } - return bundles.Publish(ctx, bundle, fmt.Sprintf("%s:%s", repoAddress, cmdData.Tag), bundlesRegistryClient) + var bundleRepo string + if finalStagesStorage != nil { + bundleRepo = finalStagesStorage.Address() + } else { + bundleRepo = stagesStorage.Address() + } + + return bundles.Publish(ctx, bundle, fmt.Sprintf("%s:%s", bundleRepo, cmdData.Tag), bundlesRegistryClient) } diff --git a/cmd/werf/bundle/render/render.go b/cmd/werf/bundle/render/render.go index 5d3566e8f8..e2805f87f3 100644 --- a/cmd/werf/bundle/render/render.go +++ b/cmd/werf/bundle/render/render.go @@ -66,7 +66,6 @@ func NewCmd() *cobra.Command { common.SetupHomeDir(&commonCmdData, cmd, common.SetupHomeDirOptions{}) common.SetupRepoOptions(&commonCmdData, cmd, common.RepoDataOptions{}) - common.SetupFinalRepo(&commonCmdData, cmd) common.SetupDockerConfig(&commonCmdData, cmd, "Command needs granted permissions to read, pull and push images into the specified repo, to pull base images") common.SetupInsecureRegistry(&commonCmdData, cmd) @@ -118,9 +117,6 @@ func runRender(ctx context.Context) error { if *commonCmdData.Repo.Address != "" { return fmt.Errorf("only one of --bundle-dir or --repo should be specified, but both provided") } - if *commonCmdData.FinalRepo.Address != "" { - return fmt.Errorf("only one of --bundle-dir or --final-repo should be specified, but both provided") - } isLocal = true case *commonCmdData.Repo.Address == storage.LocalStorageAddress: