Skip to content

Commit

Permalink
feat(v2): remove deprecated --tag/--to-tag/--repo from "werf bundle c…
Browse files Browse the repository at this point in the history
…opy"

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Apr 24, 2024
1 parent 3a5e2a1 commit 1a4bea1
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions cmd/werf/bundle/copy/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ import (
)

var cmdData struct {
// TODO(2.0): Legacy {
Repo string
Tag string
ToTag string
// TODO(2.0): } Legacy

From string
To string
}
Expand Down Expand Up @@ -70,10 +64,6 @@ func NewCmd(ctx context.Context) *cobra.Command {
commonCmdData.SetupHelmCompatibleChart(cmd, true)
commonCmdData.SetupRenameChart(cmd)

cmd.Flags().StringVarP(&cmdData.Repo, "repo", "", os.Getenv("WERF_REPO"), "Deprecated param, use --from=ADDR instead. Source address of bundle which should be copied.")
cmd.Flags().StringVarP(&cmdData.Tag, "tag", "", os.Getenv("WERF_TAG"), "Deprecated param, use --from=REPO:TAG instead. Provide from tag version of the bundle to copy ($WERF_TAG or latest by default).")
cmd.Flags().StringVarP(&cmdData.ToTag, "to-tag", "", os.Getenv("WERF_TO_TAG"), "Deprecated param, use --to=REPO:TAG instead. Provide to tag version of the bundle to copy ($WERF_TO_TAG or same as --tag by default).")

cmd.Flags().StringVarP(&cmdData.From, "from", "", os.Getenv("WERF_FROM"), "Source address of the bundle to copy, specify bundle archive using schema `archive:PATH_TO_ARCHIVE.tar.gz`, specify remote bundle with schema `[docker://]REPO:TAG` or without schema.")
cmd.Flags().StringVarP(&cmdData.To, "to", "", os.Getenv("WERF_TO"), "Destination address of the bundle to copy, specify bundle archive using schema `archive:PATH_TO_ARCHIVE.tar.gz`, specify remote bundle with schema `[docker://]REPO:TAG` or without schema.")

Expand All @@ -96,16 +86,12 @@ func runCopy(ctx context.Context) error {
return err
}

var fromAddrRaw string
if cmdData.From == "" && cmdData.Repo == "" {
if cmdData.From == "" {
return fmt.Errorf("--from=ADDRESS param required")
} else if cmdData.From != "" {
fromAddrRaw = cmdData.From
} else {
logboek.Context(ctx).Warn().LogF("Please use --from=ADDRESS param instead of deprecated --repo=ADDRESS param\n")
fromAddrRaw = cmdData.Repo
}

fromAddrRaw := cmdData.From

toAddrRaw := cmdData.To
if toAddrRaw == "" {
return fmt.Errorf("--to=ADDRESS param required")
Expand All @@ -124,25 +110,13 @@ func runCopy(ctx context.Context) error {
var fromRegistry, toRegistry docker_registry.Interface

if fromAddr.RegistryAddress != nil {
// TODO(2.0): remove legacy compatibility param
if cmdData.Tag != "" {
logboek.Context(ctx).Warn().LogF("Please use --from=REPO:TAG tag specification instead of deprecated --tag=TAG param\n")
fromAddr.RegistryAddress.Tag = cmdData.Tag
}

fromRegistry, err = common.CreateDockerRegistry(fromAddr.RegistryAddress.Repo, *commonCmdData.InsecureRegistry, *commonCmdData.SkipTlsVerifyRegistry)
if err != nil {
return err
}
}

if toAddr.RegistryAddress != nil {
// TODO(2.0): remove legacy compatibility param
if cmdData.ToTag != "" {
logboek.Context(ctx).Warn().LogF("Please use --to=REPO:TAG tag specification instead of deprecated --to-tag=TAG param\n")
toAddr.RegistryAddress.Tag = cmdData.ToTag
}

toRegistry, err = common.CreateDockerRegistry(toAddr.RegistryAddress.Repo, *commonCmdData.InsecureRegistry, *commonCmdData.SkipTlsVerifyRegistry)
if err != nil {
return err
Expand Down

0 comments on commit 1a4bea1

Please sign in to comment.