Compare commits

..

19 Commits

Author SHA1 Message Date
dc207a0138 test: lang parsing
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
See #652
2025-09-06 08:38:38 +02:00
02add8c3ef chore: make i18n
All checks were successful
continuous-integration/drone/push Build is passing
2025-09-06 08:28:53 +02:00
560d609013 test: ensure autocomplete output works
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
See #649
2025-09-06 08:26:50 +02:00
b4c9fbfe6d fix: use local flag
See #648
2025-09-06 08:24:37 +02:00
3wc
7f456a3f24 chore: 4matting
All checks were successful
continuous-integration/drone/push Build is passing
2025-09-05 21:12:21 +00:00
3wc
709a9ad659 fix: use LANG prefix instead of full value 2025-09-05 21:12:21 +00:00
a468245413 chore: update translation files
All checks were successful
continuous-integration/drone/push Build is passing
Updated by "Update PO files to match POT (msgmerge)" add-on in Weblate.

Translation: Co-op Cloud/abra
Translate-URL: https://translate.coopcloud.tech/projects/co-op-cloud/abra/
2025-09-05 21:09:51 +00:00
3wc
e895b852bc chore: update POT
All checks were successful
continuous-integration/drone/push Build is passing
2025-09-05 17:09:39 -04:00
3wc
bef92d53a8 fix: don't translate blank string
Some checks failed
continuous-integration/drone/push Build is failing
2025-09-05 13:33:51 -04:00
3wc
a4b47b431b fix: temporary fix to #648
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
2025-09-05 13:29:31 -04:00
bddf8039af test: ensure previous versions not deleted
All checks were successful
continuous-integration/drone/push Build is passing
See #615
2025-09-04 08:26:21 +00:00
d74e760940 Update translation files
All checks were successful
continuous-integration/drone/push Build is passing
Updated by "Update PO files to match POT (msgmerge)" add-on in Weblate.

Translation: Co-op Cloud/abra
Translate-URL: https://translate.coopcloud.tech/projects/co-op-cloud/abra/
2025-09-04 08:14:12 +00:00
7f75d25d56 Translated using Weblate (Spanish)
Currently translated at 10.4% (116 of 1105 strings)

Translation: Co-op Cloud/abra
Translate-URL: https://translate.coopcloud.tech/projects/co-op-cloud/abra/es/
2025-09-04 08:14:12 +00:00
3wc
0bb6d9609c Add test to make sure non-chaos hash deploy fails..
All checks were successful
continuous-integration/drone/push Build is passing
..and make sure _ensure_env_version passes through variable correctly.
2025-09-03 14:25:42 -04:00
3wc
e858dcdd14 Whoops, gettext 2025-09-03 14:25:41 -04:00
3wc
3606349a4a Error out if env version is chaos-y and --chaos not provided
Re #554
2025-09-03 14:25:22 -04:00
4547cf2579 fix: help/version override for translation
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
See #628
2025-09-03 08:58:31 +02:00
e1f029d2db chore: make i18n
All checks were successful
continuous-integration/drone/push Build is passing
2025-09-03 00:25:23 +02:00
cf2952dc65 chore: add missing i18n on --latest [ci skip] 2025-09-03 00:24:55 +02:00
24 changed files with 526 additions and 850 deletions

View File

@ -6,13 +6,14 @@ import (
"strings"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/envfile"
"coopcloud.tech/abra/pkg/secret"
appPkg "coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/deploy"
"coopcloud.tech/abra/pkg/dns"
"coopcloud.tech/abra/pkg/formatter"
"coopcloud.tech/abra/pkg/i18n"
@ -107,10 +108,13 @@ checkout as-is. Recipe commit hashes are also supported as values for
}
if !internal.Chaos {
_, err = app.Recipe.EnsureVersion(toDeployVersion)
isChaos, err := app.Recipe.EnsureVersion(toDeployVersion)
if err != nil {
log.Fatal(i18n.G("ensure recipe: %s", err))
}
if isChaos {
log.Fatal(i18n.G("version '%s' appears to be a chaos commit, but --chaos/-C was not provided", toDeployVersion))
}
}
if err := lint.LintForErrors(app.Recipe); err != nil {
@ -125,9 +129,13 @@ checkout as-is. Recipe commit hashes are also supported as values for
log.Fatal(err)
}
if err := deploy.MergeAbraShEnv(app.Recipe, app.Env); err != nil {
abraShEnv, err := envfile.ReadAbraShEnvVars(app.Recipe.AbraShPath)
if err != nil {
log.Fatal(err)
}
for k, v := range abraShEnv {
app.Env[k] = v
}
composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
if err != nil {
@ -186,35 +194,12 @@ checkout as-is. Recipe commit hashes are also supported as values for
deployedVersion = deployMeta.Version
}
// Gather secrets
secretInfo, err := deploy.GatherSecretsForDeploy(cl, app)
if err != nil {
log.Fatal(err)
}
// Gather configs
configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env)
if err != nil {
log.Fatal(err)
}
// Gather images
imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose)
if err != nil {
log.Fatal(err)
}
// Show deploy overview
if err := internal.DeployOverview(
app,
deployedVersion,
toDeployVersion,
"",
deployWarnMessages,
strings.Join(secretInfo, "\n"),
strings.Join(configInfo, "\n"),
strings.Join(imageInfo, "\n"),
); err != nil {
log.Fatal(err)
}
@ -260,7 +245,7 @@ checkout as-is. Recipe commit hashes are also supported as values for
},
}
func getLatestVersionOrCommit(app appPkg.App) (string, error) {
func getLatestVersionOrCommit(app app.App) (string, error) {
versions, err := app.Recipe.Tags()
if err != nil {
return "", err
@ -295,7 +280,7 @@ func validateArgsAndFlags(args []string) error {
return nil
}
func validateSecrets(cl *dockerClient.Client, app appPkg.App) error {
func validateSecrets(cl *dockerClient.Client, app app.App) error {
secStats, err := secret.PollSecretsStatus(cl, app)
if err != nil {
return err
@ -310,7 +295,7 @@ func validateSecrets(cl *dockerClient.Client, app appPkg.App) error {
return nil
}
func getDeployVersion(cliArgs []string, deployMeta stack.DeployMeta, app appPkg.App) (string, error) {
func getDeployVersion(cliArgs []string, deployMeta stack.DeployMeta, app app.App) (string, error) {
// Chaos mode overrides everything
if internal.Chaos {
v, err := app.Recipe.ChaosVersion()
@ -385,8 +370,8 @@ func init() {
AppDeployCommand.PersistentFlags().BoolVarP(
&internal.DeployLatest,
"latest",
"l",
i18n.G("latest"),
i18n.G("l"),
false,
i18n.G("deploy latest recipe version"),
)

View File

@ -4,10 +4,11 @@ import (
"errors"
"strings"
"coopcloud.tech/abra/pkg/app"
appPkg "coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/deploy"
"coopcloud.tech/abra/pkg/envfile"
"coopcloud.tech/abra/pkg/formatter"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/lint"
@ -154,9 +155,13 @@ beforehand. See "abra app backup" for more.`),
log.Fatal(err)
}
if err := deploy.MergeAbraShEnv(app.Recipe, app.Env); err != nil {
abraShEnv, err := envfile.ReadAbraShEnvVars(app.Recipe.AbraShPath)
if err != nil {
log.Fatal(err)
}
for k, v := range abraShEnv {
app.Env[k] = v
}
composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
if err != nil {
@ -185,24 +190,6 @@ beforehand. See "abra app backup" for more.`),
}
appPkg.SetUpdateLabel(compose, stackName, app.Env)
// Gather secrets
secretInfo, err := deploy.GatherSecretsForDeploy(cl, app)
if err != nil {
log.Fatal(err)
}
// Gather configs
configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env)
if err != nil {
log.Fatal(err)
}
// Gather images
imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose)
if err != nil {
log.Fatal(err)
}
// NOTE(d1): no release notes implemeneted for rolling back
if err := internal.DeployOverview(
app,
@ -210,9 +197,6 @@ beforehand. See "abra app backup" for more.`),
chosenDowngrade,
"",
downgradeWarnMessages,
strings.Join(secretInfo, "\n"),
strings.Join(configInfo, "\n"),
strings.Join(imageInfo, "\n"),
); err != nil {
log.Fatal(err)
}
@ -283,7 +267,7 @@ func chooseDowngrade(
// validateDownpgradeVersionArg validates the specific version.
func validateDowngradeVersionArg(
specificVersion string,
app appPkg.App,
app app.App,
deployMeta stack.DeployMeta,
) error {
parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)

View File

@ -71,9 +71,6 @@ Passing "--prune/-p" does not remove those volumes.`),
config.NO_DOMAIN_DEFAULT,
"",
nil,
"",
"",
"",
); err != nil {
log.Fatal(err)
}

View File

@ -7,11 +7,12 @@ import (
"strings"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/app"
appPkg "coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/deploy"
"coopcloud.tech/abra/pkg/envfile"
"coopcloud.tech/abra/pkg/formatter"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/lint"
@ -167,9 +168,13 @@ beforehand. See "abra app backup" for more.`),
log.Fatal(err)
}
if err := deploy.MergeAbraShEnv(app.Recipe, app.Env); err != nil {
abraShEnv, err := envfile.ReadAbraShEnvVars(app.Recipe.AbraShPath)
if err != nil {
log.Fatal(err)
}
for k, v := range abraShEnv {
app.Env[k] = v
}
composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
if err != nil {
@ -211,24 +216,6 @@ beforehand. See "abra app backup" for more.`),
}
}
// Gather secrets
secretInfo, err := deploy.GatherSecretsForDeploy(cl, app)
if err != nil {
log.Fatal(err)
}
// Gather configs
configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env)
if err != nil {
log.Fatal(err)
}
// Gather images
imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose)
if err != nil {
log.Fatal(err)
}
if showReleaseNotes {
fmt.Print(upgradeReleaseNotes)
return
@ -247,9 +234,6 @@ beforehand. See "abra app backup" for more.`),
chosenUpgrade,
upgradeReleaseNotes,
upgradeWarnMessages,
strings.Join(secretInfo, "\n"),
strings.Join(configInfo, "\n"),
strings.Join(imageInfo, "\n"),
); err != nil {
log.Fatal(err)
}
@ -327,7 +311,7 @@ func chooseUpgrade(
}
func getReleaseNotes(
app appPkg.App,
app app.App,
versions []string,
chosenUpgrade string,
deployMeta stack.DeployMeta,
@ -372,7 +356,7 @@ func getReleaseNotes(
// ensureUpgradesAvailable ensures that there are available upgrades.
func ensureUpgradesAvailable(
app appPkg.App,
app app.App,
versions []string,
availableUpgrades *[]string,
deployMeta stack.DeployMeta,
@ -404,7 +388,7 @@ func ensureUpgradesAvailable(
// validateUpgradeVersionArg validates the specific version.
func validateUpgradeVersionArg(
specificVersion string,
app appPkg.App,
app app.App,
deployMeta stack.DeployMeta,
) error {
parsedSpecificVersion, err := tagcmp.Parse(specificVersion)
@ -431,7 +415,7 @@ func validateUpgradeVersionArg(
// ensureDeployed ensures the app is deployed and if so, returns deployment
// meta info.
func ensureDeployed(cl *dockerClient.Client, app appPkg.App) (stack.DeployMeta, error) {
func ensureDeployed(cl *dockerClient.Client, app app.App) (stack.DeployMeta, error) {
log.Debug(i18n.G("checking whether %s is already deployed", app.StackName()))
deployMeta, err := stack.IsDeployed(context.Background(), cl, app.StackName())

View File

@ -5,6 +5,8 @@ var (
Debug bool
NoInput bool
Offline bool
Help bool
Version bool
// NOTE(d1): sub-command specific
Chaos bool

View File

@ -50,9 +50,6 @@ func DeployOverview(
toDeployVersion string,
releaseNotes string,
warnMessages []string,
secrets string,
configs string,
images string,
) error {
deployConfig := "compose.yml"
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
@ -83,24 +80,6 @@ func DeployOverview(
{i18n.G("CURRENT DEPLOYMENT"), formatter.BoldDirtyDefault(deployedVersion)},
{i18n.G("ENV VERSION"), formatter.BoldDirtyDefault(envVersion)},
{i18n.G("NEW DEPLOYMENT"), formatter.BoldDirtyDefault(toDeployVersion)},
{"", ""},
{i18n.G("IMAGES"), images},
}
if len(secrets) > 0 {
secretsRows := [][]string{
{"", ""},
{i18n.G("SECRETS"), secrets},
}
rows = append(rows, secretsRows...)
}
if len(configs) > 0 {
configsRows := [][]string{
{"", ""},
{i18n.G("CONFIGS"), configs},
}
rows = append(rows, configsRows...)
}
deployType := getDeployType(deployedVersion, toDeployVersion)

View File

@ -47,6 +47,29 @@ Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`)
helpCmd = &cobra.Command{
Use: i18n.G("help [command]"),
// translators: Short description for `help` command
Short: i18n.G("Help about any command"),
Long: i18n.G(`Help provides help for any command in the application.
Simply type abra help [path to command] for full details.`),
Run: func(c *cobra.Command, args []string) {
cmd, _, e := c.Root().Find(args)
if cmd == nil || e != nil {
c.Print(i18n.G("unknown help topic %#q\n", args))
if err := c.Root().Usage(); err != nil {
log.Fatal(err)
}
} else {
cmd.InitDefaultHelpFlag()
cmd.InitDefaultVersionFlag()
if err := cmd.Help(); err != nil {
log.Fatal(err)
}
}
},
}
)
func Run(version, commit string) {
@ -122,6 +145,7 @@ Config:
rootCmd.CompletionOptions.DisableDefaultCmd = true
rootCmd.SetUsageTemplate(usageTemplate)
rootCmd.SetHelpCommand(helpCmd)
// translators: `abra man` aliases. use a comma separated list of aliases
// with no spaces in between
@ -185,6 +209,22 @@ Config:
i18n.G("prefer offline & filesystem access"),
)
rootCmd.PersistentFlags().BoolVarP(
&internal.Help,
i18n.G("help"),
i18n.G("h"),
false,
i18n.G("help for abra"),
)
rootCmd.Flags().BoolVarP(
&internal.Version,
i18n.G("version"),
i18n.G("v"),
false,
i18n.G("version for abra"),
)
catalogue.CatalogueCommand.AddCommand(
catalogue.CatalogueGenerateCommand,
catalogue.CatalogueSyncCommand,

View File

@ -11,7 +11,6 @@ import (
"coopcloud.tech/abra/cli/internal"
appPkg "coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/deploy"
"coopcloud.tech/abra/pkg/envfile"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/lint"
@ -336,6 +335,21 @@ func processRecipeRepoVersion(r recipe.Recipe, version string) error {
return nil
}
// mergeAbraShEnv merges abra.sh env vars into the app env vars.
func mergeAbraShEnv(recipe recipe.Recipe, env envfile.AppEnv) error {
abraShEnv, err := envfile.ReadAbraShEnvVars(recipe.AbraShPath)
if err != nil {
return err
}
for k, v := range abraShEnv {
log.Debugf("read v:%s k: %s", v, k)
env[k] = v
}
return nil
}
// createDeployConfig merges and enriches the compose config for the deployment.
func createDeployConfig(r recipe.Recipe, stackName string, env envfile.AppEnv) (*composetypes.Config, stack.Deploy, error) {
env["STACK_NAME"] = stackName
@ -430,7 +444,7 @@ func upgrade(cl *dockerclient.Client, stackName, recipeName, upgradeVersion stri
return err
}
if err = deploy.MergeAbraShEnv(app.Recipe, app.Env); err != nil {
if err = mergeAbraShEnv(app.Recipe, app.Env); err != nil {
return err
}

View File

@ -3,7 +3,6 @@ package client
import (
"context"
"errors"
"strings"
"coopcloud.tech/abra/pkg/i18n"
"github.com/docker/docker/api/types/filters"
@ -38,12 +37,3 @@ func RemoveConfigs(cl *client.Client, ctx context.Context, configNames []string,
}
return nil
}
func GetConfigNameAndVersion(fullName string, stackName string) (string, string, error) {
name := strings.TrimPrefix(fullName, stackName+"_")
if lastUnderscore := strings.LastIndex(name, "_"); lastUnderscore != -1 {
return name[0:lastUnderscore], name[lastUnderscore+1:], nil
} else {
return "", "", errors.New(i18n.G("can't parse version from config '%s'", fullName))
}
}

View File

@ -1,89 +0,0 @@
package client
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetConfigNameAndVersion(t *testing.T) {
tests := []struct {
name string
fullName string
stackName string
expected string
expectedVer string
expectError bool
}{
{
name: "valid config with version",
fullName: "myapp_database_v2",
stackName: "myapp",
expected: "database",
expectedVer: "v2",
expectError: false,
},
{
name: "valid config with numeric version",
fullName: "myapp_redis_1",
stackName: "myapp",
expected: "redis",
expectedVer: "1",
expectError: false,
},
{
name: "config without underscore in name",
fullName: "myapp_db_v1",
stackName: "myapp",
expected: "db",
expectedVer: "v1",
expectError: false,
},
{
name: "config with multiple underscores",
fullName: "myapp_my_database_v3",
stackName: "myapp",
expected: "my_database",
expectedVer: "v3",
expectError: false,
},
{
name: "invalid config - no version",
fullName: "myapp_database",
stackName: "myapp",
expectError: true,
},
{
name: "empty config name",
fullName: "myapp__v1",
stackName: "myapp",
expected: "",
expectedVer: "v1",
expectError: false,
},
{
name: "wrong stack prefix",
fullName: "otherapp_database_v1",
stackName: "myapp",
expected: "otherapp_database",
expectedVer: "v1",
expectError: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
name, version, err := GetConfigNameAndVersion(tt.fullName, tt.stackName)
if tt.expectError {
assert.Error(t, err)
assert.Empty(t, name)
assert.Empty(t, version)
} else {
assert.NoError(t, err)
assert.Equal(t, tt.expected, name)
assert.Equal(t, tt.expectedVer, version)
}
})
}
}

View File

@ -17,11 +17,3 @@ func StoreSecret(cl *client.Client, secretName, secretValue string) error {
return nil
}
func GetSecretNames(secrets []swarm.Secret) []string {
var secretNames []string
for _, secret := range secrets {
secretNames = append(secretNames, secret.Spec.Name)
}
return secretNames
}

View File

@ -1,58 +0,0 @@
package client
import (
"testing"
"github.com/docker/docker/api/types/swarm"
"github.com/stretchr/testify/assert"
)
func TestGetSecretNames(t *testing.T) {
tests := []struct {
name string
secrets []swarm.Secret
expected []string
description string
}{
{
name: "empty secrets list",
secrets: []swarm.Secret{},
expected: nil,
description: "should return nil for empty input",
},
{
name: "single secret",
secrets: []swarm.Secret{
{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "database_password"}}},
},
expected: []string{"database_password"},
description: "should return single secret name",
},
{
name: "multiple secrets",
secrets: []swarm.Secret{
{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "db_password"}}},
{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "api_key"}}},
{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "ssl_cert"}}},
},
expected: []string{"db_password", "api_key", "ssl_cert"},
description: "should return all secret names in order",
},
{
name: "secrets with empty names",
secrets: []swarm.Secret{
{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: ""}}},
{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "valid_name"}}},
},
expected: []string{"", "valid_name"},
description: "should include empty names if present",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := GetSecretNames(tt.secrets)
assert.Equal(t, tt.expected, result, tt.description)
})
}
}

View File

@ -1,243 +0,0 @@
package deploy
import (
"context"
"errors"
"fmt"
"regexp"
"sort"
"strings"
appPkg "coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/envfile"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/abra/pkg/secret"
composetypes "github.com/docker/cli/cli/compose/types"
"github.com/docker/docker/api/types/swarm"
dockerClient "github.com/docker/docker/client"
)
// MergeAbraShEnv merges abra.sh env vars into the app env vars.
func MergeAbraShEnv(recipe recipe.Recipe, env envfile.AppEnv) error {
abraShEnv, err := envfile.ReadAbraShEnvVars(recipe.AbraShPath)
if err != nil {
return err
}
for k, v := range abraShEnv {
log.Debugf("read v:%s k: %s", v, k)
env[k] = v
}
return nil
}
// GetConfigsForStack retrieves all Docker configs attached to services in a given stack.
func GetConfigsForStack(cl *dockerClient.Client, app appPkg.App) (map[string]string, error) {
filters, err := app.Filters(false, false)
if err != nil {
return nil, err
}
// List all services in the stack
services, err := cl.ServiceList(context.Background(), swarm.ServiceListOptions{
Filters: filters,
})
if err != nil {
return nil, err
}
// Collect unique config names with versions
configs := make(map[string]string)
for _, service := range services {
if service.Spec.TaskTemplate.ContainerSpec != nil {
for _, configRef := range service.Spec.TaskTemplate.ContainerSpec.Configs {
configName := configRef.ConfigName
if configName == "" {
continue
}
configBaseName, configVersion, err := client.GetConfigNameAndVersion(configName, app.StackName())
if err != nil {
log.Warn(err)
continue
}
existingConfigVersion, ok := configs[configBaseName]
if !ok {
// First time seeing this, add to map
configs[configBaseName] = configVersion
} else {
// Just make sure the versions are the same..
if existingConfigVersion != configVersion {
log.Warnf("different versions for config '%s', '%s' and %s'", configBaseName, existingConfigVersion, configVersion)
}
}
}
}
}
return configs, nil
}
func GetImageNameAndTag(imageName string) (string, string, error) {
imageParts := regexp.MustCompile("^([^:]*):([^@]*)@?").FindSubmatch([]byte(imageName))
if len(imageParts) == 0 {
return "", "", errors.New("can't determine image version for image '%s'")
}
imageBaseName := string(imageParts[1])
imageTag := string(imageParts[2])
return imageBaseName, imageTag, nil
}
// GetImagesForStack retrieves all Docker images for services in a given stack.
func GetImagesForStack(cl *dockerClient.Client, app appPkg.App) (map[string]string, error) {
filters, err := app.Filters(false, false)
if err != nil {
return nil, err
}
// List all services in the stack
services, err := cl.ServiceList(context.Background(), swarm.ServiceListOptions{
Filters: filters,
})
if err != nil {
return nil, err
}
// Collect unique image names with versions
images := make(map[string]string)
for _, service := range services {
if service.Spec.TaskTemplate.ContainerSpec != nil {
imageName := service.Spec.TaskTemplate.ContainerSpec.Image
imageBaseName, imageTag, err := GetImageNameAndTag(imageName)
if err != nil {
log.Warn(err)
continue
}
existingImageVersion, ok := images[imageBaseName]
if !ok {
// First time seeing this, add to map
images[imageBaseName] = imageTag
} else {
// Just make sure the versions are the same..
if existingImageVersion != imageTag {
log.Warnf("different versions for image '%s', '%s' and %s'", imageBaseName, existingImageVersion, imageTag)
}
}
}
}
return images, nil
}
func GatherSecretsForDeploy(cl *dockerClient.Client, app appPkg.App) ([]string, error) {
secStats, err := secret.PollSecretsStatus(cl, app)
if err != nil {
return nil, err
}
var secretInfo []string
// Sort secrets to ensure reproducible output
sort.Slice(secStats, func(i, j int) bool {
return secStats[i].LocalName < secStats[j].LocalName
})
for _, secStat := range secStats {
secretInfo = append(secretInfo, fmt.Sprintf("%s: %s", secStat.LocalName, secStat.Version))
}
return secretInfo, nil
}
func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, abraShEnv map[string]string) ([]string, error) {
// Get current configs from existing deployment
currentConfigs, err := GetConfigsForStack(cl, app)
if err != nil {
return nil, err
}
log.Debugf("Deployed config names: %v", currentConfigs)
// Get new configs from the compose specification
newConfigs := compose.Configs
var configInfo []string
for configName := range newConfigs {
log.Debugf("Searching abra.sh for version for %s", configName)
versionKey := strings.ToUpper(configName) + "_VERSION"
newVersion, exists := abraShEnv[versionKey]
if !exists {
log.Warnf("No version found for config %s", configName)
configInfo = append(configInfo, fmt.Sprintf("%s: ? (missing version)", configName))
continue
}
if currentVersion, exists := currentConfigs[configName]; exists {
if currentVersion == newVersion {
configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion))
} else {
configInfo = append(configInfo, fmt.Sprintf("%s: %s → %s", configName, currentVersion, newVersion))
}
} else {
configInfo = append(configInfo, fmt.Sprintf("%s: %s (new)", configName, newVersion))
}
}
return configInfo, nil
}
func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config) ([]string, error) {
// Get current images from existing deployment
currentImages, err := GetImagesForStack(cl, app)
if err != nil {
return nil, err
}
log.Debugf("Deployed images: %v", currentImages)
// Proposed new images from the compose files
newImages := make(map[string]string)
for _, service := range compose.Services {
imageBaseName, imageTag, err := GetImageNameAndTag(service.Image)
if err != nil {
log.Warn(err)
continue
}
existingImageVersion, ok := newImages[imageBaseName]
if !ok {
// First time seeing this, add to map
newImages[imageBaseName] = imageTag
} else {
// Just make sure the versions are the same..
if existingImageVersion != imageTag {
log.Warnf("different versions for image '%s', '%s' and %s'", imageBaseName, existingImageVersion, imageTag)
}
}
}
log.Debugf("Proposed images: %v", newImages)
var imageInfo []string
for newImageName, newImageVersion := range newImages {
if currentVersion, exists := currentImages[newImageName]; exists {
if currentVersion == newImageVersion {
imageInfo = append(imageInfo, fmt.Sprintf("%s: %s (unchanged)", newImageName, newImageVersion))
} else {
imageInfo = append(imageInfo, fmt.Sprintf("%s: %s → %s", newImageName, currentVersion, newImageVersion))
}
} else {
imageInfo = append(imageInfo, fmt.Sprintf("%s: %s (new)", newImageName, newImageVersion))
}
}
return imageInfo, nil
}

View File

@ -1,87 +0,0 @@
package deploy
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetImageNameAndTag(t *testing.T) {
tests := []struct {
name string
imageName string
expectedName string
expectedTag string
expectError bool
description string
}{
{
name: "standard image with tag",
imageName: "nginx:1.23",
expectedName: "nginx",
expectedTag: "1.23",
expectError: false,
description: "should parse standard image name with tag",
},
{
name: "image with digest",
imageName: "nginx:1.23@sha256:abc123",
expectedName: "nginx",
expectedTag: "1.23",
expectError: false,
description: "should parse image with digest, ignoring digest part",
},
{
name: "image with latest tag",
imageName: "redis:latest",
expectedName: "redis",
expectedTag: "latest",
expectError: false,
description: "should parse image with latest tag",
},
{
name: "image with numeric tag",
imageName: "postgres:14",
expectedName: "postgres",
expectedTag: "14",
expectError: false,
description: "should parse image with numeric tag",
},
{
name: "image with complex name",
imageName: "registry.example.com/myapp/api:v1.2.3",
expectedName: "registry.example.com/myapp/api",
expectedTag: "v1.2.3",
expectError: false,
description: "should parse image with registry prefix and complex name",
},
{
name: "image without tag",
imageName: "nginx",
expectError: true,
description: "should error when no tag present",
},
{
name: "empty image name",
imageName: "",
expectError: true,
description: "should error on empty image name",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
name, tag, err := GetImageNameAndTag(tt.imageName)
if tt.expectError {
assert.Error(t, err)
assert.Empty(t, name)
assert.Empty(t, tag)
} else {
assert.NoError(t, err)
assert.Equal(t, tt.expectedName, name)
assert.Equal(t, tt.expectedTag, tag)
}
})
}
}

View File

@ -18,9 +18,11 @@ var assetFS embed.FS
var (
DefaultLocale = "en"
Locale = DefaultLocale
_, Mo = LoadLocale()
G = Mo.Get
)
func LoadLocale() *gotext.Mo {
func LoadLocale() (string, *gotext.Mo) {
entries, err := assetFS.ReadDir("locales")
if err != nil {
log.Fatalf("i18n: unable to read embedded locales directory: %s", err)
@ -36,6 +38,10 @@ func LoadLocale() *gotext.Mo {
}
locale := os.Getenv("LANG")
if lastUnderscore := strings.LastIndex(locale, "_"); lastUnderscore != -1 {
locale = locale[0:lastUnderscore]
}
if locale != "" {
if slices.Contains(linguas, locale) {
Locale = locale
@ -45,7 +51,7 @@ func LoadLocale() *gotext.Mo {
}
if Locale == DefaultLocale {
return gotext.NewMo()
return Locale, gotext.NewMo()
}
b, err := assetFS.ReadFile(fmt.Sprintf("locales/%s.mo", Locale))
@ -56,7 +62,5 @@ func LoadLocale() *gotext.Mo {
mo := gotext.NewMo()
mo.Parse(b)
return mo
return Locale, mo
}
var G = LoadLocale().Get

21
pkg/i18n/i18n_test.go Normal file
View File

@ -0,0 +1,21 @@
package i18n_test
import (
"os"
"testing"
"coopcloud.tech/abra/pkg/i18n"
)
func TestLoadLocale(t *testing.T) {
originalLang := os.Getenv("LANG")
os.Setenv("LANG", "es_ES.UTF-8")
t.Cleanup(func() {
os.Setenv("LANG", originalLang)
})
locale, _ := i18n.LoadLocale()
if locale != "es" {
t.Fatalf("expected 'es', locale was '%s'", locale)
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL\n"
"POT-Creation-Date: 2025-09-01 13:48+0200\n"
"PO-Revision-Date: 2025-08-29 21:45+0000\n"
"POT-Creation-Date: 2025-09-06 08:28+0200\n"
"PO-Revision-Date: 2025-09-04 08:14+0000\n"
"Last-Translator: chasqui <chasqui@cryptolab.net>\n"
"Language-Team: Spanish <https://translate.coopcloud.tech/projects/co-op-"
"cloud/abra/es/>\n"
@ -44,7 +44,7 @@ msgid ""
" abra recipe fetch gitea --ssh"
msgstr ""
#: cli/run.go:136
#: cli/run.go:160
msgid ""
" # generate the man pages into /usr/local/share/man/man1\n"
" abra_path=$(which abra) # pass abra absolute path to sudo below\n"
@ -376,7 +376,7 @@ msgstr ""
msgid "%s is still deployed. Run \"abra app undeploy %s\""
msgstr ""
#: cli/app/deploy.go:172 cli/app/upgrade.go:214
#: cli/app/deploy.go:175 cli/app/upgrade.go:214
#, c-format
msgid "%s missing from %s.env"
msgstr ""
@ -610,7 +610,7 @@ msgid "Both local recipe and live deployment labels are shown."
msgstr ""
#: cli/app/backup.go:319 cli/app/backup.go:335 cli/app/check.go:95
#: cli/app/cmd.go:285 cli/app/cp.go:385 cli/app/deploy.go:339
#: cli/app/cmd.go:285 cli/app/cp.go:385 cli/app/deploy.go:342
#: cli/app/labels.go:143 cli/app/new.go:377 cli/app/ps.go:213
#: cli/app/restart.go:162 cli/app/restore.go:138 cli/app/secret.go:569
#: cli/app/secret.go:609 cli/app/secret.go:633 cli/app/secret.go:641
@ -700,7 +700,7 @@ msgstr "🚀 Crea una nueva plataforma"
#. translators: Short description for `abra recipe new` command
#: cli/recipe/new.go:43
msgid "Create a new recipe"
msgstr ""
msgstr "Crear una nueva receta 🧑‍🍳"
#. translators: Short description for `app backup create` command
#: cli/app/backup.go:155
@ -777,7 +777,7 @@ msgid ""
"on your $PATH."
msgstr ""
#: cli/app/deploy.go:355 cli/app/new.go:353 cli/app/rollback.go:337
#: cli/app/deploy.go:358 cli/app/new.go:353 cli/app/rollback.go:337
#: cli/app/upgrade.go:447
msgid "D"
msgstr ""
@ -926,7 +926,7 @@ msgid ""
msgstr ""
#. translators: Short description for `man` command
#: cli/run.go:135
#: cli/run.go:159
msgid "Generate manpage"
msgstr "📒 Manual de uso"
@ -956,6 +956,17 @@ msgstr ""
msgid "HOST"
msgstr ""
#. translators: Short description for `help` command
#: cli/run.go:54
msgid "Help about any command"
msgstr ""
#: cli/run.go:55
msgid ""
"Help provides help for any command in the application.\n"
"Simply type abra help [path to command] for full details."
msgstr ""
#: cli/app/ps.go:187 cli/recipe/version.go:69
msgid "IMAGE"
msgstr ""
@ -1406,14 +1417,14 @@ msgid "The Co-op Cloud auto-updater 🤖 🚀"
msgstr "📨 Actualizador automático de Co-op Cloud 🤖 🚀"
#. translators: Short description for `abra` binary
#: cli/run.go:57
#: cli/run.go:80
msgid "The Co-op Cloud command-line utility belt 🎩🐇"
msgstr "La varita de mágica de Co-op Cloud 🪄🎩🐇"
#. translators: Long description for `abra` binary. This needs to be
#. translated in the same way as the Short description so that everything
#. matches up
#: cli/run.go:61
#: cli/run.go:84
#, fuzzy, c-format
msgid ""
"The Co-op Cloud command-line utility belt 🎩🐇\n"
@ -1800,7 +1811,7 @@ msgid "aborting as requested"
msgstr ""
#. translators: `abra` binary name
#: cli/run.go:55
#: cli/run.go:78
msgid "abra [cmd] [args] [flags]"
msgstr ""
@ -1808,7 +1819,7 @@ msgstr ""
msgid "abra app labels 1312.net"
msgstr ""
#: cli/run.go:114
#: cli/run.go:137
#, c-format
msgid "abra version: %s, commit: %s, lang: %s"
msgstr ""
@ -1885,7 +1896,7 @@ msgid "ambiguous service list received, prompting for input"
msgstr ""
#. translators: `abra app` command for autocompletion
#: cli/run.go:68
#: cli/run.go:91
msgid "app"
msgstr "plataforma"
@ -1927,7 +1938,7 @@ msgstr ""
msgid "attempting to run %s"
msgstr ""
#: cli/app/deploy.go:235 cli/app/upgrade.go:273
#: cli/app/deploy.go:238 cli/app/upgrade.go:273
#, c-format
msgid "attempting to run post deploy commands, saw: %s"
msgstr ""
@ -1943,7 +1954,7 @@ msgid "attempting to scale %s to 1"
msgstr ""
#. translators: `abra autocomplete` command for autocompletion
#: cli/run.go:70
#: cli/run.go:93
msgid "autocomplete"
msgstr ""
@ -2023,7 +2034,7 @@ msgstr ""
#. no spaces in between
#. translators: `abra app cp` aliases. use a comma separated list of aliases with
#. no spaces in between
#: cli/app/backup.go:148 cli/app/cp.go:30 cli/app/deploy.go:363
#: cli/app/backup.go:148 cli/app/cp.go:30 cli/app/deploy.go:366
#: cli/app/rollback.go:345 cli/app/upgrade.go:455
msgid "c"
msgstr ""
@ -2093,7 +2104,7 @@ msgstr ""
msgid "cannot use '[secret] [version]' and '--all' together"
msgstr ""
#: cli/app/deploy.go:274
#: cli/app/deploy.go:277
msgid "cannot use --chaos and --latest together"
msgstr ""
@ -2117,16 +2128,16 @@ msgstr ""
msgid "cannot use [service] and --all-services/-a together"
msgstr ""
#: cli/app/deploy.go:266 cli/app/new.go:76
#: cli/app/deploy.go:269 cli/app/new.go:76
msgid "cannot use [version] and --chaos together"
msgstr ""
#: cli/app/deploy.go:270
#: cli/app/deploy.go:273
msgid "cannot use [version] and --latest together"
msgstr ""
#. translators: `abra catalogue` command for autocompletion
#: cli/run.go:72
#: cli/run.go:95
msgid "catalogue"
msgstr ""
@ -2154,7 +2165,7 @@ msgid "cfg"
msgstr ""
#: cli/app/backup.go:318 cli/app/backup.go:334 cli/app/check.go:94
#: cli/app/cmd.go:284 cli/app/cp.go:384 cli/app/deploy.go:338
#: cli/app/cmd.go:284 cli/app/cp.go:384 cli/app/deploy.go:341
#: cli/app/labels.go:142 cli/app/new.go:376 cli/app/ps.go:212
#: cli/app/restart.go:161 cli/app/restore.go:137 cli/app/secret.go:568
#: cli/app/secret.go:608 cli/app/secret.go:632 cli/app/secret.go:640
@ -2512,7 +2523,7 @@ msgstr ""
msgid "deploy labels stanza present"
msgstr ""
#: cli/app/deploy.go:373
#: cli/app/deploy.go:376
#, fuzzy
msgid "deploy latest recipe version"
msgstr "Publicar una nueva versión de una receta"
@ -2590,11 +2601,11 @@ msgstr ""
msgid "dirty: %v, "
msgstr ""
#: cli/app/deploy.go:365 cli/app/rollback.go:347 cli/app/upgrade.go:457
#: cli/app/deploy.go:368 cli/app/rollback.go:347 cli/app/upgrade.go:457
msgid "disable converge logic checks"
msgstr ""
#: cli/app/deploy.go:357 cli/app/rollback.go:339 cli/app/upgrade.go:449
#: cli/app/deploy.go:360 cli/app/rollback.go:339 cli/app/upgrade.go:449
msgid "disable public DNS checks"
msgstr ""
@ -2623,7 +2634,7 @@ msgstr ""
msgid "domain name for app"
msgstr ""
#: cli/run.go:160
#: cli/run.go:184
msgid "don't forget to run 'sudo mandb'"
msgstr ""
@ -2839,7 +2850,7 @@ msgstr ""
#. translators: `abra recipe fetch` aliases. use a comma separated list of aliases
#. with no spaces in between
#: cli/app/deploy.go:347 cli/app/remove.go:163 cli/app/rollback.go:329
#: cli/app/deploy.go:350 cli/app/remove.go:163 cli/app/rollback.go:329
#: cli/app/secret.go:593 cli/app/upgrade.go:439 cli/app/volume.go:217
#: cli/recipe/fetch.go:20 cli/recipe/fetch.go:138
msgid "f"
@ -3077,7 +3088,7 @@ msgstr ""
msgid "for %s read env %s with value: %s from docker service"
msgstr ""
#: cli/app/deploy.go:346 cli/app/remove.go:162 cli/app/rollback.go:328
#: cli/app/deploy.go:349 cli/app/remove.go:162 cli/app/rollback.go:328
#: cli/app/upgrade.go:438 cli/app/volume.go:216 cli/recipe/fetch.go:137
msgid "force"
msgstr ""
@ -3250,6 +3261,10 @@ msgstr ""
msgid "git: opening repository in %s"
msgstr ""
#: cli/run.go:215
msgid "h"
msgstr ""
#: cli/recipe/new.go:94
msgid "happy hacking 🎉"
msgstr ""
@ -3266,6 +3281,19 @@ msgstr ""
msgid "healthcheck enabled for all services"
msgstr ""
#: cli/run.go:214
msgid "help"
msgstr ""
#: cli/run.go:52
#, fuzzy
msgid "help [command]"
msgstr "💻 Ejecutar comandos en una plataforma 🚀"
#: cli/run.go:217
msgid "help for abra"
msgstr ""
#: cli/app/restore.go:129
msgid "hooks"
msgstr ""
@ -3282,7 +3310,7 @@ msgid "id: %s, "
msgstr ""
#: cli/app/backup.go:321 cli/app/backup.go:337 cli/app/check.go:97
#: cli/app/cmd.go:287 cli/app/cp.go:387 cli/app/deploy.go:341
#: cli/app/cmd.go:287 cli/app/cp.go:387 cli/app/deploy.go:344
#: cli/app/labels.go:145 cli/app/new.go:379 cli/app/ps.go:215
#: cli/app/restart.go:164 cli/app/restore.go:140 cli/app/secret.go:571
#: cli/app/secret.go:611 cli/app/secret.go:635 cli/app/secret.go:643
@ -3482,8 +3510,8 @@ msgstr ""
#. no spaces in between
#. translators: `abra recipe lint` aliases. use a comma separated list of
#. aliases with no spaces in between
#: cli/app/cmd.go:261 cli/app/logs.go:20 cli/recipe/lint.go:17
#: cli/server/add.go:207
#: cli/app/cmd.go:261 cli/app/deploy.go:374 cli/app/logs.go:20
#: cli/recipe/lint.go:17 cli/server/add.go:207
msgid "l"
msgstr ""
@ -3492,7 +3520,7 @@ msgstr ""
msgid "labels <domain> [flags]"
msgstr "etiquetas <domain> [flags]"
#: cli/app/list.go:183
#: cli/app/deploy.go:373 cli/app/list.go:183
msgid "latest"
msgstr ""
@ -3619,7 +3647,7 @@ msgstr "plataformas"
#. with no spaces in between
#: cli/app/list.go:318 cli/app/move.go:34 cli/app/ps.go:205
#: cli/app/secret.go:553 cli/app/secret.go:649 cli/recipe/list.go:104
#: cli/recipe/upgrade.go:376 cli/recipe/version.go:139 cli/run.go:128
#: cli/recipe/upgrade.go:376 cli/recipe/version.go:139 cli/run.go:152
#: cli/server/list.go:106 cli/updater/updater.go:560
msgid "m"
msgstr ""
@ -3647,12 +3675,12 @@ msgid "malformed version pin specification: %s"
msgstr ""
#. translators: `abra man` command for autocompletion
#: cli/run.go:74
#: cli/run.go:97
msgid "man"
msgstr ""
#. translators: `man` command
#: cli/run.go:132
#: cli/run.go:156
msgid "man [flags]"
msgstr "manual [flags]"
@ -3694,9 +3722,8 @@ msgstr ""
#. translators: `app move` command
#: cli/app/move.go:38
#, fuzzy
msgid "move <domain> <server> [flags]"
msgstr "borrar <domain> [flags]"
msgstr "mover <domain> [flags]"
#: cli/app/move.go:137
#, c-format
@ -3716,7 +3743,7 @@ msgstr ""
#: cli/app/new.go:48 cli/recipe/new.go:36 cli/updater/updater.go:35
#: cli/updater/updater.go:513
msgid "n"
msgstr ""
msgstr "n"
#: cli/recipe/list.go:43
msgid "name"
@ -3967,11 +3994,11 @@ msgstr ""
msgid "no volumes to remove"
msgstr ""
#: cli/app/deploy.go:362 cli/app/rollback.go:344 cli/app/upgrade.go:454
#: cli/app/deploy.go:365 cli/app/rollback.go:344 cli/app/upgrade.go:454
msgid "no-converge-checks"
msgstr ""
#: cli/app/deploy.go:354 cli/app/rollback.go:336 cli/app/upgrade.go:446
#: cli/app/deploy.go:357 cli/app/rollback.go:336 cli/app/upgrade.go:446
msgid "no-domain-checks"
msgstr ""
@ -4115,7 +4142,7 @@ msgstr ""
msgid "pattern"
msgstr ""
#: cli/app/deploy.go:349 cli/app/remove.go:165 cli/app/rollback.go:331
#: cli/app/deploy.go:352 cli/app/remove.go:165 cli/app/rollback.go:331
#: cli/app/upgrade.go:441 cli/app/volume.go:219
msgid "perform action without further prompt"
msgstr ""
@ -4154,7 +4181,7 @@ msgstr ""
msgid "polling undeploy status"
msgstr "📋 Revisar el estado de una plataforma"
#: cli/run.go:185
#: cli/run.go:209
msgid "prefer offline & filesystem access"
msgstr ""
@ -4295,7 +4322,7 @@ msgid "readme: %s, "
msgstr ""
#. translators: `abra recipe` command for autocompletion
#: cli/app/list.go:302 cli/app/list.go:309 cli/run.go:76
#: cli/app/list.go:302 cli/app/list.go:309 cli/run.go:99
msgid "recipe"
msgstr ""
@ -4640,7 +4667,7 @@ msgstr ""
msgid "run command locally"
msgstr ""
#: cli/app/deploy.go:233 cli/app/upgrade.go:270
#: cli/app/deploy.go:236 cli/app/upgrade.go:270
#, c-format
msgid "run the following post-deploy commands: %s"
msgstr ""
@ -4724,7 +4751,7 @@ msgstr ""
msgid "secret not found: %s"
msgstr ""
#: cli/app/deploy.go:288
#: cli/app/deploy.go:291
#, c-format
msgid "secret not generated: %s"
msgstr ""
@ -4745,7 +4772,7 @@ msgstr ""
#. translators: `abra server` command for autocompletion
#: cli/app/list.go:325 cli/app/list.go:332 cli/app/new.go:337
#: cli/app/new.go:344 cli/run.go:78
#: cli/app/new.go:344 cli/run.go:101
msgid "server"
msgstr ""
@ -4863,7 +4890,7 @@ msgstr ""
msgid "show apps of a specific server"
msgstr ""
#: cli/run.go:169 cli/updater/updater.go:507
#: cli/run.go:193 cli/updater/updater.go:507
msgid "show debug messages"
msgstr ""
@ -4911,11 +4938,11 @@ msgstr ""
msgid "skipping converge logic checks"
msgstr ""
#: cli/app/deploy.go:186
#: cli/app/deploy.go:189
msgid "skipping domain checks"
msgstr ""
#: cli/app/deploy.go:183
#: cli/app/deploy.go:186
msgid "skipping domain checks, no DOMAIN=... configured"
msgstr ""
@ -5147,7 +5174,7 @@ msgstr ""
msgid "tmpfs options are incompatible with type volume"
msgstr ""
#: cli/run.go:177 cli/updater/updater.go:515
#: cli/run.go:201 cli/updater/updater.go:515
msgid "toggle non-interactive mode"
msgstr ""
@ -5232,7 +5259,7 @@ msgstr ""
msgid "unable to convert to JSON: %s"
msgstr ""
#: cli/run.go:94
#: cli/run.go:117
#, c-format
msgid "unable to create %s: %s"
msgstr ""
@ -5327,7 +5354,7 @@ msgstr ""
msgid "unable to parse '%s' value as bool: %s"
msgstr ""
#: cli/run.go:152
#: cli/run.go:176
#, c-format
msgid "unable to proceed, %s does not exist?"
msgstr ""
@ -5490,6 +5517,11 @@ msgstr ""
msgid "unknown deployed version, unable to upgrade"
msgstr ""
#: cli/run.go:60
#, c-format
msgid "unknown help topic %#q\n"
msgstr ""
#: pkg/upstream/convert/service.go:780
#, c-format
msgid "unknown mode: %s"
@ -5531,7 +5563,7 @@ msgid "updating %s to %s in %s"
msgstr ""
#. translators: `abra upgrade` command for autocompletion
#: cli/run.go:80
#: cli/run.go:103
msgid "upgrade"
msgstr ""
@ -5607,7 +5639,7 @@ msgstr ""
#. translators: `abra recipe versions` aliases. use a comma separated list of aliases
#. with no spaces in between
#: cli/app/backup.go:311 cli/app/restore.go:122 cli/recipe/version.go:19
#: cli/server/prune.go:107
#: cli/run.go:223 cli/server/prune.go:107
msgid "v"
msgstr ""
@ -5635,16 +5667,30 @@ msgstr ""
msgid "vendor config versions in an abra.sh"
msgstr ""
#: cli/run.go:222
msgid "version"
msgstr ""
#: pkg/app/app.go:688
#, c-format
msgid "version %s saved to %s.env"
msgstr ""
#: cli/app/deploy.go:116
#, c-format
msgid ""
"version '%s' appears to be a chaos commit, but --chaos/-C was not provided"
msgstr ""
#: pkg/recipe/recipe.go:200
#, c-format
msgid "version : %s, "
msgstr ""
#: cli/run.go:225
msgid "version for abra"
msgstr ""
#: pkg/recipe/recipe.go:130
#, c-format
msgid "version seems invalid: %s"
@ -5655,32 +5701,32 @@ msgstr ""
msgid "version wiped from %s.env"
msgstr ""
#: cli/app/deploy.go:315
#: cli/app/deploy.go:318
#, c-format
msgid "version: can not redeploy chaos version %s"
msgstr ""
#: cli/app/deploy.go:302
#: cli/app/deploy.go:305
#, c-format
msgid "version: taking chaos version: %s"
msgstr ""
#: cli/app/deploy.go:323
#: cli/app/deploy.go:326
#, c-format
msgid "version: taking deployed version: %s"
msgstr ""
#: cli/app/deploy.go:328
#: cli/app/deploy.go:331
#, c-format
msgid "version: taking new recipe version: %s"
msgstr ""
#: cli/app/deploy.go:317
#: cli/app/deploy.go:320
#, c-format
msgid "version: taking version from .env file: %s"
msgstr ""
#: cli/app/deploy.go:308
#: cli/app/deploy.go:311
#, c-format
msgid "version: taking version from cli arg: %s"
msgstr ""
@ -5806,7 +5852,7 @@ msgstr ""
msgid "writer: %v, "
msgstr ""
#: cli/app/deploy.go:240 cli/app/new.go:221 cli/app/rollback.go:232
#: cli/app/deploy.go:243 cli/app/new.go:221 cli/app/rollback.go:232
#: cli/app/undeploy.go:111 cli/app/upgrade.go:278
#, c-format
msgid "writing recipe version failed: %s"

View File

@ -280,7 +280,7 @@ type secretStatus struct {
type secretStatuses []secretStatus
// PollSecretsStatus checks status of secrets by comparing the local recipe
// config and deployed server state.
// config and deploymend server state.
func PollSecretsStatus(cl *dockerClient.Client, app appPkg.App) (secretStatuses, error) {
var secStats secretStatuses
@ -306,7 +306,7 @@ func PollSecretsStatus(cl *dockerClient.Client, app appPkg.App) (secretStatuses,
remoteSecretNames := make(map[string]bool)
for _, cont := range secretList {
remoteSecretNames[cont.Spec.Name] = true
remoteSecretNames[cont.Spec.Annotations.Name] = true
}
for secretName, val := range secretsConfig {

View File

@ -174,6 +174,23 @@ teardown(){
assert_output --partial "${wantHash:0:8}"
}
# bats test_tags=slow
@test "bail if env has a hash but no --chaos" {
wantHash=$(_get_n_hash 3)
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
assert_success
assert_equal $(_get_current_hash) "$wantHash"
_ensure_env_version "$wantHash"
run $ABRA app deploy "$TEST_APP_DOMAIN" \
--no-input --no-converge-checks
assert_failure
assert_output --partial "chaos commit"
}
# bats test_tags=slow
@test "retrieve recipe if missing" {
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"

View File

@ -19,11 +19,18 @@ teardown_file(){
_rm_app
_rm_server
_reset_recipe
# NOTE(d1): fallback cleanup, not interested in failures here
run docker secret rm "${TEST_APP_DOMAIN}_test_pass_one_v1"
rm -rf "${BATS_TMPFILE}"
}
setup(){
load "$PWD/tests/integration/helpers/common"
_common_setup
export BATS_TMPFILE="$(mktemp)"
echo MySuperCoolPassword > ${BATS_TMPFILE}
}
teardown(){
@ -324,6 +331,41 @@ teardown(){
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
}
@test "rm: dont remove all versions" {
run sed -i 's/SECRET_TEST_PASS_ONE_VERSION=v1/SECRET_TEST_PASS_ONE_VERSION=v2/g' \
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
assert_success
run $ABRA app secret ls "$TEST_APP_DOMAIN"
assert_success
assert_output --partial 'test_pass_one_v2'
assert_output --partial 'true'
run docker secret create "${TEST_APP_DOMAIN}_test_pass_one_v1" "$BATS_TMPFILE"
assert_success
run docker secret ls
assert_success
assert_output --partial "${TEST_APP_DOMAIN}_test_pass_one_v1"
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
assert_success
run $ABRA app secret ls "$TEST_APP_DOMAIN"
assert_success
assert_output --partial 'false'
run docker secret ls
assert_success
assert_output --partial "${TEST_APP_DOMAIN}_test_pass_one_v1"
run docker secret rm "${TEST_APP_DOMAIN}_test_pass_one_v1"
assert_success
}
@test "ls: validate arguments" {
run $ABRA app secret ls
assert_failure

View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
setup_file(){
load "$PWD/tests/integration/helpers/common"
_common_setup
}
setup(){
load "$PWD/tests/integration/helpers/common"
_common_setup
}
@test "autocomplete output works" {
run $ABRA autocomplete bash
assert_success
run $ABRA autocomplete fish
assert_success
run $ABRA autocomplete zsh
assert_success
run $ABRA autocomplete powershell
assert_success
}

View File

@ -30,7 +30,7 @@ _ensure_catalogue(){
}
_ensure_env_version(){
run sed -i 's/TYPE=abra-test-recipe:.*/TYPE=abra-test-recipe:$1/g' \
run sed -i "s/TYPE=abra-test-recipe:.*/TYPE=abra-test-recipe:$1/g" \
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success
}