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,
compose *composetypes.Config,
appEnv envfile.AppEnv,
toDeployVersion string) {
toDeployVersion string,
) {
for _, service := range compose.Services {
if service.Name == "app" {
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.
func (a App) WriteRecipeVersion(version string, dryRun bool) error {
if a.Recipe.Local {
return nil
}
file, err := os.Open(a.Path)
if err != nil {
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))
}
// When the docker context does not exist but the server folder is
// there, let's create a new docker context.
err = CreateContext(serverName)
if err != nil {
// NOTE(p4u1): when the docker context does not exist but the server folder
// is there, let's create a new docker context.
if err = CreateContext(serverName); err != nil {
return nil, errors.New(i18n.G("server missing context, context creation failed: %s", err))
}

View File

@ -7,7 +7,7 @@
msgid ""
msgstr "Project-Id-Version: \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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -2291,7 +2291,7 @@ msgstr ""
msgid "create remote directory: %s"
msgstr ""
#: ./pkg/client/client.go:102
#: ./pkg/client/client.go:111
#, c-format
msgid "created client for %s"
msgstr ""
@ -4651,11 +4651,21 @@ msgstr ""
msgid "server doesn't exist?"
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
msgid "server missing context, run \"abra server add %s\"?"
msgstr ""
#: ./pkg/client/client.go:48
#, c-format
msgid "server missing, run \"abra server add %s\"?"
msgstr ""
#: ./cli/server/add.go:148
#, c-format
msgid "serverAdd: cleanUp: %s is not empty, aborting cleanup"
@ -4931,12 +4941,12 @@ msgstr ""
msgid "successfully created %s"
msgstr ""
#: ./pkg/client/client.go:111
#: ./pkg/client/client.go:120
#, c-format
msgid "swarm mode not enabled on %s?"
msgstr ""
#: ./pkg/client/client.go:114
#: ./pkg/client/client.go:123
msgid "swarm mode not enabled on local server?"
msgstr ""
@ -5435,11 +5445,6 @@ msgstr ""
msgid "unknown server %s, run \"abra server add %s\"?"
msgstr ""
#: ./pkg/client/client.go:51
#, c-format
msgid "unknown server, run \"abra server add %s\"?"
msgstr ""
#: ./cli/app/cp.go:259
#, c-format
msgid "untar: %s"

View File

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \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"
"Last-Translator: chasqui <chasqui@cryptolab.net>\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"
msgstr ""
#: pkg/client/client.go:102
#: pkg/client/client.go:111
#, c-format
msgid "created client for %s"
msgstr ""
@ -4774,11 +4774,21 @@ msgstr ""
msgid "server doesn't exist?"
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
msgid "server missing context, run \"abra server add %s\"?"
msgstr ""
#: pkg/client/client.go:48
#, c-format
msgid "server missing, run \"abra server add %s\"?"
msgstr ""
#: cli/server/add.go:148
#, c-format
msgid "serverAdd: cleanUp: %s is not empty, aborting cleanup"
@ -5054,12 +5064,12 @@ msgstr ""
msgid "successfully created %s"
msgstr ""
#: pkg/client/client.go:111
#: pkg/client/client.go:120
#, c-format
msgid "swarm mode not enabled on %s?"
msgstr ""
#: pkg/client/client.go:114
#: pkg/client/client.go:123
msgid "swarm mode not enabled on local server?"
msgstr ""
@ -5565,11 +5575,6 @@ msgstr ""
msgid "unknown server %s, run \"abra server add %s\"?"
msgstr ""
#: pkg/client/client.go:51
#, c-format
msgid "unknown server, run \"abra server add %s\"?"
msgstr ""
#: cli/app/cp.go:259
#, c-format
msgid "untar: %s"

View File

@ -486,6 +486,10 @@ func LintSecretLengths(recipe recipe.Recipe) (bool, error) {
}
func LintValidTags(recipe recipe.Recipe) (bool, error) {
if recipe.Local {
return true, nil
}
repo, err := git.PlainOpen(recipe.Dir)
if err != nil {
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
// version checked out.
func (r Recipe) Ensure(ctx EnsureContext) error {
if r.Local {
return nil
}
if err := r.EnsureExists(); err != nil {
return err
}
@ -68,6 +72,10 @@ func (r Recipe) Ensure(ctx EnsureContext) error {
// EnsureExists ensures that the recipe is locally cloned
func (r Recipe) EnsureExists() error {
if r.Local {
return nil
}
if _, err := os.Stat(r.Dir); os.IsNotExist(err) {
if err := gitPkg.Clone(r.Dir, r.GitURL); err != nil {
return err
@ -83,6 +91,10 @@ func (r Recipe) EnsureExists() error {
// IsChaosCommit determines if a version sttring is a chaos commit or not.
func (r Recipe) IsChaosCommit(version string) (bool, error) {
if r.Local {
return false, nil
}
isChaosCommit := false
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.
func (r Recipe) EnsureVersion(version string) (bool, error) {
if r.Local {
return false, nil
}
isChaosCommit := false
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.
func (r Recipe) EnsureIsClean() error {
if r.Local {
return nil
}
isClean, err := gitPkg.IsClean(r.Dir)
if err != nil {
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
func (r Recipe) EnsureLatest() error {
if r.Local {
return nil
}
if err := gitPkg.EnsureGitRepo(r.Dir); err != nil {
return err
}
@ -231,6 +255,10 @@ func (r Recipe) EnsureLatest() error {
// EnsureUpToDate ensures that the local repo is synced to the remote
func (r Recipe) EnsureUpToDate() error {
if r.Local {
return nil
}
repo, err := git.PlainOpen(r.Dir)
if err != nil {
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.
func (r *Recipe) IsDirty() (bool, error) {
if r.Local {
return false, nil
}
isClean, err := gitPkg.IsClean(r.Dir)
if err != nil {
return false, err
@ -292,6 +324,10 @@ func (r *Recipe) IsDirty() (bool, error) {
// ChaosVersion constructs a chaos mode recipe version.
func (r *Recipe) ChaosVersion() (string, error) {
if r.Local {
return "", nil
}
var version string
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
// local SSH configuration for git.coopcloud.tech working for this to work
func (r Recipe) Push(dryRun bool) error {
if r.Local {
return nil
}
repo, err := git.PlainOpen(r.Dir)
if err != nil {
return err
@ -333,6 +373,10 @@ func (r Recipe) Push(dryRun bool) error {
// Tags list the recipe tags
func (r Recipe) Tags() ([]string, error) {
if r.Local {
return nil, nil
}
var tags []string
repo, err := git.PlainOpen(r.Dir)
@ -371,6 +415,10 @@ func (r Recipe) Tags() ([]string, error) {
// GetRecipeVersions retrieves all recipe versions.
func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) {
if r.Local {
return nil, nil, nil
}
var warnMsg []string
versions := RecipeVersions{}

View File

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