Skip to content

Commit

Permalink
fix(COD-1559): Failures in Lacework CLI update checking (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
linpengzhang authored Sep 12, 2023
1 parent e65e720 commit 29dc321
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cli/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ versions available for update.
Set the environment variable 'LW_UPDATES_DISABLE=1' to avoid checking for updates.`,
Args: cobra.NoArgs,
Run: func(_ *cobra.Command, _ []string) {
componentVerionsOutput := &strings.Builder{}
componentVersionsOutput := &strings.Builder{}
if cli.LwComponents != nil {
for _, component := range cli.LwComponents.Components {
if component.IsInstalled() {
v, err := component.CurrentVersion()
if err == nil {
componentVerionsOutput.WriteString(
componentVersionsOutput.WriteString(
fmt.Sprintf(" > %s v%s\n", component.Name, v.String()),
)
continue
Expand All @@ -86,7 +86,7 @@ Set the environment variable 'LW_UPDATES_DISABLE=1' to avoid checking for update
BuildTime: BuildTime,
}

if componentVerionsOutput.String() != "" {
if componentVersionsOutput.String() != "" {
vJSON.CDK = cli.LwComponents
}

Expand All @@ -95,13 +95,14 @@ Set the environment variable 'LW_UPDATES_DISABLE=1' to avoid checking for update
}

cli.OutputHuman("lacework v%s (sha:%s) (time:%s)\n", Version, GitSHA, BuildTime)
if componentVerionsOutput.String() != "" {
cli.OutputHuman("\nComponents:\n\n%s", componentVerionsOutput.String())
if componentVersionsOutput.String() != "" {
cli.OutputHuman("\nComponents:\n\n%s", componentVersionsOutput.String())
}

// check the latest version of the cli
if _, err := versionCheck(); err != nil {
exitwithCode(err, 4)
cli.Log.Errorw("unable to perform lacework cli version check",
"error", err.Error())
}
},
}
Expand Down

0 comments on commit 29dc321

Please sign in to comment.