Skip to content
Permalink
Browse files
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 <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Jun 14, 2022
1 parent e0562f6 commit 4d771175eeee0eaa26689a869d83644e44da94c8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
@@ -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)
@@ -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)
@@ -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)
}
@@ -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:

0 comments on commit 4d77117

Please sign in to comment.