forked from toolshed/abra
@ -77,16 +77,16 @@ var recipeLintCommand = &cli.Command{
|
||||
}
|
||||
}
|
||||
|
||||
tableCol := []string{"Rule", "Satisfied"}
|
||||
tableCol := []string{"rule", "satisfied"}
|
||||
table := formatter.CreateTable(tableCol)
|
||||
table.Append([]string{"Compose files have the expected version", strconv.FormatBool(expectedVersion)})
|
||||
table.Append([]string{"Environment configuration is provided", strconv.FormatBool(envSampleProvided)})
|
||||
table.Append([]string{"Recipe contains a service named 'app'", strconv.FormatBool(serviceNamedApp)})
|
||||
table.Append([]string{"Traefik routing enabled on at least one service", strconv.FormatBool(traefikEnabled)})
|
||||
table.Append([]string{"All services have a healthcheck enabled", strconv.FormatBool(healthChecksForAllServices)})
|
||||
table.Append([]string{"All images are using a tag", strconv.FormatBool(allImagesTagged)})
|
||||
table.Append([]string{"No usage of unstable 'latest' tags", strconv.FormatBool(noUnstableTags)})
|
||||
table.Append([]string{"All tags are using a semver-like format", strconv.FormatBool(semverLikeTags)})
|
||||
table.Append([]string{"compose files have the expected version", strconv.FormatBool(expectedVersion)})
|
||||
table.Append([]string{"environment configuration is provided", strconv.FormatBool(envSampleProvided)})
|
||||
table.Append([]string{"recipe contains a service named 'app'", strconv.FormatBool(serviceNamedApp)})
|
||||
table.Append([]string{"traefik routing enabled on at least one service", strconv.FormatBool(traefikEnabled)})
|
||||
table.Append([]string{"all services have a healthcheck enabled", strconv.FormatBool(healthChecksForAllServices)})
|
||||
table.Append([]string{"all images are using a tag", strconv.FormatBool(allImagesTagged)})
|
||||
table.Append([]string{"no usage of unstable 'latest' tags", strconv.FormatBool(noUnstableTags)})
|
||||
table.Append([]string{"all tags are using a semver-like format", strconv.FormatBool(semverLikeTags)})
|
||||
table.Render()
|
||||
|
||||
return nil
|
||||
|
@ -23,7 +23,7 @@ var recipeListCommand = &cli.Command{
|
||||
recipes := catl.Flatten()
|
||||
sort.Sort(catalogue.ByRecipeName(recipes))
|
||||
|
||||
tableCol := []string{"Name", "Category", "Status"}
|
||||
tableCol := []string{"name", "category", "status"}
|
||||
table := formatter.CreateTable(tableCol)
|
||||
|
||||
for _, recipe := range recipes {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"coopcloud.tech/abra/pkg/git"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
@ -28,10 +28,8 @@ var recipeNewCommand = &cli.Command{
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/example.git", config.REPOS_BASE_URL)
|
||||
_, err := git.PlainClone(directory, false, &git.CloneOptions{URL: url, Tags: git.AllTags})
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
return nil
|
||||
if err := git.Clone(directory, url); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gitRepo := path.Join(config.APPS_DIR, recipe.Name, ".git")
|
||||
@ -39,6 +37,7 @@ var recipeNewCommand = &cli.Command{
|
||||
logrus.Fatal(err)
|
||||
return nil
|
||||
}
|
||||
logrus.Debugf("removed git repo in '%s'", gitRepo)
|
||||
|
||||
toParse := []string{
|
||||
path.Join(config.APPS_DIR, recipe.Name, "README.md"),
|
||||
@ -71,7 +70,7 @@ var recipeNewCommand = &cli.Command{
|
||||
}
|
||||
|
||||
logrus.Infof(
|
||||
"New recipe '%s' created in %s, happy hacking!\n",
|
||||
"new recipe '%s' created in %s, happy hacking!\n",
|
||||
recipe.Name, path.Join(config.APPS_DIR, recipe.Name),
|
||||
)
|
||||
|
||||
|
@ -36,7 +36,7 @@ the versioning metadata of up-and-running containers are.
|
||||
}
|
||||
|
||||
if !hasAppService {
|
||||
logrus.Fatal(fmt.Sprintf("No 'app' service defined in '%s', cannot proceed", recipe.Name))
|
||||
logrus.Fatal(fmt.Sprintf("no 'app' service defined in '%s'", recipe.Name))
|
||||
}
|
||||
|
||||
for _, service := range recipe.Config.Services {
|
||||
@ -44,17 +44,20 @@ the versioning metadata of up-and-running containers are.
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debugf("detected image '%s' for service '%s'", img, service.Name)
|
||||
|
||||
digest, err := client.GetTagDigest(img)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debugf("retrieved digest '%s' for '%s'", digest, img)
|
||||
|
||||
tag := img.(reference.NamedTagged).Tag()
|
||||
label := fmt.Sprintf("coop-cloud.${STACK_NAME}.%s.version=%s-%s", service.Name, tag, digest)
|
||||
if err := recipe.UpdateLabel(service.Name, label); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debugf("added label '%s' to service '%s'", label, service.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -40,6 +40,7 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debugf("read '%s' from the recipe catalogue for '%s'", catlVersions, service.Name)
|
||||
|
||||
img, err := reference.ParseNormalizedNamed(service.Image)
|
||||
if err != nil {
|
||||
@ -51,6 +52,7 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debugf("retrieved '%s' from remote registry for '%s'", regVersions, image)
|
||||
|
||||
if strings.Contains(image, "library") {
|
||||
// ParseNormalizedNamed prepends 'library' to images like nginx:<tag>,
|
||||
@ -61,6 +63,7 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||
|
||||
semverLikeTag := true
|
||||
if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) {
|
||||
logrus.Debugf("'%s' not considered semver-like", img.(reference.NamedTagged).Tag())
|
||||
semverLikeTag = false
|
||||
}
|
||||
|
||||
@ -68,6 +71,7 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||
if err != nil && semverLikeTag {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debugf("parsed '%s' for '%s'", tag, service.Name)
|
||||
|
||||
var compatible []tagcmp.Tag
|
||||
for _, regVersion := range regVersions {
|
||||
@ -81,10 +85,12 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("detected potential upgradable tags '%s' for '%s'", compatible, service.Name)
|
||||
|
||||
sort.Sort(tagcmp.ByTagDesc(compatible))
|
||||
|
||||
if len(compatible) == 0 && semverLikeTag {
|
||||
logrus.Info(fmt.Sprintf("No new versions available for '%s', '%s' is the latest", image, tag))
|
||||
logrus.Info(fmt.Sprintf("no new versions available for '%s', '%s' is the latest", image, tag))
|
||||
continue // skip on to the next tag and don't update any compose files
|
||||
}
|
||||
|
||||
@ -101,11 +107,13 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||
}
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("Which tag would you like to upgrade to? (service: %s, tag: %s)", service.Name, tag)
|
||||
logrus.Debugf("detected compatible upgradable tags '%s' for '%s'", compatibleStrings, service.Name)
|
||||
|
||||
msg := fmt.Sprintf("upgrade to which tag? (service: %s, tag: %s)", service.Name, tag)
|
||||
if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) {
|
||||
tag := img.(reference.NamedTagged).Tag()
|
||||
logrus.Warning(fmt.Sprintf("Unable to determine versioning semantics of '%s', listing all tags...", tag))
|
||||
msg = fmt.Sprintf("Which tag would you like to upgrade to? (service: %s, tag: %s)", service.Name, tag)
|
||||
logrus.Warning(fmt.Sprintf("unable to determine versioning semantics of '%s', listing all tags", tag))
|
||||
msg = fmt.Sprintf("upgrade to which tag? (service: %s, tag: %s)", service.Name, tag)
|
||||
compatibleStrings = []string{}
|
||||
for _, regVersion := range regVersions {
|
||||
compatibleStrings = append(compatibleStrings, regVersion.Name)
|
||||
@ -124,6 +132,7 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||
if err := recipe.UpdateTag(image, upgradeTag); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debugf("tag updated from '%s' to '%s' for '%s'", image, upgradeTag, recipe.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user