0
0
forked from toolshed/abra

Compare commits

..

4 Commits

Author SHA1 Message Date
8cbf118f66 feat: introduce local recipes 2025-11-04 09:18:29 +01:00
cc8703310c chore: update translation files
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-11-04 07:35:14 +00:00
fcd5bd863d chore: make i18n 2025-11-04 08:35:04 +01:00
e6af2da9dd refactor: named note, merge if clause 2025-11-04 08:34:49 +01:00
7 changed files with 130 additions and 53 deletions

View File

@ -506,7 +506,8 @@ func ExposeAllEnv(
stackName string, stackName string,
compose *composetypes.Config, compose *composetypes.Config,
appEnv envfile.AppEnv, appEnv envfile.AppEnv,
toDeployVersion string) { toDeployVersion string,
) {
for _, service := range compose.Services { for _, service := range compose.Services {
if service.Name == "app" { if service.Name == "app" {
log.Debug(i18n.G("adding env vars to %s service config", stackName)) log.Debug(i18n.G("adding env vars to %s service config", stackName))
@ -633,6 +634,10 @@ func (a App) WipeRecipeVersion() error {
// WriteRecipeVersion writes the recipe version to the app .env file. // WriteRecipeVersion writes the recipe version to the app .env file.
func (a App) WriteRecipeVersion(version string, dryRun bool) error { func (a App) WriteRecipeVersion(version string, dryRun bool) error {
if a.Recipe.Local {
return nil
}
file, err := os.Open(a.Path) file, err := os.Open(a.Path)
if err != nil { if err != nil {
return err return err

View File

@ -48,10 +48,9 @@ func New(serverName string, opts ...Opt) (*client.Client, error) {
return nil, errors.New(i18n.G("server missing, run \"abra server add %s\"?", serverName)) return nil, errors.New(i18n.G("server missing, run \"abra server add %s\"?", serverName))
} }
// When the docker context does not exist but the server folder is // NOTE(p4u1): when the docker context does not exist but the server folder
// there, let's create a new docker context. // is there, let's create a new docker context.
err = CreateContext(serverName) if err = CreateContext(serverName); err != nil {
if err != nil {
return nil, errors.New(i18n.G("server missing context, context creation failed: %s", err)) return nil, errors.New(i18n.G("server missing context, context creation failed: %s", err))
} }

View File

@ -7,7 +7,7 @@
msgid "" msgid ""
msgstr "Project-Id-Version: \n" msgstr "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL\n" "Report-Msgid-Bugs-To: EMAIL\n"
"POT-Creation-Date: 2025-11-02 11:41+0100\n" "POT-Creation-Date: 2025-11-04 08:35+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -2291,7 +2291,7 @@ msgstr ""
msgid "create remote directory: %s" msgid "create remote directory: %s"
msgstr "" msgstr ""
#: ./pkg/client/client.go:102 #: ./pkg/client/client.go:111
#, c-format #, c-format
msgid "created client for %s" msgid "created client for %s"
msgstr "" msgstr ""
@ -4651,11 +4651,21 @@ msgstr ""
msgid "server doesn't exist?" msgid "server doesn't exist?"
msgstr "" msgstr ""
#: ./pkg/client/client.go:48 #: ./pkg/client/client.go:54
#, c-format
msgid "server missing context, context creation failed: %s"
msgstr ""
#: ./pkg/client/client.go:59
#, c-format #, c-format
msgid "server missing context, run \"abra server add %s\"?" msgid "server missing context, run \"abra server add %s\"?"
msgstr "" msgstr ""
#: ./pkg/client/client.go:48
#, c-format
msgid "server missing, run \"abra server add %s\"?"
msgstr ""
#: ./cli/server/add.go:148 #: ./cli/server/add.go:148
#, c-format #, c-format
msgid "serverAdd: cleanUp: %s is not empty, aborting cleanup" msgid "serverAdd: cleanUp: %s is not empty, aborting cleanup"
@ -4931,12 +4941,12 @@ msgstr ""
msgid "successfully created %s" msgid "successfully created %s"
msgstr "" msgstr ""
#: ./pkg/client/client.go:111 #: ./pkg/client/client.go:120
#, c-format #, c-format
msgid "swarm mode not enabled on %s?" msgid "swarm mode not enabled on %s?"
msgstr "" msgstr ""
#: ./pkg/client/client.go:114 #: ./pkg/client/client.go:123
msgid "swarm mode not enabled on local server?" msgid "swarm mode not enabled on local server?"
msgstr "" msgstr ""
@ -5435,11 +5445,6 @@ msgstr ""
msgid "unknown server %s, run \"abra server add %s\"?" msgid "unknown server %s, run \"abra server add %s\"?"
msgstr "" msgstr ""
#: ./pkg/client/client.go:51
#, c-format
msgid "unknown server, run \"abra server add %s\"?"
msgstr ""
#: ./cli/app/cp.go:259 #: ./cli/app/cp.go:259
#, c-format #, c-format
msgid "untar: %s" msgid "untar: %s"

View File

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL\n" "Report-Msgid-Bugs-To: EMAIL\n"
"POT-Creation-Date: 2025-11-02 11:41+0100\n" "POT-Creation-Date: 2025-11-04 08:35+0100\n"
"PO-Revision-Date: 2025-09-04 08:14+0000\n" "PO-Revision-Date: 2025-09-04 08:14+0000\n"
"Last-Translator: chasqui <chasqui@cryptolab.net>\n" "Last-Translator: chasqui <chasqui@cryptolab.net>\n"
"Language-Team: Spanish <https://translate.coopcloud.tech/projects/co-op-cloud/abra/es/>\n" "Language-Team: Spanish <https://translate.coopcloud.tech/projects/co-op-cloud/abra/es/>\n"
@ -2363,7 +2363,7 @@ msgstr ""
msgid "create remote directory: %s" msgid "create remote directory: %s"
msgstr "" msgstr ""
#: pkg/client/client.go:102 #: pkg/client/client.go:111
#, c-format #, c-format
msgid "created client for %s" msgid "created client for %s"
msgstr "" msgstr ""
@ -4774,11 +4774,21 @@ msgstr ""
msgid "server doesn't exist?" msgid "server doesn't exist?"
msgstr "" msgstr ""
#: pkg/client/client.go:48 #: pkg/client/client.go:54
#, c-format
msgid "server missing context, context creation failed: %s"
msgstr ""
#: pkg/client/client.go:59
#, c-format #, c-format
msgid "server missing context, run \"abra server add %s\"?" msgid "server missing context, run \"abra server add %s\"?"
msgstr "" msgstr ""
#: pkg/client/client.go:48
#, c-format
msgid "server missing, run \"abra server add %s\"?"
msgstr ""
#: cli/server/add.go:148 #: cli/server/add.go:148
#, c-format #, c-format
msgid "serverAdd: cleanUp: %s is not empty, aborting cleanup" msgid "serverAdd: cleanUp: %s is not empty, aborting cleanup"
@ -5054,12 +5064,12 @@ msgstr ""
msgid "successfully created %s" msgid "successfully created %s"
msgstr "" msgstr ""
#: pkg/client/client.go:111 #: pkg/client/client.go:120
#, c-format #, c-format
msgid "swarm mode not enabled on %s?" msgid "swarm mode not enabled on %s?"
msgstr "" msgstr ""
#: pkg/client/client.go:114 #: pkg/client/client.go:123
msgid "swarm mode not enabled on local server?" msgid "swarm mode not enabled on local server?"
msgstr "" msgstr ""
@ -5565,11 +5575,6 @@ msgstr ""
msgid "unknown server %s, run \"abra server add %s\"?" msgid "unknown server %s, run \"abra server add %s\"?"
msgstr "" msgstr ""
#: pkg/client/client.go:51
#, c-format
msgid "unknown server, run \"abra server add %s\"?"
msgstr ""
#: cli/app/cp.go:259 #: cli/app/cp.go:259
#, c-format #, c-format
msgid "untar: %s" msgid "untar: %s"

View File

@ -486,6 +486,10 @@ func LintSecretLengths(recipe recipe.Recipe) (bool, error) {
} }
func LintValidTags(recipe recipe.Recipe) (bool, error) { func LintValidTags(recipe recipe.Recipe) (bool, error) {
if recipe.Local {
return true, nil
}
repo, err := git.PlainOpen(recipe.Dir) repo, err := git.PlainOpen(recipe.Dir)
if err != nil { if err != nil {
return false, errors.New(i18n.G("unable to open %s: %s", recipe.Dir, err)) return false, errors.New(i18n.G("unable to open %s: %s", recipe.Dir, err))

View File

@ -28,6 +28,10 @@ type EnsureContext struct {
// Ensure makes sure the recipe exists, is up to date and has the specific // Ensure makes sure the recipe exists, is up to date and has the specific
// version checked out. // version checked out.
func (r Recipe) Ensure(ctx EnsureContext) error { func (r Recipe) Ensure(ctx EnsureContext) error {
if r.Local {
return nil
}
if err := r.EnsureExists(); err != nil { if err := r.EnsureExists(); err != nil {
return err return err
} }
@ -68,6 +72,10 @@ func (r Recipe) Ensure(ctx EnsureContext) error {
// EnsureExists ensures that the recipe is locally cloned // EnsureExists ensures that the recipe is locally cloned
func (r Recipe) EnsureExists() error { func (r Recipe) EnsureExists() error {
if r.Local {
return nil
}
if _, err := os.Stat(r.Dir); os.IsNotExist(err) { if _, err := os.Stat(r.Dir); os.IsNotExist(err) {
if err := gitPkg.Clone(r.Dir, r.GitURL); err != nil { if err := gitPkg.Clone(r.Dir, r.GitURL); err != nil {
return err return err
@ -83,6 +91,10 @@ func (r Recipe) EnsureExists() error {
// IsChaosCommit determines if a version sttring is a chaos commit or not. // IsChaosCommit determines if a version sttring is a chaos commit or not.
func (r Recipe) IsChaosCommit(version string) (bool, error) { func (r Recipe) IsChaosCommit(version string) (bool, error) {
if r.Local {
return false, nil
}
isChaosCommit := false isChaosCommit := false
if err := gitPkg.EnsureGitRepo(r.Dir); err != nil { if err := gitPkg.EnsureGitRepo(r.Dir); err != nil {
@ -118,6 +130,10 @@ func (r Recipe) IsChaosCommit(version string) (bool, error) {
// EnsureVersion checks whether a specific version exists for a recipe. // EnsureVersion checks whether a specific version exists for a recipe.
func (r Recipe) EnsureVersion(version string) (bool, error) { func (r Recipe) EnsureVersion(version string) (bool, error) {
if r.Local {
return false, nil
}
isChaosCommit := false isChaosCommit := false
if err := gitPkg.EnsureGitRepo(r.Dir); err != nil { if err := gitPkg.EnsureGitRepo(r.Dir); err != nil {
@ -182,6 +198,10 @@ func (r Recipe) EnsureVersion(version string) (bool, error) {
// EnsureIsClean makes sure that the recipe repository has no unstaged changes. // EnsureIsClean makes sure that the recipe repository has no unstaged changes.
func (r Recipe) EnsureIsClean() error { func (r Recipe) EnsureIsClean() error {
if r.Local {
return nil
}
isClean, err := gitPkg.IsClean(r.Dir) isClean, err := gitPkg.IsClean(r.Dir)
if err != nil { if err != nil {
return errors.New(i18n.G("unable to check git clean status in %s: %s", r.Dir, err)) return errors.New(i18n.G("unable to check git clean status in %s: %s", r.Dir, err))
@ -196,6 +216,10 @@ func (r Recipe) EnsureIsClean() error {
// EnsureLatest makes sure the latest commit is checked out for the local recipe repository // EnsureLatest makes sure the latest commit is checked out for the local recipe repository
func (r Recipe) EnsureLatest() error { func (r Recipe) EnsureLatest() error {
if r.Local {
return nil
}
if err := gitPkg.EnsureGitRepo(r.Dir); err != nil { if err := gitPkg.EnsureGitRepo(r.Dir); err != nil {
return err return err
} }
@ -231,6 +255,10 @@ func (r Recipe) EnsureLatest() error {
// EnsureUpToDate ensures that the local repo is synced to the remote // EnsureUpToDate ensures that the local repo is synced to the remote
func (r Recipe) EnsureUpToDate() error { func (r Recipe) EnsureUpToDate() error {
if r.Local {
return nil
}
repo, err := git.PlainOpen(r.Dir) repo, err := git.PlainOpen(r.Dir)
if err != nil { if err != nil {
return errors.New(i18n.G("unable to open %s: %s", r.Dir, err)) return errors.New(i18n.G("unable to open %s: %s", r.Dir, err))
@ -282,6 +310,10 @@ func (r Recipe) EnsureUpToDate() error {
// IsDirty checks whether a recipe is dirty or not. // IsDirty checks whether a recipe is dirty or not.
func (r *Recipe) IsDirty() (bool, error) { func (r *Recipe) IsDirty() (bool, error) {
if r.Local {
return false, nil
}
isClean, err := gitPkg.IsClean(r.Dir) isClean, err := gitPkg.IsClean(r.Dir)
if err != nil { if err != nil {
return false, err return false, err
@ -292,6 +324,10 @@ func (r *Recipe) IsDirty() (bool, error) {
// ChaosVersion constructs a chaos mode recipe version. // ChaosVersion constructs a chaos mode recipe version.
func (r *Recipe) ChaosVersion() (string, error) { func (r *Recipe) ChaosVersion() (string, error) {
if r.Local {
return "", nil
}
var version string var version string
head, err := r.Head() head, err := r.Head()
@ -315,6 +351,10 @@ func (r *Recipe) ChaosVersion() (string, error) {
// Push pushes the latest changes to a SSH URL remote. You need to have your // Push pushes the latest changes to a SSH URL remote. You need to have your
// local SSH configuration for git.coopcloud.tech working for this to work // local SSH configuration for git.coopcloud.tech working for this to work
func (r Recipe) Push(dryRun bool) error { func (r Recipe) Push(dryRun bool) error {
if r.Local {
return nil
}
repo, err := git.PlainOpen(r.Dir) repo, err := git.PlainOpen(r.Dir)
if err != nil { if err != nil {
return err return err
@ -333,6 +373,10 @@ func (r Recipe) Push(dryRun bool) error {
// Tags list the recipe tags // Tags list the recipe tags
func (r Recipe) Tags() ([]string, error) { func (r Recipe) Tags() ([]string, error) {
if r.Local {
return nil, nil
}
var tags []string var tags []string
repo, err := git.PlainOpen(r.Dir) repo, err := git.PlainOpen(r.Dir)
@ -371,6 +415,10 @@ func (r Recipe) Tags() ([]string, error) {
// GetRecipeVersions retrieves all recipe versions. // GetRecipeVersions retrieves all recipe versions.
func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) { func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) {
if r.Local {
return nil, nil, nil
}
var warnMsg []string var warnMsg []string
versions := RecipeVersions{} versions := RecipeVersions{}

View File

@ -124,6 +124,14 @@ type Features struct {
func Get(name string) Recipe { func Get(name string) Recipe {
version := "" version := ""
versionRaw := "" versionRaw := ""
gitURL := ""
sshURL := ""
dir := ""
local := false
if strings.HasPrefix(name, "./") {
dir = path.Join(config.ABRA_DIR, name)
local = true
} else {
if strings.Contains(name, ":") { if strings.Contains(name, ":") {
split := strings.Split(name, ":") split := strings.Split(name, ":")
if len(split) > 2 { if len(split) > 2 {
@ -139,8 +147,8 @@ func Get(name string) Recipe {
} }
} }
gitURL := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, name) gitURL = fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, name)
sshURL := fmt.Sprintf(config.RECIPES_SSH_URL_TEMPLATE, name) sshURL = fmt.Sprintf(config.RECIPES_SSH_URL_TEMPLATE, name)
if strings.Contains(name, "/") { if strings.Contains(name, "/") {
u, err := url.Parse(name) u, err := url.Parse(name)
if err != nil { if err != nil {
@ -154,7 +162,8 @@ func Get(name string) Recipe {
sshURL = u.String() + ".git" sshURL = u.String() + ".git"
} }
dir := path.Join(config.RECIPES_DIR, escapeRecipeName(name)) dir = path.Join(config.RECIPES_DIR, escapeRecipeName(name))
}
r := Recipe{ r := Recipe{
Name: name, Name: name,
@ -163,6 +172,7 @@ func Get(name string) Recipe {
Dir: dir, Dir: dir,
GitURL: gitURL, GitURL: gitURL,
SSHURL: sshURL, SSHURL: sshURL,
Local: local,
ComposePath: path.Join(dir, "compose.yml"), ComposePath: path.Join(dir, "compose.yml"),
ReadmePath: path.Join(dir, "README.md"), ReadmePath: path.Join(dir, "README.md"),
@ -187,6 +197,7 @@ type Recipe struct {
Dir string Dir string
GitURL string GitURL string
SSHURL string SSHURL string
Local bool
ComposePath string ComposePath string
ReadmePath string ReadmePath string