Skip to content

Commit

Permalink
fix: add release diff
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveRuble committed Oct 27, 2021
1 parent bba374b commit 26a6b52
Show file tree
Hide file tree
Showing 202 changed files with 342 additions and 255 deletions.
103 changes: 52 additions & 51 deletions cmd/deploy_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ var deployExecuteCmd = addCommand(deployCmd, &cobra.Command{
}

pathOrSlot := args[0]
switch pathOrSlot{
case "release","current", bosun.SlotStable, bosun.SlotUnstable:
switch pathOrSlot {
case "release", "current", bosun.SlotStable, bosun.SlotUnstable:
r, folder, resolveReleaseErr := getReleaseAndPlanFolderName(b, pathOrSlot)
if resolveReleaseErr != nil {
return resolveReleaseErr
Expand Down Expand Up @@ -92,7 +92,7 @@ var deployExecuteCmd = addCommand(deployCmd, &cobra.Command{

return err
},
},applyDeployExecuteCmdFlags)
}, applyDeployExecuteCmdFlags)

func applyDeployExecuteCmdFlags(cmd *cobra.Command) {
cmd.Flags().Bool(argDeployExecuteSkipValidate, false, "Skip validation")
Expand All @@ -105,70 +105,71 @@ const (
argDeployExecuteValuesOnly = "values-only"
)

var _ = addCommand(deployCmd, &cobra.Command{
var deployDiffCmd = addCommand(deployCmd, &cobra.Command{
Use: "diff {path | {release|stable|unstable}} [apps...]",
Args: cobra.MinimumNArgs(1),
Short: "Shows a diff of what would change if a deployment were executed",
Long: "If apps are provided, only those apps will be deployed.",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
b := MustGetBosun()
return diffDeploy(args[0], args[1:]...)
},
}, func(cmd *cobra.Command) {
cmd.Flags().Bool(argDeployExecuteValuesOnly, false, "Display the values which would be used for the deploy.")
})

check(b.ConfirmEnvironment())
func diffDeploy(pathOrSlot string, apps ...string) error {
b := MustGetBosun()

p, err := b.GetCurrentPlatform()
if err != nil {
return err
}
req := bosun.ExecuteDeploymentPlanRequest{
Validate: false,
DiffOnly: true,
DumpValuesOnly: viper.GetBool(argDeployExecuteValuesOnly),
UseSudo: viper.GetBool(ArgGlobalSudo),
}
check(b.ConfirmEnvironment())

pathOrSlot := args[0]
switch pathOrSlot{
case "release","current", bosun.SlotStable, bosun.SlotUnstable:
r, folder, resolveReleaseErr := getReleaseAndPlanFolderName(b, pathOrSlot)
if resolveReleaseErr != nil {
return resolveReleaseErr
}
expectedReleaseHash, hashErr := r.GetChangeDetectionHash()
p, err := b.GetCurrentPlatform()
if err != nil {
return err
}
req := bosun.ExecuteDeploymentPlanRequest{
Validate: false,
DiffOnly: true,
DumpValuesOnly: viper.GetBool(argDeployExecuteValuesOnly),
UseSudo: viper.GetBool(ArgGlobalSudo),
}

switch pathOrSlot {
case "release", "current", bosun.SlotStable, bosun.SlotUnstable:
r, folder, resolveReleaseErr := getReleaseAndPlanFolderName(b, pathOrSlot)
if resolveReleaseErr != nil {
return resolveReleaseErr
}
expectedReleaseHash, hashErr := r.GetChangeDetectionHash()

if hashErr != nil {
return hashErr
}
if hashErr != nil {
return hashErr
}

req.Path = filepath.Join(p.GetDeploymentsDir(), fmt.Sprintf("%s/plan.yaml", folder))
req.Plan, resolveReleaseErr = bosun.LoadDeploymentPlanFromFile(req.Path)
if resolveReleaseErr != nil {
return resolveReleaseErr
}
req.Path = filepath.Join(p.GetDeploymentsDir(), fmt.Sprintf("%s/plan.yaml", folder))
req.Plan, resolveReleaseErr = bosun.LoadDeploymentPlanFromFile(req.Path)
if resolveReleaseErr != nil {
return resolveReleaseErr
}

if req.Plan.BasedOnHash != "" && req.Plan.BasedOnHash != expectedReleaseHash {
confirmed := cli.RequestConfirmFromUser("The release has changed since this plan was created, are you sure you want to continue?")
if !confirmed {
if req.Plan.BasedOnHash != "" && req.Plan.BasedOnHash != expectedReleaseHash {
confirmed := cli.RequestConfirmFromUser("The release has changed since this plan was created, are you sure you want to continue?")
if !confirmed {

color.Yellow("You may want to run `bosun deploy plan release` to update the deployment plan\n")
return nil
}
color.Yellow("You may want to run `bosun deploy plan release` to update the deployment plan\n")
return nil
}
break
default:
req.Path = pathOrSlot
}
break
default:
req.Path = pathOrSlot
}

if len(args) > 1 {
req.IncludeApps = args[1:]
}
req.IncludeApps = apps

executor := bosun.NewDeploymentPlanExecutor(b, p)
executor := bosun.NewDeploymentPlanExecutor(b, p)

_, err = executor.Execute(req)
_, err = executor.Execute(req)

return err
},
}, func(cmd *cobra.Command) {
cmd.Flags().Bool(argDeployExecuteValuesOnly, false, "Display the values which would be used for the deploy.")
})
return err
}
7 changes: 7 additions & 0 deletions cmd/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ var _ = addCommand(releaseDeployCmd, &cobra.Command{
return deployShowCmd.RunE(cmd, []string{"release"})
},
})
var _ = addCommand(releaseDeployCmd, &cobra.Command{
Use: "diff [apps...]",
Short: "Shows the changes that will be inflicted when the deploy is executed",
RunE: func(cmd *cobra.Command, args []string) error {
return deployDiffCmd.RunE(cmd, append([]string{"release"}, args...))
},
})

var _ = addCommand(releaseDeployCmd, &cobra.Command{
Use: "execute [apps...]",
Expand Down
2 changes: 1 addition & 1 deletion docs/bosun.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ building, deploying, or monitoring apps you may want to add them to this tool.
* [bosun vault](bosun_vault.md) - Contains vault-related commands.
* [bosun workspace](bosun_workspace.md) - Workspace commands configure and manipulate the bindings between app repos and your local machine.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ App commands
* [bosun app values](bosun_app_values.md) - Outputs the values the app would use to deploy to the current target.
* [bosun app version](bosun_app_version.md) - Outputs the version of an app.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_accept-actual.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app accept-actual [name...] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app action [app] {name} [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_add-hosts.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ bosun apps add-hosts --all | sudo tee /etc/hosts

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_build-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ bosun app build-image [app] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_bump.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ bosun app bump {name} [major|minor|patch|major.minor.patch] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ bosun app change-log {app} {from} [to] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_clone.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ bosun app clone [name] [name...] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ bosun app delete [name] [name...] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ bosun app deploy [name] [name...] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_import.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app import [file] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_list-repos.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app list-repos [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_list-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app list-versions [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ bosun app list [flags]
* [bosun app](bosun_app.md) - App commands
* [bosun app list actions](bosun_app_list_actions.md) - Lists the actions for an app. If no app is provided, lists all actions.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_list_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app list actions [app] [flags]

* [bosun app list](bosun_app_list.md) - Lists the static config of all known apps.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_mutate.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Collects operations for updating app config files.
* [bosun app mutate foreach](bosun_app_mutate_foreach.md) - Runs a command for each matched app.
* [bosun app mutate label](bosun_app_mutate_label.md) - Adds labels to one or more apps.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_mutate_foreach.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app mutate foreach {[app apps...] | --include {filter}} -- {command} [args

* [bosun app mutate](bosun_app_mutate.md) - Collects operations for updating app config files.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_mutate_label.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app mutate label {app} [apps...] {label=value} [label=value...] [flags]

* [bosun app mutate](bosun_app_mutate.md) - Collects operations for updating app config files.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_publish-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app publish-chart [app] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_publish-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ bosun app publish-image [app] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_pull.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ bosun app pull [app] [app...] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_recycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ bosun app recycle [name] [name...] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_remove-hosts.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app remove-hosts [name...] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_repo-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app repo-path [name] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app run [app] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_script.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ bosun app script [app] {name} [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app scripts [app] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ bosun app status [name...] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_toggle.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ bosun app toggle [name] [name...] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_values.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app values [name] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_app_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ bosun app version [name] [flags]

* [bosun app](bosun_app.md) - App commands

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_chores.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Commands for automating tiresome tasks, like migrating bosun files.
* [bosun chores move-app-to-chart](bosun_chores_move-app-to-chart.md) - Moves the app config for an app into the folder containing the chart for the app.
* [bosun chores parse-xids](bosun_chores_parse-xids.md) - Takes text containing XIDs (or reads from stdin) and echos with any XIDs parsed.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_chores_import-descendents.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ bosun chores import-descendents {into-file} {pattern} [anti-pattern] [flags]

* [bosun chores](bosun_chores.md) - Commands for automating tiresome tasks, like migrating bosun files.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_chores_migrate-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ bosun chores migrate-files {files...} [flags]

* [bosun chores](bosun_chores.md) - Commands for automating tiresome tasks, like migrating bosun files.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_chores_move-app-to-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ bosun chores move-app-to-chart {app} [flags]

* [bosun chores](bosun_chores.md) - Commands for automating tiresome tasks, like migrating bosun files.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_chores_parse-xids.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ bosun chores parse-xids [xids...] [flags]

* [bosun chores](bosun_chores.md) - Commands for automating tiresome tasks, like migrating bosun files.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ Commands for interacting with clusters.
* [bosun cluster configure](bosun_cluster_configure.md) - Configures the specified cluster, or the current cluster if none specified
* [bosun cluster list](bosun_cluster_list.md) - Lists all cluster definitions.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_cluster_configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ bosun cluster configure [name] [flags]

* [bosun cluster](bosun_cluster.md) - Commands for interacting with clusters.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_cluster_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ bosun cluster list [flags]

* [bosun cluster](bosun_cluster.md) - Commands for interacting with clusters.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
2 changes: 1 addition & 1 deletion docs/bosun_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ Contains commands for planning and executing a deploy.
* [bosun deploy show](bosun_deploy_show.md) - Show the deployment plan and its progress.
* [bosun deploy validate](bosun_deploy_validate.md) - Validates a deployment plan.

###### Auto generated by spf13/cobra on 23-Sep-2021
###### Auto generated by spf13/cobra on 27-Oct-2021
Loading

0 comments on commit 26a6b52

Please sign in to comment.