Skip to content

Commit

Permalink
fix(bundles): cleanup --final-repo param usage in bundles
Browse files Browse the repository at this point in the history
* 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 4d77117
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
1 change: 0 additions & 1 deletion cmd/werf/bundle/apply/apply.go
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion cmd/werf/bundle/download/download.go
Expand Up @@ -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)
Expand Down
23 changes: 13 additions & 10 deletions cmd/werf/bundle/publish/publish.go
Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
4 changes: 0 additions & 4 deletions cmd/werf/bundle/render/render.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4d77117

Please sign in to comment.