Skip to content

Commit

Permalink
Fix Crane option argument parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
phillebaba committed Jun 11, 2024
1 parent fd45291 commit a29c9d7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/cmd/tools/crane.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ func init() {
craneCopy := craneCmd.NewCmdCopy(&craneOptions)

registryCmd.AddCommand(craneCopy)
registryCmd.AddCommand(zarfCraneCatalog(craneOptions))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdList, craneOptions, lang.CmdToolsRegistryListExample, 0))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdPush, craneOptions, lang.CmdToolsRegistryPushExample, 1))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdPull, craneOptions, lang.CmdToolsRegistryPullExample, 0))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdDelete, craneOptions, lang.CmdToolsRegistryDeleteExample, 0))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdDigest, craneOptions, lang.CmdToolsRegistryDigestExample, 0))
registryCmd.AddCommand(zarfCraneCatalog(&craneOptions))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdList, &craneOptions, lang.CmdToolsRegistryListExample, 0))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdPush, &craneOptions, lang.CmdToolsRegistryPushExample, 1))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdPull, &craneOptions, lang.CmdToolsRegistryPullExample, 0))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdDelete, &craneOptions, lang.CmdToolsRegistryDeleteExample, 0))
registryCmd.AddCommand(zarfCraneInternalWrapper(craneCmd.NewCmdDigest, &craneOptions, lang.CmdToolsRegistryDigestExample, 0))
registryCmd.AddCommand(pruneCmd)
registryCmd.AddCommand(craneCmd.NewCmdVersion())

Expand All @@ -100,8 +100,8 @@ func init() {
}

// Wrap the original crane catalog with a zarf specific version
func zarfCraneCatalog(cranePlatformOptions []crane.Option) *cobra.Command {
craneCatalog := craneCmd.NewCmdCatalog(&cranePlatformOptions)
func zarfCraneCatalog(cranePlatformOptions *[]crane.Option) *cobra.Command {
craneCatalog := craneCmd.NewCmdCatalog(cranePlatformOptions)

craneCatalog.Example = lang.CmdToolsRegistryCatalogExample
craneCatalog.Args = nil
Expand Down Expand Up @@ -134,7 +134,7 @@ func zarfCraneCatalog(cranePlatformOptions []crane.Option) *cobra.Command {

// Add the correct authentication to the crane command options
authOption := images.WithPullAuth(zarfState.RegistryInfo)
cranePlatformOptions = append(cranePlatformOptions, authOption)
*cranePlatformOptions = append(*cranePlatformOptions, authOption)

if tunnel != nil {
message.Notef(lang.CmdToolsRegistryTunnel, registryEndpoint, zarfState.RegistryInfo.Address)
Expand All @@ -149,8 +149,8 @@ func zarfCraneCatalog(cranePlatformOptions []crane.Option) *cobra.Command {
}

// Wrap the original crane list with a zarf specific version
func zarfCraneInternalWrapper(commandToWrap func(*[]crane.Option) *cobra.Command, cranePlatformOptions []crane.Option, exampleText string, imageNameArgumentIndex int) *cobra.Command {
wrappedCommand := commandToWrap(&cranePlatformOptions)
func zarfCraneInternalWrapper(commandToWrap func(*[]crane.Option) *cobra.Command, cranePlatformOptions *[]crane.Option, exampleText string, imageNameArgumentIndex int) *cobra.Command {
wrappedCommand := commandToWrap(cranePlatformOptions)

wrappedCommand.Example = exampleText
wrappedCommand.Args = nil
Expand Down Expand Up @@ -190,7 +190,7 @@ func zarfCraneInternalWrapper(commandToWrap func(*[]crane.Option) *cobra.Command

// Add the correct authentication to the crane command options
authOption := images.WithPushAuth(zarfState.RegistryInfo)
cranePlatformOptions = append(cranePlatformOptions, authOption)
*cranePlatformOptions = append(*cranePlatformOptions, authOption)

if tunnel != nil {
message.Notef(lang.CmdToolsRegistryTunnel, tunnel.Endpoint(), zarfState.RegistryInfo.Address)
Expand Down

0 comments on commit a29c9d7

Please sign in to comment.