feat: recipe sync shows changes
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
See #579
This commit is contained in:
@ -16,7 +16,6 @@ import (
|
|||||||
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
||||||
"coopcloud.tech/abra/pkg/secret"
|
"coopcloud.tech/abra/pkg/secret"
|
||||||
"github.com/AlecAivazis/survey/v2"
|
"github.com/AlecAivazis/survey/v2"
|
||||||
"github.com/charmbracelet/lipgloss/table"
|
|
||||||
dockerClient "github.com/docker/docker/client"
|
dockerClient "github.com/docker/docker/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -144,7 +143,6 @@ var AppNewCommand = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var appSecrets AppSecrets
|
var appSecrets AppSecrets
|
||||||
var secretsTable *table.Table
|
|
||||||
if generateSecrets {
|
if generateSecrets {
|
||||||
sampleEnv, err := recipe.SampleEnv()
|
sampleEnv, err := recipe.SampleEnv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -178,18 +176,6 @@ var AppNewCommand = &cobra.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
secretsTable, err = formatter.CreateTable()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
headers := []string{i18n.G("NAME"), i18n.G("VALUE")}
|
|
||||||
secretsTable.Headers(headers...)
|
|
||||||
|
|
||||||
for name, val := range appSecrets {
|
|
||||||
secretsTable.Row(name, val)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if newAppServer == "default" {
|
if newAppServer == "default" {
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// PromptBumpType prompts for version bump type
|
// PromptBumpType prompts for version bump type
|
||||||
func PromptBumpType(tagString, latestRelease string) error {
|
func PromptBumpType(tagString, latestRelease, changeOverview string) error {
|
||||||
if (!Major && !Minor && !Patch) && tagString == "" {
|
if (!Major && !Minor && !Patch) && tagString == "" {
|
||||||
fmt.Print(i18n.G(`
|
fmt.Print(i18n.G(`
|
||||||
You need to make a decision about what kind of an update this new recipe
|
You need to make a decision about what kind of an update this new recipe
|
||||||
@ -24,6 +24,8 @@ version.
|
|||||||
|
|
||||||
The latest published version is %s.
|
The latest published version is %s.
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
Here is a semver cheat sheet (more on https://semver.org):
|
Here is a semver cheat sheet (more on https://semver.org):
|
||||||
|
|
||||||
major: new features/bug fixes, backwards incompatible (e.g 1.0.0 -> 2.0.0).
|
major: new features/bug fixes, backwards incompatible (e.g 1.0.0 -> 2.0.0).
|
||||||
@ -38,7 +40,7 @@ Here is a semver cheat sheet (more on https://semver.org):
|
|||||||
should also Just Work and is mostly to do with minor bug fixes
|
should also Just Work and is mostly to do with minor bug fixes
|
||||||
and/or security patches. "nothing to worry about".
|
and/or security patches. "nothing to worry about".
|
||||||
|
|
||||||
`, latestRelease))
|
`, latestRelease, changeOverview))
|
||||||
|
|
||||||
var chosenBumpType string
|
var chosenBumpType string
|
||||||
prompt := &survey.Select{
|
prompt := &survey.Select{
|
||||||
|
@ -72,7 +72,7 @@ your private key and enter your passphrase beforehand.
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
recipe := internal.ValidateRecipe(args, cmd.Name())
|
recipe := internal.ValidateRecipe(args, cmd.Name())
|
||||||
|
|
||||||
imagesTmp, err := getImageVersions(recipe)
|
imagesTmp, err := GetImageVersions(recipe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -151,6 +151,7 @@ your private key and enter your passphrase beforehand.
|
|||||||
|
|
||||||
if len(tags) > 0 {
|
if len(tags) > 0 {
|
||||||
log.Warn(i18n.G("previous git tags detected, assuming new semver release"))
|
log.Warn(i18n.G("previous git tags detected, assuming new semver release"))
|
||||||
|
|
||||||
if err := createReleaseFromPreviousTag(tagString, mainAppVersion, recipe, tags); err != nil {
|
if err := createReleaseFromPreviousTag(tagString, mainAppVersion, recipe, tags); err != nil {
|
||||||
if cleanErr := cleanTag(recipe, tagString); cleanErr != nil {
|
if cleanErr := cleanTag(recipe, tagString); cleanErr != nil {
|
||||||
log.Fatal(cleanErr)
|
log.Fatal(cleanErr)
|
||||||
@ -178,8 +179,8 @@ your private key and enter your passphrase beforehand.
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// getImageVersions retrieves image versions for a recipe
|
// GetImageVersions retrieves image versions for a recipe
|
||||||
func getImageVersions(recipe recipe.Recipe) (map[string]string, error) {
|
func GetImageVersions(recipe recipe.Recipe) (map[string]string, error) {
|
||||||
services := make(map[string]string)
|
services := make(map[string]string)
|
||||||
|
|
||||||
config, err := recipe.GetComposeConfig(nil)
|
config, err := recipe.GetComposeConfig(nil)
|
||||||
@ -511,12 +512,6 @@ func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recip
|
|||||||
newTag.Major = strconv.Itoa(now + 1)
|
newTag.Major = strconv.Itoa(now + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if tagString == "" {
|
|
||||||
if err := internal.PromptBumpType(tagString, lastGitTag.String()); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if internal.Major || internal.Minor || internal.Patch {
|
if internal.Major || internal.Minor || internal.Patch {
|
||||||
newTag.Metadata = mainAppVersion
|
newTag.Metadata = mainAppVersion
|
||||||
tagString = newTag.String()
|
tagString = newTag.String()
|
||||||
|
@ -6,9 +6,11 @@ import (
|
|||||||
|
|
||||||
"coopcloud.tech/abra/cli/internal"
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
|
"coopcloud.tech/abra/pkg/formatter"
|
||||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
gitPkg "coopcloud.tech/abra/pkg/git"
|
||||||
"coopcloud.tech/abra/pkg/i18n"
|
"coopcloud.tech/abra/pkg/i18n"
|
||||||
"coopcloud.tech/abra/pkg/log"
|
"coopcloud.tech/abra/pkg/log"
|
||||||
|
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
||||||
"coopcloud.tech/tagcmp"
|
"coopcloud.tech/tagcmp"
|
||||||
"github.com/AlecAivazis/survey/v2"
|
"github.com/AlecAivazis/survey/v2"
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
@ -51,7 +53,7 @@ local file system.`),
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
imagesTmp, err := getImageVersions(recipe)
|
imagesTmp, err := GetImageVersions(recipe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -105,8 +107,46 @@ likely to change.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if nextTag == "" && (!internal.Major && !internal.Minor && !internal.Patch) {
|
if nextTag == "" && (!internal.Major && !internal.Minor && !internal.Patch) {
|
||||||
|
var changeOverview string
|
||||||
|
|
||||||
|
catl, err := recipePkg.ReadRecipeCatalogue(false)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
versions, err := recipePkg.GetRecipeCatalogueVersions(recipe.Name, catl)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
changesTable, err := formatter.CreateTable()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
latestRelease := tags[len(tags)-1]
|
latestRelease := tags[len(tags)-1]
|
||||||
if err := internal.PromptBumpType("", latestRelease); err != nil {
|
changesTable.Headers(i18n.G("SERVICE"), latestRelease, i18n.G("PROPOSED CHANGES"))
|
||||||
|
|
||||||
|
latestRecipeVersion := versions[len(versions)-1]
|
||||||
|
allRecipeVersions := catl[recipe.Name].Versions
|
||||||
|
for _, recipeVersion := range allRecipeVersions {
|
||||||
|
if serviceVersions, ok := recipeVersion[latestRecipeVersion]; ok {
|
||||||
|
for serviceName := range serviceVersions {
|
||||||
|
serviceMeta := serviceVersions[serviceName]
|
||||||
|
changesTable.Row(
|
||||||
|
[]string{
|
||||||
|
serviceName,
|
||||||
|
fmt.Sprintf("%s:%s", serviceMeta.Image, serviceMeta.Tag),
|
||||||
|
fmt.Sprintf("%s:%s", serviceMeta.Image, imagesTmp[serviceMeta.Image]),
|
||||||
|
}...,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changeOverview = changesTable.Render()
|
||||||
|
|
||||||
|
if err := internal.PromptBumpType("", latestRelease, changeOverview); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user