forked from coop-cloud/abra
Fix comments
This commit is contained in:
parent
a55ac9d762
commit
6273fb3d08
|
@ -138,8 +138,8 @@ var UpgradeAll = cli.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read docker label in the format coop-cloud.${STACK_NAME}.${LABEL}
|
|
||||||
func getLabel(cl *dockerclient.Client, stackName string, label string) string {
|
func getLabel(cl *dockerclient.Client, stackName string, label string) string {
|
||||||
|
// getLabel reads docker label in the format coop-cloud.${STACK_NAME}.${LABEL}
|
||||||
filter := filters.NewArgs()
|
filter := filters.NewArgs()
|
||||||
filter.Add("label", fmt.Sprintf("%s=%s", convert.LabelNamespace, stackName))
|
filter.Add("label", fmt.Sprintf("%s=%s", convert.LabelNamespace, stackName))
|
||||||
|
|
||||||
|
@ -157,9 +157,9 @@ func getLabel(cl *dockerclient.Client, stackName string, label string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read boolean docker label
|
|
||||||
func getBoolLabel(cl *dockerclient.Client, stackName string, label string) bool {
|
func getBoolLabel(cl *dockerclient.Client, stackName string, label string) bool {
|
||||||
lableValue := getLabel(cl, stackName, label)
|
lableValue := getLabel(cl, stackName, label)
|
||||||
|
// getBoolLabel reads a boolean docker label
|
||||||
if lableValue != "" {
|
if lableValue != "" {
|
||||||
value, err := strconv.ParseBool(lableValue)
|
value, err := strconv.ParseBool(lableValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -170,8 +170,8 @@ func getBoolLabel(cl *dockerclient.Client, stackName string, label string) bool
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read Env variables from docker services
|
|
||||||
func getEnv(cl *dockerclient.Client, stackName string) config.AppEnv {
|
func getEnv(cl *dockerclient.Client, stackName string) config.AppEnv {
|
||||||
|
// getEnv reads Env variables from docker services
|
||||||
envMap := make(map[string]string)
|
envMap := make(map[string]string)
|
||||||
filter := filters.NewArgs()
|
filter := filters.NewArgs()
|
||||||
filter.Add("label", fmt.Sprintf("%s=%s", convert.LabelNamespace, stackName))
|
filter.Add("label", fmt.Sprintf("%s=%s", convert.LabelNamespace, stackName))
|
||||||
|
@ -200,6 +200,8 @@ func getEnv(cl *dockerclient.Client, stackName string) config.AppEnv {
|
||||||
func getLatestUpgrade(cl *dockerclient.Client, stackName string, recipeName string) string {
|
func getLatestUpgrade(cl *dockerclient.Client, stackName string, recipeName string) string {
|
||||||
deployedVersion := getDeployedVersion(cl, stackName, recipeName)
|
deployedVersion := getDeployedVersion(cl, stackName, recipeName)
|
||||||
availableUpgrades := getAvailableUpgrades(cl, stackName, recipeName, deployedVersion)
|
availableUpgrades := getAvailableUpgrades(cl, stackName, recipeName, deployedVersion)
|
||||||
|
// getLatestUpgrade returns the latest available version for an app regarding to the --major flag
|
||||||
|
// if it is newer than the currently deployed version
|
||||||
if len(availableUpgrades) == 0 {
|
if len(availableUpgrades) == 0 {
|
||||||
logrus.Debugf("no available upgrades for %s", stackName)
|
logrus.Debugf("no available upgrades for %s", stackName)
|
||||||
return ""
|
return ""
|
||||||
|
@ -216,6 +218,7 @@ func getLatestUpgrade(cl *dockerclient.Client, stackName string, recipeName stri
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDeployedVersion(cl *dockerclient.Client, stackName string, recipeName string) string {
|
func getDeployedVersion(cl *dockerclient.Client, stackName string, recipeName string) string {
|
||||||
|
// getDeployedVersion returns the currently deployed version of an app
|
||||||
logrus.Debugf("Retrieve deployed version whether %s is already deployed", stackName)
|
logrus.Debugf("Retrieve deployed version whether %s is already deployed", stackName)
|
||||||
isDeployed, deployedVersion, err := stack.IsDeployed(context.Background(), cl, stackName)
|
isDeployed, deployedVersion, err := stack.IsDeployed(context.Background(), cl, stackName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -230,6 +233,8 @@ func getDeployedVersion(cl *dockerclient.Client, stackName string, recipeName st
|
||||||
return deployedVersion
|
return deployedVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getAvailableUpgrades returns all available versions of an app that are newer than
|
||||||
|
// the deployed version. It only includes major steps if the --major flag is set.
|
||||||
func getAvailableUpgrades(cl *dockerclient.Client, stackName string, recipeName string,
|
func getAvailableUpgrades(cl *dockerclient.Client, stackName string, recipeName string,
|
||||||
deployedVersion string) []string {
|
deployedVersion string) []string {
|
||||||
catl, err := recipe.ReadRecipeCatalogue()
|
catl, err := recipe.ReadRecipeCatalogue()
|
||||||
|
@ -271,8 +276,8 @@ func getAvailableUpgrades(cl *dockerclient.Client, stackName string, recipeName
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// clone, pull, checkout version and lint the recipe repository
|
|
||||||
func processRecipeRepoVersion(recipeName string, version string) {
|
func processRecipeRepoVersion(recipeName string, version string) {
|
||||||
|
// processRecipeRepoVersion clones, pulls, checks out the version and lints the recipe repository
|
||||||
if err := recipe.EnsureExists(recipeName); err != nil {
|
if err := recipe.EnsureExists(recipeName); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -289,8 +294,8 @@ func processRecipeRepoVersion(recipeName string, version string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge abra.sh env's into app env's
|
|
||||||
func mergeAbraShEnv(recipeName string, env config.AppEnv) {
|
func mergeAbraShEnv(recipeName string, env config.AppEnv) {
|
||||||
|
// mergeAbraShEnv merges abra.sh env's into the app env's
|
||||||
abraShPath := fmt.Sprintf("%s/%s/%s", config.RECIPES_DIR, recipeName, "abra.sh")
|
abraShPath := fmt.Sprintf("%s/%s/%s", config.RECIPES_DIR, recipeName, "abra.sh")
|
||||||
abraShEnv, err := config.ReadAbraShEnvVars(abraShPath)
|
abraShEnv, err := config.ReadAbraShEnvVars(abraShPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -303,6 +308,7 @@ func mergeAbraShEnv(recipeName string, env config.AppEnv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDeployConfig(recipeName string, stackName string, env config.AppEnv) (*composetypes.Config, stack.Deploy) {
|
func createDeployConfig(recipeName string, stackName string, env config.AppEnv) (*composetypes.Config, stack.Deploy) {
|
||||||
|
// createDeployConfig merges and enriches the compose config for the deployment
|
||||||
// Workaround, is there a better way?
|
// Workaround, is there a better way?
|
||||||
env["STACK_NAME"] = stackName
|
env["STACK_NAME"] = stackName
|
||||||
|
|
||||||
|
@ -329,6 +335,7 @@ func createDeployConfig(recipeName string, stackName string, env config.AppEnv)
|
||||||
}
|
}
|
||||||
|
|
||||||
func upgrade(cl *dockerclient.Client, stackName string, recipeName string, upgradeVersion string) {
|
func upgrade(cl *dockerclient.Client, stackName string, recipeName string, upgradeVersion string) {
|
||||||
|
// upgrade performs all necessary steps to upgrade an app
|
||||||
app := config.App{
|
app := config.App{
|
||||||
Name: stackName,
|
Name: stackName,
|
||||||
Recipe: recipeName,
|
Recipe: recipeName,
|
||||||
|
|
Loading…
Reference in New Issue