Skip to content

Commit

Permalink
only create tunnel with internal registry
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman committed Jun 26, 2023
1 parent 6254072 commit f7c3f0e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/cmd/tools/crane.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,27 @@ func zarfCraneList(cranePlatformOptions *[]crane.Option) *cobra.Command {
return originalListFn(cmd, args)
}

// Open a tunnel to the Zarf registry
tunnelReg, err := cluster.NewZarfTunnel()
if err != nil {
return err
}
err = tunnelReg.Connect(cluster.ZarfRegistry, false)
if err != nil {
return err
if zarfState.RegistryInfo.InternalRegistry {
// Open a tunnel to the Zarf registry
tunnelReg, err := cluster.NewZarfTunnel()
if err != nil {
return err
}
err = tunnelReg.Connect(cluster.ZarfRegistry, false)
if err != nil {
return err
}

givenAddress := fmt.Sprintf("%s/", zarfState.RegistryInfo.Address)
tunnelAddress := fmt.Sprintf("%s/", tunnelReg.Endpoint())
args[0] = strings.Replace(args[0], givenAddress, tunnelAddress, 1)
}

// Add the correct authentication to the crane command options
authOption := config.GetCraneAuthOption(zarfState.RegistryInfo.PullUsername, zarfState.RegistryInfo.PullPassword)
*cranePlatformOptions = append(*cranePlatformOptions, authOption)
registryEndpoint := tunnelReg.Endpoint()

return originalListFn(cmd, []string{strings.Replace(args[0],
fmt.Sprintf("%s/", zarfState.RegistryInfo.Address), fmt.Sprintf("%s/", registryEndpoint), 1)})
return originalListFn(cmd, args)
}

return craneList
Expand Down

0 comments on commit f7c3f0e

Please sign in to comment.