-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(environments): Preflight cli changes #246
Conversation
remove unnecessary attribute assignments
57d2358
to
f899587
Compare
…into preflight_cli_changes
can you add before and after exampled for each command? |
@@ -54,7 +53,7 @@ type Create struct { | |||
Type string `long:"type" usage:"environment type, when not specified"` | |||
Provider string `long:"provider" usage:"environment cloud provider to use"` | |||
Region string `long:"region" usage:"environment region"` | |||
Config []string `short:"c" long:"config" usage:"environment configuration based on type and provider (e.g.: --config aws_access_key_id=my_access_key --config aws_access_secret=my_access_secret)"` // nolint:lll | |||
Config []string `short:"c" long:"config" usage:"environment configuration based on type and provider (e.g.: --config aws_access_key_id=my_access_key --config aws_secret_access_key=my_access_secret)"` // nolint:lll |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm biased, but i think these changes are looking pretty good
Added! Let me know if we are good to merge this or anything else needs to be updated :) |
There seems to be an inconsistency in spacing I'd also prefer for the output of |
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend staying consistent between all operations. This is an operation code taken from create
that seems a little neater
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) | |
details := utils.EnvironmentPreflightTable(rr) | |
c.logger.Errorf(ctx, | |
"Environment %q could not be repaired because it failed the preflight checks\n%s\n", | |
environment.Name, | |
details) | |
environment.Name, | ||
details) | ||
} else { | ||
environment.Status.PreflightDetails = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary to clear out preflight check details. Customers might want to see this info in the --json command
environment.Status.PreflightDetails = nil |
} 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) | ||
} | ||
r.logger.Infof(ctx, `Run "meroxa env describe %s" for status.`, r.args.NameOrUUID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} 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) | |
} | |
r.logger.Infof(ctx, `Run "meroxa env describe %s" for status.`, r.args.NameOrUUID) | |
} else { | |
c.logger.Infof(ctx, | |
"Preflight checks have passed. Environment %q is being repaired. Run `meroxa env describe %s` for status", | |
environment.Name, | |
environment.Name) | |
} | |
text := fmt.Sprintf("Environment %q could not be updated.", c.args.NameOrUUID) | ||
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) | ||
|
||
} else { | ||
c.logger.Infof(ctx, "Environment %q has been updated. Run `meroxa env describe %s` for status", environment.Name, environment.Name) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text := fmt.Sprintf("Environment %q could not be updated.", c.args.NameOrUUID) | |
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) | |
} else { | |
c.logger.Infof(ctx, "Environment %q has been updated. Run `meroxa env describe %s` for status", environment.Name, environment.Name) | |
} | |
details := utils.EnvironmentPreflightTable(rr) | |
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, | |
"Preflight checks have passed. Environment %q is being updated. Run `meroxa env describe %s` for status", | |
environment.Name, | |
environment.Name) | |
} |
Description of change
We want to be able to see preflight check information on cli when creating an environment. On 'meroxa env describe' we will lis t full environment information with preflight checks. When creating an environment, we want to log to console if preflight check is successful or errored out.
Fixes #245
Type of change
How was this tested?
Demo
Before the Changes:
Creating bad environment with not enough permissions
Describing bad environment that failed to provision
After the Changes :
Creating bad environment with not enough permissions
Describing bad environment that failed to provision
Repairing environment after giving necessary permissions
Additional references
Documentation updated
N/A