Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit c2a182d

Browse files
committed
fixup! Migrate more logs to clog
1 parent 540a957 commit c2a182d

File tree

8 files changed

+17
-14
lines changed

8 files changed

+17
-14
lines changed

internal/clog/error.go

+3
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,6 @@ func Hint(format string, a ...interface{}) string {
131131
func Cause(format string, a ...interface{}) string {
132132
return fmt.Sprintf("%s %s", Bold("cause:"), fmt.Sprintf(format, a...))
133133
}
134+
135+
// BlankLine is an empty string meant to be used in CLIMessage and CLIError construction.
136+
const BlankLine = ""

internal/cmd/ceapi.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func findEnv(ctx context.Context, client *coder.Client, envName, userEmail strin
7777
return nil, clog.Fatal(
7878
"failed to find environment",
7979
fmt.Sprintf("environment %q not found in %q", envName, found),
80-
"",
80+
clog.BlankLine,
8181
clog.Tip("run \"coder envs ls\" to view your environments"),
8282
)
8383
}

internal/cmd/envs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ coder envs --user charlie@coder.com ls -o json \
107107
if err = client.StopEnvironment(cmd.Context(), env.ID); err != nil {
108108
atomic.AddInt32(&fails, 1)
109109
err = clog.Fatal(fmt.Sprintf("stop environment %q", env.Name),
110-
clog.Cause(err.Error()), "",
110+
clog.Cause(err.Error()), clog.BlankLine,
111111
clog.Hint("current environment status is %q", env.LatestStat.ContainerStatus),
112112
)
113113
clog.Log(err)

internal/cmd/rebuild.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"time"
99

1010
"cdr.dev/coder-cli/coder-sdk"
11+
"cdr.dev/coder-cli/internal/clog"
1112
"github.com/briandowns/spinner"
1213
"github.com/fatih/color"
1314
"github.com/manifoldco/promptui"
1415
"github.com/spf13/cobra"
15-
"go.coder.com/flog"
1616
"golang.org/x/crypto/ssh/terminal"
1717
"golang.org/x/xerrors"
1818
)
@@ -56,7 +56,10 @@ coder envs rebuild backend-env --force`,
5656
return err
5757
}
5858
} else {
59-
flog.Info("Use \"coder envs watch-build %s\" to follow the build logs", env.Name)
59+
clog.LogSuccess(
60+
"successfully started rebuild",
61+
clog.Tip("run \"coder envs watch-build %s\" to follow the build logs", env.Name),
62+
)
6063
}
6164
return nil
6265
},

internal/cmd/secrets.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import (
1212
"cdr.dev/coder-cli/coder-sdk"
1313
"cdr.dev/coder-cli/internal/clog"
1414
"cdr.dev/coder-cli/internal/x/xtabwriter"
15-
16-
"go.coder.com/flog"
1715
)
1816

1917
func makeSecretsCmd() *cobra.Command {
@@ -155,7 +153,7 @@ func listSecrets(userEmail *string) func(cmd *cobra.Command, _ []string) error {
155153
}
156154

157155
if len(secrets) < 1 {
158-
flog.Info("No secrets found")
156+
clog.LogInfo("no secrets found")
159157
return nil
160158
}
161159

internal/cmd/shell.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func networkErr(client *coder.Client, env *coder.Environment) error {
202202
"environment is not running",
203203
fmt.Sprintf("environment %q is not running", env.Name),
204204
fmt.Sprintf("its current status is %q", env.LatestStat.ContainerStatus),
205-
"",
205+
clog.BlankLine,
206206
clog.Tip("run \"coder envs rebuild %s --follow\" to start the environment", env.Name),
207207
)
208208
}

internal/cmd/sync.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import (
99
"strings"
1010

1111
"cdr.dev/coder-cli/coder-sdk"
12+
"cdr.dev/coder-cli/internal/clog"
1213
"cdr.dev/coder-cli/internal/sync"
1314
"github.com/spf13/cobra"
1415
"golang.org/x/xerrors"
15-
16-
"go.coder.com/flog"
1716
)
1817

1918
func makeSyncCmd() *cobra.Command {
@@ -96,7 +95,7 @@ func makeRunSync(init *bool) func(cmd *cobra.Command, args []string) error {
9695
remoteVersion, rsyncErr := s.Version()
9796

9897
if rsyncErr != nil {
99-
flog.Info("Unable to determine remote rsync version. Proceeding cautiously.")
98+
clog.LogInfo("unable to determine remote rsync version: proceeding cautiously")
10099
} else if localVersion != remoteVersion {
101100
return xerrors.Errorf("rsync protocol mismatch: local = %s, remote = %s", localVersion, remoteVersion)
102101
}

internal/cmd/urls.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func makeListDevURLs(outputFmt *string) func(cmd *cobra.Command, args []string)
102102
switch *outputFmt {
103103
case "human":
104104
if len(devURLs) < 1 {
105-
flog.Info("No devURLs found for environment %q", envName)
105+
clog.LogInfo(fmt.Sprintf("no devURLs found for environment %q", envName))
106106
return nil
107107
}
108108
err := xtabwriter.WriteTable(len(devURLs), func(i int) interface{} {
@@ -169,13 +169,13 @@ func makeCreateDevURL() *cobra.Command {
169169

170170
urlID, found := devURLID(portNum, urls)
171171
if found {
172-
flog.Info("Updating devurl for port %v", port)
172+
clog.LogInfo(fmt.Sprintf("updating devurl for port %v", port))
173173
err := client.UpdateDevURL(cmd.Context(), env.ID, urlID, portNum, urlname, access)
174174
if err != nil {
175175
return xerrors.Errorf("update DevURL: %w", err)
176176
}
177177
} else {
178-
flog.Info("Adding devurl for port %v", port)
178+
clog.LogInfo(fmt.Sprintf("Adding devurl for port %v", port))
179179
err := client.InsertDevURL(cmd.Context(), env.ID, portNum, urlname, access)
180180
if err != nil {
181181
return xerrors.Errorf("insert DevURL: %w", err)

0 commit comments

Comments
 (0)