Skip to content

Commit

Permalink
Cli desc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-cross committed Feb 9, 2022
1 parent b2e3a55 commit f1d2f2f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 37 deletions.
3 changes: 1 addition & 2 deletions cmd/meroxa/root/environments/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,13 @@ func (c *Create) Execute(ctx context.Context) error {
return err
}

if environment.Status.State == meroxa.EnvironmentStatePreflightError {
if environment.Status.State != meroxa.EnvironmentStatePreflightSuccess {
details := utils.EnvironmentPreflightTable(environment)
c.logger.Errorf(ctx,
"Environment %q could not be provisioned because it failed the preflight checks\n%s\n",
environment.Name,
details)
} else {
environment.Status.PreflightDetails = nil
c.logger.Infof(ctx,
"Preflight checks have passed. Environment %q is being provisioned. Run `meroxa env describe %s` for status",
environment.Name,
Expand Down
34 changes: 13 additions & 21 deletions cmd/meroxa/root/environments/repair.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package environments
import (
"context"
"errors"
"fmt"

"github.com/meroxa/cli/cmd/meroxa/builder"
"github.com/meroxa/cli/log"
Expand Down Expand Up @@ -78,31 +77,24 @@ func (r *Repair) ParseArgs(args []string) error {
}

func (r *Repair) Execute(ctx context.Context) error {
rr, err := r.client.PerformActionOnEnvironment(ctx, r.args.NameOrUUID, &meroxa.RepairEnvironmentInput{Action: meroxa.EnvironmentActionRepair}) // nolint:lll
environment, err := r.client.PerformActionOnEnvironment(ctx, r.args.NameOrUUID, &meroxa.RepairEnvironmentInput{Action: meroxa.EnvironmentActionRepair}) // nolint:lll
if err != nil {
return err
}

state := rr.Status.State
name := rr.Name
if state == meroxa.EnvironmentStatePreflightError {
text := fmt.Sprintf("Environment %q could not be repaired because it failed the preflight checks.", name)
details := utils.EnvironmentPreflightTable(rr)
text += fmt.Sprintf("\n%s\n", details)

r.logger.Errorf(ctx, text)
} else if state == meroxa.EnvironmentStateRepairing || state == meroxa.EnvironmentStatePreflightSuccess {
r.logger.Infof(ctx, `The repairment of your environment %q is now in progress and your environment will be up and running soon.`, r.args.NameOrUUID) // nolint:lll
} else if state == meroxa.EnvironmentStateRepairingError || state == meroxa.EnvironmentStateUpdatingError ||
state == meroxa.EnvironmentStateProvisioningError || state == meroxa.EnvironmentStateDeprovisioningError {
text := fmt.Sprintf("Environment %q could not be repaired.", r.args.NameOrUUID)
if details, err := utils.PrettyString(rr.Status.Details); err == nil {
text += fmt.Sprintf("\n%s\n", details)
}
r.logger.Infof(ctx, text)
if environment.Status.State != meroxa.EnvironmentStatePreflightSuccess {
details := utils.EnvironmentPreflightTable(environment)
r.logger.Errorf(ctx,
"Environment %q could not be repaired because it failed the preflight checks\n%s\n",
environment.Name,
details)
} else {
r.logger.Infof(ctx,
"Preflight checks have passed. Environment %q is being repaired. Run `meroxa env describe %s` for status",
environment.Name,
environment.Name)
}
r.logger.Infof(ctx, `Run "meroxa env describe %s" for status.`, r.args.NameOrUUID)
r.logger.JSON(ctx, rr)

r.logger.JSON(ctx, environment)
return nil
}
23 changes: 10 additions & 13 deletions cmd/meroxa/root/environments/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,20 @@ func (c *Update) Execute(ctx context.Context) error {
return err
}

state := environment.Status.State
if state == meroxa.EnvironmentStateUpdatingError {
text := fmt.Sprintf("Environment %q could not be updated.", c.args.NameOrUUID)
if environment.Status.State != meroxa.EnvironmentStatePreflightSuccess {
details := utils.EnvironmentPreflightTable(environment)
text += fmt.Sprintf("\n%s\n", details)
c.logger.Infof(ctx, text)
} else if state == meroxa.EnvironmentStatePreflightError {
text := fmt.Sprintf("Environment %q could not be updated because it failed the preflight checks.", c.args.NameOrUUID)
details := utils.EnvironmentPreflightTable(environment)
text += fmt.Sprintf("\n%s\n", details)
c.logger.Infof(ctx, text)

c.logger.Errorf(ctx,
"Environment %q could not be updated because it failed the preflight checks\n%s\n",
environment.Name,
details)
} else {
c.logger.Infof(ctx, "Environment %q has been updated. Run `meroxa env describe %s` for status", environment.Name, environment.Name)
c.logger.Infof(ctx,
"Preflight checks have passed. Environment %q is being updated. Run `meroxa env describe %s` for status",
environment.Name,
environment.Name)
}
c.logger.JSON(ctx, environment)

c.logger.JSON(ctx, environment)
return nil
}

Expand Down
1 change: 0 additions & 1 deletion utils/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,6 @@ func EnvironmentTable(environment *meroxa.Environment) string {
}

func EnvironmentPreflightTable(environment *meroxa.Environment) string {

if environment.Status.PreflightDetails != nil {
preflightTable := simpletable.New()
preflightTable.Body.Cells = [][]*simpletable.Cell{
Expand Down

0 comments on commit f1d2f2f

Please sign in to comment.