Skip to content

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
abiosoft authored Nov 23, 2024
1 parent fbc6f93 commit 4a0f25c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ type statusInfo struct {
Disk int64 `json:"disk"`
}

func (c colimaApp) getStatus() (*status, error) {
func (c colimaApp) getStatus() (status statusInfo, err error) {

Check failure on line 309 in app/app.go

View workflow job for this annotation

GitHub Actions / lint

other declaration of status (typecheck)

Check failure on line 309 in app/app.go

View workflow job for this annotation

GitHub Actions / lint

other declaration of status) (typecheck)

Check failure on line 309 in app/app.go

View workflow job for this annotation

GitHub Actions / containerd

other declaration of status

Check failure on line 309 in app/app.go

View workflow job for this annotation

GitHub Actions / docker

other declaration of status

Check failure on line 309 in app/app.go

View workflow job for this annotation

GitHub Actions / build-macos

other declaration of status

Check failure on line 309 in app/app.go

View workflow job for this annotation

GitHub Actions / incus

other declaration of status

Check failure on line 309 in app/app.go

View workflow job for this annotation

GitHub Actions / build-linux

other declaration of status

Check failure on line 309 in app/app.go

View workflow job for this annotation

GitHub Actions / kubernetes-containerd

other declaration of status

Check failure on line 309 in app/app.go

View workflow job for this annotation

GitHub Actions / kubernetes-docker

other declaration of status
ctx := context.Background()
if !c.guest.Running(ctx) {
return nil, fmt.Errorf("%s is not running", config.CurrentProfile().DisplayName)
return status, fmt.Errorf("%s is not running", config.CurrentProfile().DisplayName)
}

currentRuntime, err := c.currentRuntime(ctx)
if err != nil {
return nil, err
return status, err
}

var status statusInfo

Check failure on line 320 in app/app.go

View workflow job for this annotation

GitHub Actions / lint

status redeclared in this block

Check failure on line 320 in app/app.go

View workflow job for this annotation

GitHub Actions / lint

status redeclared in this block

Check failure on line 320 in app/app.go

View workflow job for this annotation

GitHub Actions / containerd

status redeclared in this block

Check failure on line 320 in app/app.go

View workflow job for this annotation

GitHub Actions / docker

status redeclared in this block

Check failure on line 320 in app/app.go

View workflow job for this annotation

GitHub Actions / build-macos

status redeclared in this block

Check failure on line 320 in app/app.go

View workflow job for this annotation

GitHub Actions / incus

status redeclared in this block

Check failure on line 320 in app/app.go

View workflow job for this annotation

GitHub Actions / build-linux

status redeclared in this block

Check failure on line 320 in app/app.go

View workflow job for this annotation

GitHub Actions / kubernetes-containerd

status redeclared in this block

Check failure on line 320 in app/app.go

View workflow job for this annotation

GitHub Actions / kubernetes-docker

status redeclared in this block
Expand Down Expand Up @@ -342,7 +342,7 @@ func (c colimaApp) getStatus() (*status, error) {
status.Memory = inst.Memory
status.Disk = inst.Disk
}
return &status, nil
return status, nil
}

func (c colimaApp) Status(extended bool, jsonOutput bool) error {
Expand All @@ -352,8 +352,9 @@ func (c colimaApp) Status(extended bool, jsonOutput bool) error {
}

if jsonOutput {
b, _ := json.Marshal(status)
fmt.Println(string(b))
if err := json.NewEncoder(os.Stdout).Encode(status); err != nil {
return fmt.Errorf("error encoding status as json: %w", err)
}
} else {

log.Println(config.CurrentProfile().DisplayName, "is running using", status.Driver)
Expand Down

0 comments on commit 4a0f25c

Please sign in to comment.