diff --git a/cli/app/backup.go b/cli/app/backup.go index 4208bcf2..cfe4be86 100644 --- a/cli/app/backup.go +++ b/cli/app/backup.go @@ -38,7 +38,7 @@ var appBackupCommand = &cli.Command{ internal.ShowSubcommandHelpAndError(c, errors.New("cannot use '' and '--all' together")) } - abraSh := path.Join(config.ABRA_DIR, "apps", app.Type, "abra.sh") + abraSh := path.Join(config.RECIPES_DIR, app.Type, "abra.sh") if _, err := os.Stat(abraSh); err != nil { if os.IsNotExist(err) { logrus.Fatalf("%s does not exist?", abraSh) diff --git a/cli/app/check.go b/cli/app/check.go index 78a6fcc0..14e64223 100644 --- a/cli/app/check.go +++ b/cli/app/check.go @@ -20,7 +20,7 @@ var appCheckCommand = &cli.Command{ Action: func(c *cli.Context) error { app := internal.ValidateApp(c) - envSamplePath := path.Join(config.ABRA_DIR, "apps", app.Type, ".env.sample") + envSamplePath := path.Join(config.RECIPES_DIR, app.Type, ".env.sample") if _, err := os.Stat(envSamplePath); err != nil { if os.IsNotExist(err) { logrus.Fatalf("%s does not exist?", envSamplePath) diff --git a/cli/app/restore.go b/cli/app/restore.go index 5d016c2f..acf59983 100644 --- a/cli/app/restore.go +++ b/cli/app/restore.go @@ -37,7 +37,7 @@ var appRestoreCommand = &cli.Command{ internal.ShowSubcommandHelpAndError(c, errors.New("cannot use / and '--all' together")) } - abraSh := path.Join(config.ABRA_DIR, "apps", app.Type, "abra.sh") + abraSh := path.Join(config.RECIPES_DIR, app.Type, "abra.sh") if _, err := os.Stat(abraSh); err != nil { if os.IsNotExist(err) { logrus.Fatalf("%s does not exist?", abraSh) diff --git a/cli/app/rollback.go b/cli/app/rollback.go index 690f82c2..d5ea800d 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -135,7 +135,7 @@ recipes. } } - abraShPath := fmt.Sprintf("%s/%s/%s", config.APPS_DIR, app.Type, "abra.sh") + abraShPath := fmt.Sprintf("%s/%s/%s", config.RECIPES_DIR, app.Type, "abra.sh") abraShEnv, err := config.ReadAbraShEnvVars(abraShPath) if err != nil { logrus.Fatal(err) diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index 463c2c48..7db4b1a1 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -138,7 +138,7 @@ recipes. } } - abraShPath := fmt.Sprintf("%s/%s/%s", config.APPS_DIR, app.Type, "abra.sh") + abraShPath := fmt.Sprintf("%s/%s/%s", config.RECIPES_DIR, app.Type, "abra.sh") abraShEnv, err := config.ReadAbraShEnvVars(abraShPath) if err != nil { logrus.Fatal(err) diff --git a/cli/catalogue/catalogue.go b/cli/catalogue/catalogue.go index 2ded57b7..cb38c3f9 100644 --- a/cli/catalogue/catalogue.go +++ b/cli/catalogue/catalogue.go @@ -130,7 +130,7 @@ A new catalogue copy can be published to the recipes repository by passing the return } - recipeDir := path.Join(config.ABRA_DIR, "apps", rm.Name) + recipeDir := path.Join(config.RECIPES_DIR, rm.Name) if err := gitPkg.Clone(recipeDir, rm.SSHURL); err != nil { logrus.Fatal(err) @@ -200,8 +200,8 @@ A new catalogue copy can be published to the recipes repository by passing the logrus.Fatal(err) } - if _, err := os.Stat(config.APPS_JSON); err != nil && os.IsNotExist(err) { - if err := ioutil.WriteFile(config.APPS_JSON, recipesJSON, 0764); err != nil { + if _, err := os.Stat(config.RECIPES_JSON); err != nil && os.IsNotExist(err) { + if err := ioutil.WriteFile(config.RECIPES_JSON, recipesJSON, 0764); err != nil { logrus.Fatal(err) } } else { @@ -216,13 +216,13 @@ A new catalogue copy can be published to the recipes repository by passing the if err != nil { logrus.Fatal(err) } - if err := ioutil.WriteFile(config.APPS_JSON, updatedRecipesJSON, 0764); err != nil { + if err := ioutil.WriteFile(config.RECIPES_JSON, updatedRecipesJSON, 0764); err != nil { logrus.Fatal(err) } } } - logrus.Infof("generated new recipe catalogue in %s", config.APPS_JSON) + logrus.Infof("generated new recipe catalogue in %s", config.RECIPES_JSON) if internal.Commit { if internal.CommitMessage == "" && !internal.NoInput { diff --git a/cli/cli.go b/cli/cli.go index 9423bd2b..3cac259a 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -71,9 +71,9 @@ convenient command-line experience. See "abra autocomplete -h" for more. paths := []string{ config.ABRA_DIR, - path.Join(config.ABRA_DIR, "servers"), - path.Join(config.ABRA_DIR, "apps"), - path.Join(config.ABRA_DIR, "vendor"), + path.Join(config.SERVERS_DIR), + path.Join(config.RECIPES_DIR), + path.Join(config.VENDOR_DIR), } for _, path := range paths { diff --git a/cli/internal/deploy.go b/cli/internal/deploy.go index 4d464baa..a01e50da 100644 --- a/cli/internal/deploy.go +++ b/cli/internal/deploy.go @@ -93,7 +93,7 @@ func DeployAction(c *cli.Context) error { } } - abraShPath := fmt.Sprintf("%s/%s/%s", config.APPS_DIR, app.Type, "abra.sh") + abraShPath := fmt.Sprintf("%s/%s/%s", config.RECIPES_DIR, app.Type, "abra.sh") abraShEnv, err := config.ReadAbraShEnvVars(abraShPath) if err != nil { logrus.Fatal(err) diff --git a/cli/recipe/lint.go b/cli/recipe/lint.go index af3d308f..07cda681 100644 --- a/cli/recipe/lint.go +++ b/cli/recipe/lint.go @@ -29,7 +29,7 @@ var recipeLintCommand = &cli.Command{ } envSampleProvided := false - envSample := fmt.Sprintf("%s/%s/.env.sample", config.APPS_DIR, recipe.Name) + envSample := fmt.Sprintf("%s/%s/.env.sample", config.RECIPES_DIR, recipe.Name) if _, err := os.Stat(envSample); !os.IsNotExist(err) { envSampleProvided = true } else if err != nil { diff --git a/cli/recipe/new.go b/cli/recipe/new.go index 162e722f..7dbd19f7 100644 --- a/cli/recipe/new.go +++ b/cli/recipe/new.go @@ -39,7 +39,7 @@ The new example repository is cloned to ~/.abra/apps/. internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided")) } - directory := path.Join(config.APPS_DIR, recipeName) + directory := path.Join(config.RECIPES_DIR, recipeName) if _, err := os.Stat(directory); !os.IsNotExist(err) { logrus.Fatalf("%s recipe directory already exists?", directory) } @@ -49,16 +49,16 @@ The new example repository is cloned to ~/.abra/apps/. logrus.Fatal(err) } - gitRepo := path.Join(config.APPS_DIR, recipeName, ".git") + gitRepo := path.Join(config.RECIPES_DIR, recipeName, ".git") if err := os.RemoveAll(gitRepo); err != nil { logrus.Fatal(err) } logrus.Debugf("removed git repo in %s", gitRepo) toParse := []string{ - path.Join(config.APPS_DIR, recipeName, "README.md"), - path.Join(config.APPS_DIR, recipeName, ".env.sample"), - path.Join(config.APPS_DIR, recipeName, ".drone.yml"), + path.Join(config.RECIPES_DIR, recipeName, "README.md"), + path.Join(config.RECIPES_DIR, recipeName, ".env.sample"), + path.Join(config.RECIPES_DIR, recipeName, ".drone.yml"), } for _, path := range toParse { file, err := os.OpenFile(path, os.O_RDWR, 0664) @@ -82,14 +82,14 @@ The new example repository is cloned to ~/.abra/apps/. } } - newGitRepo := path.Join(config.APPS_DIR, recipeName) + newGitRepo := path.Join(config.RECIPES_DIR, recipeName) if err := git.Init(newGitRepo, true); err != nil { logrus.Fatal(err) } logrus.Infof( "new recipe %s created in %s, happy hacking!\n", - recipeName, path.Join(config.APPS_DIR, recipeName), + recipeName, path.Join(config.RECIPES_DIR, recipeName), ) return nil diff --git a/cli/recipe/release.go b/cli/recipe/release.go index b6b24678..9a4b65ca 100644 --- a/cli/recipe/release.go +++ b/cli/recipe/release.go @@ -177,7 +177,7 @@ func getImageVersions(recipe recipe.Recipe) (map[string]string, error) { func createReleaseFromTag(recipe recipe.Recipe, tagString, mainAppVersion string) error { var err error - directory := path.Join(config.APPS_DIR, recipe.Name) + directory := path.Join(config.RECIPES_DIR, recipe.Name) repo, err := git.PlainOpen(directory) if err != nil { return err @@ -269,7 +269,7 @@ func commitRelease(recipe recipe.Recipe) error { } if internal.Commit { - repoPath := path.Join(config.APPS_DIR, recipe.Name) + repoPath := path.Join(config.RECIPES_DIR, recipe.Name) if err := gitPkg.Commit(repoPath, "compose.**yml", internal.CommitMessage, internal.Dry); err != nil { return err } @@ -343,7 +343,7 @@ func pushRelease(tagString string, repo *git.Repository) error { } func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recipe.Recipe, tags []string) error { - directory := path.Join(config.APPS_DIR, recipe.Name) + directory := path.Join(config.RECIPES_DIR, recipe.Name) repo, err := git.PlainOpen(directory) if err != nil { return err @@ -421,7 +421,7 @@ func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recip // cleanUpTag removes a freshly created tag func cleanUpTag(tag, recipeName string) error { - directory := path.Join(config.APPS_DIR, recipeName) + directory := path.Join(config.RECIPES_DIR, recipeName) repo, err := git.PlainOpen(directory) if err != nil { return err diff --git a/cli/recipe/sync.go b/cli/recipe/sync.go index 6caf4b6c..aff55824 100644 --- a/cli/recipe/sync.go +++ b/cli/recipe/sync.go @@ -95,7 +95,7 @@ will know that things are likely to change. } if nextTag == "" { - recipeDir := path.Join(config.APPS_DIR, recipe.Name) + recipeDir := path.Join(config.RECIPES_DIR, recipe.Name) repo, err := git.PlainOpen(recipeDir) if err != nil { logrus.Fatal(err) diff --git a/cli/recipe/upgrade.go b/cli/recipe/upgrade.go index 7c9a2e10..4ea0f733 100644 --- a/cli/recipe/upgrade.go +++ b/cli/recipe/upgrade.go @@ -61,7 +61,7 @@ You may invoke this command in "wizard" mode and be prompted for input: // check for versions file and load pinned versions versionsPresent := false - recipeDir := path.Join(config.ABRA_DIR, "apps", recipe.Name) + recipeDir := path.Join(config.RECIPES_DIR, recipe.Name) versionsPath := path.Join(recipeDir, "versions") var servicePins = make(map[string]imgPin) if _, err := os.Stat(versionsPath); err == nil { diff --git a/cli/server/add.go b/cli/server/add.go index 78955549..58140338 100644 --- a/cli/server/add.go +++ b/cli/server/add.go @@ -97,7 +97,7 @@ func cleanUp(domainName string) { } logrus.Warnf("cleaning up server directory for %s", domainName) - if err := os.RemoveAll(filepath.Join(config.ABRA_SERVER_FOLDER, domainName)); err != nil { + if err := os.RemoveAll(filepath.Join(config.SERVERS_DIR, domainName)); err != nil { logrus.Fatal(err) } } diff --git a/cli/server/remove.go b/cli/server/remove.go index c046e482..b8e428c5 100644 --- a/cli/server/remove.go +++ b/cli/server/remove.go @@ -164,7 +164,7 @@ like tears in rain. logrus.Fatal(err) } - if err := os.RemoveAll(filepath.Join(config.ABRA_SERVER_FOLDER, serverName)); err != nil { + if err := os.RemoveAll(filepath.Join(config.SERVERS_DIR, serverName)); err != nil { logrus.Fatal(err) } diff --git a/pkg/catalogue/catalogue.go b/pkg/catalogue/catalogue.go index 9dd3d348..cfc9e8df 100644 --- a/pkg/catalogue/catalogue.go +++ b/pkg/catalogue/catalogue.go @@ -136,7 +136,7 @@ func recipeCatalogueFSIsLatest() (bool, error) { return false, err } - info, err := os.Stat(config.APPS_JSON) + info, err := os.Stat(config.RECIPES_JSON) if err != nil { if os.IsNotExist(err) { logrus.Debugf("no recipe catalogue found in file system cache") @@ -185,7 +185,7 @@ func ReadRecipeCatalogue() (RecipeCatalogue, error) { // readRecipeCatalogueFS reads the catalogue from the file system. func readRecipeCatalogueFS(target interface{}) error { - recipesJSONFS, err := ioutil.ReadFile(config.APPS_JSON) + recipesJSONFS, err := ioutil.ReadFile(config.RECIPES_JSON) if err != nil { return err } @@ -194,7 +194,7 @@ func readRecipeCatalogueFS(target interface{}) error { return err } - logrus.Debugf("read recipe catalogue from file system cache in %s", config.APPS_JSON) + logrus.Debugf("read recipe catalogue from file system cache in %s", config.RECIPES_JSON) return nil } @@ -210,7 +210,7 @@ func readRecipeCatalogueWeb(target interface{}) error { return err } - if err := ioutil.WriteFile(config.APPS_JSON, recipesJSON, 0764); err != nil { + if err := ioutil.WriteFile(config.RECIPES_JSON, recipesJSON, 0764); err != nil { return err } @@ -437,7 +437,7 @@ func GetRecipeFeaturesAndCategory(recipeName string) (features, string, error) { var category string - readmePath := path.Join(config.ABRA_DIR, "apps", recipeName, "README.md") + readmePath := path.Join(config.RECIPES_DIR, recipeName, "README.md") logrus.Debugf("attempting to open %s for recipe metadata parsing", readmePath) @@ -509,7 +509,7 @@ func GetRecipeFeaturesAndCategory(recipeName string) (features, string, error) { func GetRecipeVersions(recipeName string) (RecipeVersions, error) { versions := RecipeVersions{} - recipeDir := path.Join(config.ABRA_DIR, "apps", recipeName) + recipeDir := path.Join(config.RECIPES_DIR, recipeName) logrus.Debugf("attempting to open git repository in %s", recipeDir) diff --git a/pkg/compose/compose.go b/pkg/compose/compose.go index d1c32b65..ee683a50 100644 --- a/pkg/compose/compose.go +++ b/pkg/compose/compose.go @@ -27,7 +27,7 @@ func UpdateTag(pattern, image, tag, recipeName string) error { for _, composeFile := range composeFiles { opts := stack.Deploy{Composefiles: []string{composeFile}} - envSamplePath := path.Join(config.ABRA_DIR, "apps", recipeName, ".env.sample") + envSamplePath := path.Join(config.RECIPES_DIR, recipeName, ".env.sample") sampleEnv, err := config.ReadEnv(envSamplePath) if err != nil { return err @@ -93,7 +93,7 @@ func UpdateLabel(pattern, serviceName, label, recipeName string) error { for _, composeFile := range composeFiles { opts := stack.Deploy{Composefiles: []string{composeFile}} - envSamplePath := path.Join(config.ABRA_DIR, "apps", recipeName, ".env.sample") + envSamplePath := path.Join(config.RECIPES_DIR, recipeName, ".env.sample") sampleEnv, err := config.ReadEnv(envSamplePath) if err != nil { return err diff --git a/pkg/config/app.go b/pkg/config/app.go index 88b8531f..a413c336 100644 --- a/pkg/config/app.go +++ b/pkg/config/app.go @@ -135,7 +135,7 @@ func LoadAppFiles(servers ...string) (AppFiles, error) { if servers[0] == "" { // Empty servers flag, one string will always be passed var err error - servers, err = GetAllFoldersInDirectory(ABRA_SERVER_FOLDER) + servers, err = GetAllFoldersInDirectory(SERVERS_DIR) if err != nil { return nil, err } @@ -145,14 +145,14 @@ func LoadAppFiles(servers ...string) (AppFiles, error) { logrus.Debugf("collecting metadata from %v servers: %s", len(servers), strings.Join(servers, ", ")) for _, server := range servers { - serverDir := path.Join(ABRA_SERVER_FOLDER, server) + serverDir := path.Join(SERVERS_DIR, server) files, err := getAllFilesInDirectory(serverDir) if err != nil { return nil, err } for _, file := range files { appName := strings.TrimSuffix(file.Name(), ".env") - appFilePath := path.Join(ABRA_SERVER_FOLDER, server, file.Name()) + appFilePath := path.Join(SERVERS_DIR, server, file.Name()) appFiles[appName] = AppFile{ Path: appFilePath, Server: server, @@ -248,8 +248,8 @@ func GetAppNames() ([]string, error) { } // TemplateAppEnvSample copies the example env file for the app into the users env files -func TemplateAppEnvSample(recipe, appName, server, domain string) error { - envSamplePath := path.Join(ABRA_DIR, "apps", recipe, ".env.sample") +func TemplateAppEnvSample(recipeName, appName, server, domain string) error { + envSamplePath := path.Join(RECIPES_DIR, recipeName, ".env.sample") envSample, err := ioutil.ReadFile(envSamplePath) if err != nil { return err @@ -260,7 +260,7 @@ func TemplateAppEnvSample(recipe, appName, server, domain string) error { return fmt.Errorf("%s already exists?", appEnvPath) } - envSample = []byte(strings.Replace(string(envSample), fmt.Sprintf("%s.example.com", recipe), domain, -1)) + envSample = []byte(strings.Replace(string(envSample), fmt.Sprintf("%s.example.com", recipeName), domain, -1)) envSample = []byte(strings.Replace(string(envSample), "example.com", domain, -1)) err = ioutil.WriteFile(appEnvPath, envSample, 0664) @@ -336,7 +336,7 @@ func GetAppComposeFiles(recipe string, appEnv AppEnv) ([]string, error) { if _, ok := appEnv["COMPOSE_FILE"]; !ok { logrus.Debug("no COMPOSE_FILE detected, loading compose.yml") - path := fmt.Sprintf("%s/%s/compose.yml", APPS_DIR, recipe) + path := fmt.Sprintf("%s/%s/compose.yml", RECIPES_DIR, recipe) composeFiles = append(composeFiles, path) return composeFiles, nil } @@ -345,7 +345,7 @@ func GetAppComposeFiles(recipe string, appEnv AppEnv) ([]string, error) { envVars := strings.Split(composeFileEnvVar, ":") logrus.Debugf("COMPOSE_FILE detected (%s), loading %s", composeFileEnvVar, strings.Join(envVars, ", ")) for _, file := range strings.Split(composeFileEnvVar, ":") { - path := fmt.Sprintf("%s/%s/%s", APPS_DIR, recipe, file) + path := fmt.Sprintf("%s/%s/%s", RECIPES_DIR, recipe, file) composeFiles = append(composeFiles, path) } diff --git a/pkg/config/env.go b/pkg/config/env.go index b0085b96..3cb5a231 100644 --- a/pkg/config/env.go +++ b/pkg/config/env.go @@ -15,16 +15,17 @@ import ( ) var ABRA_DIR = os.ExpandEnv("$HOME/.abra") -var ABRA_SERVER_FOLDER = path.Join(ABRA_DIR, "servers") -var APPS_JSON = path.Join(ABRA_DIR, "catalogue", "recipes.json") -var APPS_DIR = path.Join(ABRA_DIR, "apps") +var SERVERS_DIR = path.Join(ABRA_DIR, "servers") +var RECIPES_DIR = path.Join(ABRA_DIR, "apps") +var VENDOR_DIR = path.Join(ABRA_DIR, "vendor") +var RECIPES_JSON = path.Join(ABRA_DIR, "catalogue", "recipes.json") var REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud" // GetServers retrieves all servers. func GetServers() ([]string, error) { var servers []string - servers, err := GetAllFoldersInDirectory(ABRA_SERVER_FOLDER) + servers, err := GetAllFoldersInDirectory(SERVERS_DIR) if err != nil { return servers, err } @@ -50,13 +51,13 @@ func ReadEnv(filePath string) (AppEnv, error) { // ReadServerNames retrieves all server names. func ReadServerNames() ([]string, error) { - serverNames, err := GetAllFoldersInDirectory(ABRA_SERVER_FOLDER) + serverNames, err := GetAllFoldersInDirectory(SERVERS_DIR) if err != nil { return nil, err } - logrus.Debugf("read %s from %s", strings.Join(serverNames, ","), ABRA_SERVER_FOLDER) + logrus.Debugf("read %s from %s", strings.Join(serverNames, ","), SERVERS_DIR) return serverNames, nil } diff --git a/pkg/git/read.go b/pkg/git/read.go index 01e75133..4081a6f2 100644 --- a/pkg/git/read.go +++ b/pkg/git/read.go @@ -18,7 +18,7 @@ import ( // GetRecipeHead retrieves latest HEAD metadata. func GetRecipeHead(recipeName string) (*plumbing.Reference, error) { - recipeDir := path.Join(config.ABRA_DIR, "apps", recipeName) + recipeDir := path.Join(config.RECIPES_DIR, recipeName) repo, err := git.PlainOpen(recipeDir) if err != nil { @@ -35,7 +35,7 @@ func GetRecipeHead(recipeName string) (*plumbing.Reference, error) { // IsClean checks if a repo has unstaged changes func IsClean(recipeName string) (bool, error) { - recipeDir := path.Join(config.ABRA_DIR, "apps", recipeName) + recipeDir := path.Join(config.RECIPES_DIR, recipeName) repo, err := git.PlainOpen(recipeDir) if err != nil { diff --git a/pkg/recipe/recipe.go b/pkg/recipe/recipe.go index e96b98bd..09453aa6 100644 --- a/pkg/recipe/recipe.go +++ b/pkg/recipe/recipe.go @@ -24,9 +24,14 @@ type Recipe struct { Config *composetypes.Config } +// Dir retrieves the recipe repository path +func (r Recipe) Dir() string { + return path.Join(config.RECIPES_DIR, r.Name) +} + // UpdateLabel updates a recipe label func (r Recipe) UpdateLabel(pattern, serviceName, label string) error { - fullPattern := fmt.Sprintf("%s/%s/%s", config.APPS_DIR, r.Name, pattern) + fullPattern := fmt.Sprintf("%s/%s/%s", config.RECIPES_DIR, r.Name, pattern) if err := compose.UpdateLabel(fullPattern, serviceName, label, r.Name); err != nil { return err } @@ -35,7 +40,7 @@ func (r Recipe) UpdateLabel(pattern, serviceName, label string) error { // UpdateTag updates a recipe tag func (r Recipe) UpdateTag(image, tag string) error { - pattern := fmt.Sprintf("%s/%s/compose**yml", config.APPS_DIR, r.Name) + pattern := fmt.Sprintf("%s/%s/compose**yml", config.RECIPES_DIR, r.Name) if err := compose.UpdateTag(pattern, image, tag, r.Name); err != nil { return err } @@ -46,8 +51,7 @@ func (r Recipe) UpdateTag(image, tag string) error { func (r Recipe) Tags() ([]string, error) { var tags []string - recipeDir := path.Join(config.ABRA_DIR, "apps", r.Name) - repo, err := git.PlainOpen(recipeDir) + repo, err := git.PlainOpen(r.Dir()) if err != nil { return tags, err } @@ -75,7 +79,7 @@ func Get(recipeName string) (Recipe, error) { return Recipe{}, err } - pattern := fmt.Sprintf("%s/%s/compose**yml", config.APPS_DIR, recipeName) + pattern := fmt.Sprintf("%s/%s/compose**yml", config.RECIPES_DIR, recipeName) composeFiles, err := filepath.Glob(pattern) if err != nil { return Recipe{}, err @@ -85,7 +89,7 @@ func Get(recipeName string) (Recipe, error) { return Recipe{}, fmt.Errorf("%s is missing a compose.yml or compose.*.yml file?", recipeName) } - envSamplePath := path.Join(config.ABRA_DIR, "apps", recipeName, ".env.sample") + envSamplePath := path.Join(config.RECIPES_DIR, recipeName, ".env.sample") sampleEnv, err := config.ReadEnv(envSamplePath) if err != nil { return Recipe{}, err @@ -101,12 +105,12 @@ func Get(recipeName string) (Recipe, error) { } // EnsureExists ensures that a recipe is locally cloned -func EnsureExists(recipe string) error { - recipeDir := path.Join(config.ABRA_DIR, "apps", strings.ToLower(recipe)) +func EnsureExists(recipeName string) error { + recipeDir := path.Join(config.RECIPES_DIR, recipeName) if _, err := os.Stat(recipeDir); os.IsNotExist(err) { logrus.Debugf("%s does not exist, attemmpting to clone", recipeDir) - url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, recipe) + url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, recipeName) if err := gitPkg.Clone(recipeDir, url); err != nil { return err } @@ -121,7 +125,7 @@ func EnsureExists(recipe string) error { // EnsureVersion checks whether a specific version exists for a recipe. func EnsureVersion(recipeName, version string) error { - recipeDir := path.Join(config.ABRA_DIR, "apps", recipeName) + recipeDir := path.Join(config.RECIPES_DIR, recipeName) isClean, err := gitPkg.IsClean(recipeName) if err != nil { @@ -186,7 +190,7 @@ func EnsureVersion(recipeName, version string) error { // EnsureLatest makes sure the latest commit is checked out for a local recipe repository func EnsureLatest(recipeName string) error { - recipeDir := path.Join(config.ABRA_DIR, "apps", recipeName) + recipeDir := path.Join(config.RECIPES_DIR, recipeName) isClean, err := gitPkg.IsClean(recipeName) if err != nil { @@ -259,7 +263,7 @@ func ChaosVersion(recipeName string) (string, error) { func GetRecipesLocal() ([]string, error) { var recipes []string - recipes, err := config.GetAllFoldersInDirectory(config.APPS_DIR) + recipes, err := config.GetAllFoldersInDirectory(config.RECIPES_DIR) if err != nil { return recipes, err } @@ -288,7 +292,7 @@ func GetVersionLabelLocal(recipe Recipe) (string, error) { // EnsureUpToDate ensures that the local repo is synced to the remote func EnsureUpToDate(recipeName string) error { - recipeDir := path.Join(config.ABRA_DIR, "apps", recipeName) + recipeDir := path.Join(config.RECIPES_DIR, recipeName) repo, err := git.PlainOpen(recipeDir) if err != nil {