forked from toolshed/abra
		
	feat: add --show-unchanged/-U option
This commit is contained in:
		| @ -196,13 +196,13 @@ checkout as-is. Recipe commit hashes are also supported as values for | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Gather configs | 		// Gather configs | ||||||
| 		configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env) | 		configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env, internal.ShowUnchanged) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatal(err) | 			log.Fatal(err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Gather images | 		// Gather images | ||||||
| 		imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose) | 		imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose, internal.ShowUnchanged) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatal(err) | 			log.Fatal(err) | ||||||
| 		} | 		} | ||||||
| @ -393,4 +393,12 @@ func init() { | |||||||
| 		false, | 		false, | ||||||
| 		i18n.G("deploy latest recipe version"), | 		i18n.G("deploy latest recipe version"), | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
|  | 	AppDeployCommand.Flags().BoolVarP( | ||||||
|  | 		&internal.ShowUnchanged, | ||||||
|  | 		i18n.G("show-unchanged"), | ||||||
|  | 		i18n.G("U"), | ||||||
|  | 		false, | ||||||
|  | 		i18n.G("show all configs & images, including unchanged ones"), | ||||||
|  | 	) | ||||||
| } | } | ||||||
|  | |||||||
| @ -192,13 +192,13 @@ beforehand. See "abra app backup" for more.`), | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Gather configs | 		// Gather configs | ||||||
| 		configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env) | 		configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env, internal.ShowUnchanged) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatal(err) | 			log.Fatal(err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Gather images | 		// Gather images | ||||||
| 		imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose) | 		imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose, internal.ShowUnchanged) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatal(err) | 			log.Fatal(err) | ||||||
| 		} | 		} | ||||||
| @ -362,4 +362,12 @@ func init() { | |||||||
| 		false, | 		false, | ||||||
| 		i18n.G("disable converge logic checks"), | 		i18n.G("disable converge logic checks"), | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
|  | 	AppRollbackCommand.Flags().BoolVarP( | ||||||
|  | 		&internal.ShowUnchanged, | ||||||
|  | 		i18n.G("show-unchanged"), | ||||||
|  | 		i18n.G("U"), | ||||||
|  | 		false, | ||||||
|  | 		i18n.G("show all configs & images, including unchanged ones"), | ||||||
|  | 	) | ||||||
| } | } | ||||||
|  | |||||||
| @ -218,13 +218,13 @@ beforehand. See "abra app backup" for more.`), | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Gather configs | 		// Gather configs | ||||||
| 		configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env) | 		configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env, internal.ShowUnchanged) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatal(err) | 			log.Fatal(err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Gather images | 		// Gather images | ||||||
| 		imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose) | 		imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose, internal.ShowUnchanged) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatal(err) | 			log.Fatal(err) | ||||||
| 		} | 		} | ||||||
| @ -480,4 +480,12 @@ func init() { | |||||||
| 		false, | 		false, | ||||||
| 		i18n.G("only show release notes"), | 		i18n.G("only show release notes"), | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
|  | 	AppUpgradeCommand.Flags().BoolVarP( | ||||||
|  | 		&internal.ShowUnchanged, | ||||||
|  | 		i18n.G("show-unchanged"), | ||||||
|  | 		i18n.G("U"), | ||||||
|  | 		false, | ||||||
|  | 		i18n.G("show all configs & images, including unchanged ones"), | ||||||
|  | 	) | ||||||
| } | } | ||||||
|  | |||||||
| @ -19,4 +19,5 @@ var ( | |||||||
| 	Minor            bool | 	Minor            bool | ||||||
| 	NoDomainChecks   bool | 	NoDomainChecks   bool | ||||||
| 	Patch            bool | 	Patch            bool | ||||||
|  | 	ShowUnchanged 	 bool | ||||||
| ) | ) | ||||||
|  | |||||||
| @ -157,7 +157,7 @@ func GatherSecretsForDeploy(cl *dockerClient.Client, app appPkg.App) ([]string, | |||||||
| 	return secretInfo, nil | 	return secretInfo, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, abraShEnv map[string]string) ([]string, error) { | func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, abraShEnv map[string]string, showUnchanged bool) ([]string, error) { | ||||||
| 	// Get current configs from existing deployment | 	// Get current configs from existing deployment | ||||||
| 	currentConfigs, err := GetConfigsForStack(cl, app) | 	currentConfigs, err := GetConfigsForStack(cl, app) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| @ -182,7 +182,9 @@ func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *co | |||||||
|  |  | ||||||
| 		if currentVersion, exists := currentConfigs[configName]; exists { | 		if currentVersion, exists := currentConfigs[configName]; exists { | ||||||
| 			if currentVersion == newVersion { | 			if currentVersion == newVersion { | ||||||
|  | 				if (showUnchanged) { | ||||||
| 					configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion)) | 					configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion)) | ||||||
|  | 				} | ||||||
| 			} else { | 			} else { | ||||||
| 				configInfo = append(configInfo, fmt.Sprintf("%s: %s → %s", configName, currentVersion, newVersion)) | 				configInfo = append(configInfo, fmt.Sprintf("%s: %s → %s", configName, currentVersion, newVersion)) | ||||||
| 			} | 			} | ||||||
| @ -194,7 +196,7 @@ func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *co | |||||||
| 	return configInfo, nil | 	return configInfo, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config) ([]string, error) { | func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, showUnchanged bool) ([]string, error) { | ||||||
|  |  | ||||||
| 	// Get current images from existing deployment | 	// Get current images from existing deployment | ||||||
| 	currentImages, err := GetImagesForStack(cl, app) | 	currentImages, err := GetImagesForStack(cl, app) | ||||||
| @ -230,7 +232,9 @@ func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *com | |||||||
| 	for newImageName, newImageVersion := range newImages { | 	for newImageName, newImageVersion := range newImages { | ||||||
| 		if currentVersion, exists := currentImages[newImageName]; exists { | 		if currentVersion, exists := currentImages[newImageName]; exists { | ||||||
| 			if currentVersion == newImageVersion { | 			if currentVersion == newImageVersion { | ||||||
|  | 				if showUnchanged { | ||||||
| 					imageInfo = append(imageInfo, fmt.Sprintf("%s: %s (unchanged)", newImageName, newImageVersion)) | 					imageInfo = append(imageInfo, fmt.Sprintf("%s: %s (unchanged)", newImageName, newImageVersion)) | ||||||
|  | 				} | ||||||
| 			} else { | 			} else { | ||||||
| 				imageInfo = append(imageInfo, fmt.Sprintf("%s: %s → %s", newImageName, currentVersion, newImageVersion)) | 				imageInfo = append(imageInfo, fmt.Sprintf("%s: %s → %s", newImageName, currentVersion, newImageVersion)) | ||||||
| 			} | 			} | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user