forked from toolshed/abra
.
This commit is contained in:
parent
51ea98a910
commit
154a95ac5b
@ -180,9 +180,10 @@ checkout as-is. Recipe commit hashes are also supported as values for
|
|||||||
|
|
||||||
if err := internal.DeployOverview(
|
if err := internal.DeployOverview(
|
||||||
app,
|
app,
|
||||||
deployWarnMessages,
|
|
||||||
deployedVersion,
|
deployedVersion,
|
||||||
toDeployVersion,
|
toDeployVersion,
|
||||||
|
"",
|
||||||
|
deployWarnMessages,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -64,11 +64,12 @@ Passing "--prune/-p" does not remove those volumes.`,
|
|||||||
toWriteVersion = chaosVersion
|
toWriteVersion = chaosVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := internal.UndeployOverview(
|
if err := internal.DeployOverview(
|
||||||
app,
|
app,
|
||||||
deployMeta.Version,
|
deployMeta.Version,
|
||||||
chaosVersion,
|
config.NO_DOMAIN_DEFAULT,
|
||||||
toWriteVersion,
|
"",
|
||||||
|
nil,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,8 @@ beforehand. See "abra app backup" for more.`,
|
|||||||
ValidArgsFunction: func(
|
ValidArgsFunction: func(
|
||||||
cmd *cobra.Command,
|
cmd *cobra.Command,
|
||||||
args []string,
|
args []string,
|
||||||
toComplete string) ([]string, cobra.ShellCompDirective) {
|
toComplete string,
|
||||||
|
) ([]string, cobra.ShellCompDirective) {
|
||||||
switch l := len(args); l {
|
switch l := len(args); l {
|
||||||
case 0:
|
case 0:
|
||||||
return autocomplete.AppNameComplete()
|
return autocomplete.AppNameComplete()
|
||||||
@ -206,23 +207,21 @@ beforehand. See "abra app backup" for more.`,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
chaosVersion := config.CHAOS_DEFAULT
|
if upgradeReleaseNotes != "" && chosenUpgrade != "" {
|
||||||
if deployMeta.IsChaos {
|
fmt.Print(upgradeReleaseNotes)
|
||||||
chaosVersion = deployMeta.ChaosVersion
|
} else {
|
||||||
|
upgradeWarnMessages = append(
|
||||||
if deployMeta.ChaosVersion == "" {
|
upgradeWarnMessages,
|
||||||
chaosVersion = config.UNKNOWN_DEFAULT
|
fmt.Sprintf("no release notes available for %s", chosenUpgrade),
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := internal.NewVersionOverview(
|
if err := internal.DeployOverview(
|
||||||
app,
|
app,
|
||||||
upgradeWarnMessages,
|
|
||||||
"upgrade",
|
|
||||||
deployMeta.Version,
|
deployMeta.Version,
|
||||||
chaosVersion,
|
|
||||||
chosenUpgrade,
|
chosenUpgrade,
|
||||||
upgradeReleaseNotes,
|
upgradeReleaseNotes,
|
||||||
|
upgradeWarnMessages,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -397,9 +396,7 @@ func ensureDeployed(cl *dockerClient.Client, app app.App) (stack.DeployMeta, err
|
|||||||
return deployMeta, nil
|
return deployMeta, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var showReleaseNotes bool
|
||||||
showReleaseNotes bool
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
AppUpgradeCommand.Flags().BoolVarP(
|
AppUpgradeCommand.Flags().BoolVarP(
|
||||||
|
@ -45,7 +45,8 @@ func NewVersionOverview(
|
|||||||
deployedVersion,
|
deployedVersion,
|
||||||
deployedChaosVersion,
|
deployedChaosVersion,
|
||||||
toDeployVersion,
|
toDeployVersion,
|
||||||
releaseNotes string) error {
|
releaseNotes string,
|
||||||
|
) error {
|
||||||
deployConfig := "compose.yml"
|
deployConfig := "compose.yml"
|
||||||
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
||||||
deployConfig = formatComposeFiles(composeFiles)
|
deployConfig = formatComposeFiles(composeFiles)
|
||||||
@ -76,7 +77,6 @@ func NewVersionOverview(
|
|||||||
|
|
||||||
{"CURRENT DEPLOYMENT", "---"},
|
{"CURRENT DEPLOYMENT", "---"},
|
||||||
{"VERSION", formatter.BoldDirtyDefault(deployedVersion)},
|
{"VERSION", formatter.BoldDirtyDefault(deployedVersion)},
|
||||||
{"CHAOS ", formatter.BoldDirtyDefault(deployedChaosVersion)},
|
|
||||||
|
|
||||||
{upperKind, "---"},
|
{upperKind, "---"},
|
||||||
{"VERSION", formatter.BoldDirtyDefault(toDeployVersion)},
|
{"VERSION", formatter.BoldDirtyDefault(toDeployVersion)},
|
||||||
@ -130,9 +130,10 @@ func formatComposeFiles(composeFiles string) string {
|
|||||||
// DeployOverview shows a deployment overview
|
// DeployOverview shows a deployment overview
|
||||||
func DeployOverview(
|
func DeployOverview(
|
||||||
app appPkg.App,
|
app appPkg.App,
|
||||||
warnMessages []string,
|
|
||||||
deployedVersion string,
|
deployedVersion string,
|
||||||
toDeployVersion string,
|
toDeployVersion string,
|
||||||
|
info string,
|
||||||
|
warnMessages []string,
|
||||||
) error {
|
) error {
|
||||||
deployConfig := "compose.yml"
|
deployConfig := "compose.yml"
|
||||||
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
||||||
@ -163,17 +164,22 @@ func DeployOverview(
|
|||||||
{"CURRENT DEPLOYMENT", "---"},
|
{"CURRENT DEPLOYMENT", "---"},
|
||||||
{"VERSION", formatter.BoldDirtyDefault(deployedVersion)},
|
{"VERSION", formatter.BoldDirtyDefault(deployedVersion)},
|
||||||
|
|
||||||
{"CURRENT ENV VERSION", "---"},
|
{"ENV VERSION", "---"},
|
||||||
{"ENV VERSION", formatter.BoldDirtyDefault(envVersion)},
|
{"ENV VERSION", formatter.BoldDirtyDefault(envVersion)},
|
||||||
|
|
||||||
{"NEW DEPLOYMENT", "---"},
|
{"NEW DEPLOYMENT", "---"},
|
||||||
{"VERSION", formatter.BoldDirtyDefault(toDeployVersion)},
|
{"VERSION", formatter.BoldDirtyDefault(toDeployVersion)},
|
||||||
}
|
}
|
||||||
|
|
||||||
overview := formatter.CreateOverview("DEPLOY OVERVIEW", rows)
|
deployType := getDeployType(deployedVersion, toDeployVersion)
|
||||||
|
overview := formatter.CreateOverview(fmt.Sprintf("%s OVERVIEW", deployType), rows)
|
||||||
|
|
||||||
fmt.Println(overview)
|
fmt.Println(overview)
|
||||||
|
|
||||||
|
if info != "" {
|
||||||
|
fmt.Println(info)
|
||||||
|
}
|
||||||
|
|
||||||
for _, msg := range warnMessages {
|
for _, msg := range warnMessages {
|
||||||
log.Warn(msg)
|
log.Warn(msg)
|
||||||
}
|
}
|
||||||
@ -195,67 +201,31 @@ func DeployOverview(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UndeployOverview shows an undeployment overview
|
func getDeployType(currentVersion, newVersion string) string {
|
||||||
func UndeployOverview(
|
if currentVersion == newVersion {
|
||||||
app appPkg.App,
|
return "RE-DEPLOY"
|
||||||
deployedVersion,
|
|
||||||
deployedChaosVersion,
|
|
||||||
toWriteVersion string,
|
|
||||||
) error {
|
|
||||||
deployConfig := "compose.yml"
|
|
||||||
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
|
||||||
deployConfig = formatComposeFiles(composeFiles)
|
|
||||||
}
|
}
|
||||||
|
if currentVersion == config.NO_VERSION_DEFAULT {
|
||||||
server := app.Server
|
return "NEW DEPLOY"
|
||||||
if app.Server == "default" {
|
|
||||||
server = "local"
|
|
||||||
}
|
}
|
||||||
|
if strings.Contains(newVersion, "+U") {
|
||||||
domain := app.Domain
|
return "CHAOS DEPLOY"
|
||||||
if domain == "" {
|
|
||||||
domain = config.NO_DOMAIN_DEFAULT
|
|
||||||
}
|
}
|
||||||
|
if strings.Contains(currentVersion, "+U") {
|
||||||
envVersion := app.Recipe.EnvVersionRaw
|
return "UNCHAOS DEPLOY"
|
||||||
if envVersion == "" {
|
|
||||||
envVersion = config.NO_VERSION_DEFAULT
|
|
||||||
}
|
}
|
||||||
|
currentParsed, err := tagcmp.Parse(currentVersion)
|
||||||
rows := [][]string{
|
if err != nil {
|
||||||
{"DOMAIN", domain},
|
return "DEPLOY"
|
||||||
{"RECIPE", app.Recipe.Name},
|
|
||||||
{"SERVER", server},
|
|
||||||
{"CONFIG", deployConfig},
|
|
||||||
|
|
||||||
{"CURRENT DEPLOYMENT", "---"},
|
|
||||||
{"VERSION", formatter.BoldDirtyDefault(deployedVersion)},
|
|
||||||
{"CHAOS", formatter.BoldDirtyDefault(deployedChaosVersion)},
|
|
||||||
|
|
||||||
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Name)), "---"},
|
|
||||||
{"CURRENT VERSION", formatter.BoldDirtyDefault(envVersion)},
|
|
||||||
{"NEW VERSION", formatter.BoldDirtyDefault(toWriteVersion)},
|
|
||||||
}
|
}
|
||||||
|
newParsed, err := tagcmp.Parse(newVersion)
|
||||||
overview := formatter.CreateOverview("UNDEPLOY OVERVIEW", rows)
|
if err != nil {
|
||||||
|
return "DEPLOY"
|
||||||
fmt.Println(overview)
|
|
||||||
|
|
||||||
if NoInput {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
if currentParsed.IsLessThan(newParsed) {
|
||||||
response := false
|
return "UPGRADE"
|
||||||
prompt := &survey.Confirm{Message: "proceed?"}
|
|
||||||
if err := survey.AskOne(prompt, &response); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
return "DOWNGRADE"
|
||||||
if !response {
|
|
||||||
log.Fatal("undeploy cancelled")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostCmds parses a string of commands and executes them inside of the respective services
|
// PostCmds parses a string of commands and executes them inside of the respective services
|
||||||
|
Loading…
x
Reference in New Issue
Block a user