Fix comments

This commit is contained in:
Moritz 2023-02-07 18:08:43 +01:00
parent 5767eb0eda
commit b32bc018f9
1 changed files with 12 additions and 5 deletions

View File

@ -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 {
// getLabel reads docker label in the format coop-cloud.${STACK_NAME}.${LABEL}
filter := filters.NewArgs()
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 ""
}
// Read boolean docker label
func getBoolLabel(cl *dockerclient.Client, stackName string, label string) bool {
lableValue := getLabel(cl, stackName, label)
// getBoolLabel reads a boolean docker label
if lableValue != "" {
value, err := strconv.ParseBool(lableValue)
if err != nil {
@ -170,8 +170,8 @@ func getBoolLabel(cl *dockerclient.Client, stackName string, label string) bool
return false
}
// Read Env variables from docker services
func getEnv(cl *dockerclient.Client, stackName string) config.AppEnv {
// getEnv reads Env variables from docker services
envMap := make(map[string]string)
filter := filters.NewArgs()
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 {
deployedVersion := getDeployedVersion(cl, stackName, recipeName)
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 {
logrus.Debugf("no available upgrades for %s", stackName)
return ""
@ -216,6 +218,7 @@ func getLatestUpgrade(cl *dockerclient.Client, stackName string, recipeName stri
}
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)
isDeployed, deployedVersion, err := stack.IsDeployed(context.Background(), cl, stackName)
if err != nil {
@ -230,6 +233,8 @@ func getDeployedVersion(cl *dockerclient.Client, stackName string, recipeName st
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,
deployedVersion string) []string {
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) {
// processRecipeRepoVersion clones, pulls, checks out the version and lints the recipe repository
if err := recipe.EnsureExists(recipeName); err != nil {
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) {
// mergeAbraShEnv merges abra.sh env's into the app env's
abraShPath := fmt.Sprintf("%s/%s/%s", config.RECIPES_DIR, recipeName, "abra.sh")
abraShEnv, err := config.ReadAbraShEnvVars(abraShPath)
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) {
// createDeployConfig merges and enriches the compose config for the deployment
// Workaround, is there a better way?
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) {
// upgrade performs all necessary steps to upgrade an app
app := config.App{
Name: stackName,
Recipe: recipeName,