Skip to content

Commit

Permalink
feat: implement new logger for Zarf connect (#3208)
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 authored Nov 7, 2024
1 parent 4a2ef14 commit bc9b634
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/zarf-dev/zarf/src/config/lang"
"github.com/zarf-dev/zarf/src/pkg/cluster"
"github.com/zarf-dev/zarf/src/pkg/logger"
"github.com/zarf-dev/zarf/src/pkg/message"
"github.com/zarf-dev/zarf/src/pkg/utils/exec"
)
Expand All @@ -25,6 +26,8 @@ var connectCmd = &cobra.Command{
Short: lang.CmdConnectShort,
Long: lang.CmdConnectLong,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
l := logger.From(ctx)
target := ""
if len(args) > 0 {
target = args[0]
Expand All @@ -38,8 +41,6 @@ var connectCmd = &cobra.Command{
return err
}

ctx := cmd.Context()

var tunnel *cluster.Tunnel
if target == "" {
tunnel, err = c.ConnectTunnelInfo(ctx, zt)
Expand All @@ -61,14 +62,12 @@ var connectCmd = &cobra.Command{

defer tunnel.Close()

// Dump the tunnel URL to the console for other tools to use.
fmt.Print(tunnel.FullURL())

if cliOnly {
spinner.Updatef(lang.CmdConnectEstablishedCLI, tunnel.FullURL())
l.Info("Tunnel established, waiting for user to interrupt (ctrl-c to end)", "url", tunnel.FullURL())
} else {
spinner.Updatef(lang.CmdConnectEstablishedWeb, tunnel.FullURL())

l.Info("Tunnel established, opening your default web browser (ctrl-c to end)", "url", tunnel.FullURL())
if err := exec.LaunchURL(tunnel.FullURL()); err != nil {
return err
}
Expand Down Expand Up @@ -98,6 +97,9 @@ var connectListCmd = &cobra.Command{
if err != nil {
return err
}
// HACK: Re-initializing PTerm with a stderr writer isn't great, but it lets us render these
// tables for backwards compatibility
message.InitializePTerm(logger.DestinationDefault)
message.PrintConnectStringTable(connections)
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/packager/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (p *Packager) findImages(ctx context.Context) (map[string][]string, error)
for idx, k := range manifest.Kustomizations {
// Generate manifests from kustomizations and place in the package
kname := fmt.Sprintf("kustomization-%s-%d.yaml", manifest.Name, idx)
// Use the temp folder because if "helpers.CreatePathAndCopy" is provider with the same path it will result in the file being empty
// Use the temp folder because if "helpers.CreatePathAndCopy" is provided with the same path it will result in the file being empty
destination := filepath.Join(componentPaths.Temp, kname)
if err := kustomize.Build(k, destination, manifest.KustomizeAllowAnyDirectory); err != nil {
return nil, fmt.Errorf("unable to build the kustomization for %s: %w", k, err)
Expand Down

0 comments on commit bc9b634

Please sign in to comment.