refactor: less quotes
This commit is contained in:
parent
053a06ccba
commit
0a903f041f
|
@ -20,11 +20,14 @@ func getImagePath(image string) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
path := reference.Path(img)
|
path := reference.Path(img)
|
||||||
if strings.Contains(path, "library") {
|
if strings.Contains(path, "library") {
|
||||||
path = strings.Split(path, "/")[1]
|
path = strings.Split(path, "/")[1]
|
||||||
}
|
}
|
||||||
logrus.Debugf("parsed '%s' from '%s'", path, image)
|
|
||||||
|
logrus.Debugf("parsed %s from %s", path, image)
|
||||||
|
|
||||||
return path, nil
|
return path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +49,7 @@ Cloud recipe version.
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("checking whether '%s' is already deployed", stackName)
|
logrus.Debugf("checking whether %s is already deployed", stackName)
|
||||||
|
|
||||||
isDeployed, deployedVersion, err := stack.IsDeployed(c.Context, cl, stackName)
|
isDeployed, deployedVersion, err := stack.IsDeployed(c.Context, cl, stackName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -54,11 +57,11 @@ Cloud recipe version.
|
||||||
}
|
}
|
||||||
|
|
||||||
if deployedVersion == "" {
|
if deployedVersion == "" {
|
||||||
logrus.Fatalf("failed to determine version of deployed '%s'", app.Name)
|
logrus.Fatalf("failed to determine version of deployed %s", app.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isDeployed {
|
if !isDeployed {
|
||||||
logrus.Fatalf("'%s' is not deployed?", app.Name)
|
logrus.Fatalf("%s is not deployed?", app.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
recipeMeta, err := catalogue.GetRecipeMeta(app.Type)
|
recipeMeta, err := catalogue.GetRecipeMeta(app.Type)
|
||||||
|
@ -74,7 +77,7 @@ Cloud recipe version.
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(versionsMeta) == 0 {
|
if len(versionsMeta) == 0 {
|
||||||
logrus.Fatalf("could not retrieve deployed version ('%s') from recipe catalogue?", deployedVersion)
|
logrus.Fatalf("could not retrieve deployed version (%s) from recipe catalogue?", deployedVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
tableCol := []string{"version", "service", "image", "digest"}
|
tableCol := []string{"version", "service", "image", "digest"}
|
||||||
|
|
|
@ -79,7 +79,7 @@ func ValidateRecipeWithPrompt(c *cli.Context) recipe.Recipe {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("validated '%s' as recipe argument", recipeName)
|
logrus.Debugf("validated %s as recipe argument", recipeName)
|
||||||
|
|
||||||
return recipe
|
return recipe
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ func ValidateApp(c *cli.Context) config.App {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("validated '%s' as app argument", appName)
|
logrus.Debugf("validated %s as app argument", appName)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ func ValidateDomain(c *cli.Context) (string, error) {
|
||||||
ShowSubcommandHelpAndError(c, errors.New("no domain provided"))
|
ShowSubcommandHelpAndError(c, errors.New("no domain provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("validated '%s' as domain argument", domainName)
|
logrus.Debugf("validated %s as domain argument", domainName)
|
||||||
|
|
||||||
return domainName, nil
|
return domainName, nil
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ func ValidateServer(c *cli.Context) (string, error) {
|
||||||
ShowSubcommandHelpAndError(c, errors.New("no server provided"))
|
ShowSubcommandHelpAndError(c, errors.New("no server provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("validated '%s' as server argument", serverName)
|
logrus.Debugf("validated %s as server argument", serverName)
|
||||||
|
|
||||||
return serverName, nil
|
return serverName, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
logrus.Debugf("retrieved '%s' from remote registry for '%s'", regVersions, image)
|
logrus.Debugf("retrieved %s from remote registry for %s", regVersions, image)
|
||||||
|
|
||||||
if strings.Contains(image, "library") {
|
if strings.Contains(image, "library") {
|
||||||
// ParseNormalizedNamed prepends 'library' to images like nginx:<tag>,
|
// ParseNormalizedNamed prepends 'library' to images like nginx:<tag>,
|
||||||
|
@ -148,7 +148,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||||
sort.Sort(tagcmp.ByTagDesc(compatible))
|
sort.Sort(tagcmp.ByTagDesc(compatible))
|
||||||
|
|
||||||
if len(compatible) == 0 && semverLikeTag {
|
if len(compatible) == 0 && semverLikeTag {
|
||||||
logrus.Info(fmt.Sprintf("no new versions available for %s, %s' is the latest", image, tag))
|
logrus.Info(fmt.Sprintf("no new versions available for %s, %s is the latest", image, tag))
|
||||||
continue // skip on to the next tag and don't update any compose files
|
continue // skip on to the next tag and don't update any compose files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ func LoadAppFiles(servers ...string) (AppFiles, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("collecting metadata from '%v' servers: '%s'", len(servers), strings.Join(servers, ", "))
|
logrus.Debugf("collecting metadata from %v servers: %s", len(servers), strings.Join(servers, ", "))
|
||||||
|
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
serverDir := path.Join(ABRA_SERVER_FOLDER, server)
|
serverDir := path.Join(ABRA_SERVER_FOLDER, server)
|
||||||
|
@ -168,7 +168,7 @@ func LoadAppFiles(servers ...string) (AppFiles, error) {
|
||||||
func GetApp(apps AppFiles, name AppName) (App, error) {
|
func GetApp(apps AppFiles, name AppName) (App, error) {
|
||||||
appFile, exists := apps[name]
|
appFile, exists := apps[name]
|
||||||
if !exists {
|
if !exists {
|
||||||
return App{}, fmt.Errorf("cannot find app with name '%s'", name)
|
return App{}, fmt.Errorf("cannot find app with name %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
app, err := readAppEnvFile(appFile, name)
|
app, err := readAppEnvFile(appFile, name)
|
||||||
|
@ -268,7 +268,7 @@ func TemplateAppEnvSample(appType, appName, server, domain, recipe string) error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("copied '%s' to '%s'", envSamplePath, appEnvPath)
|
logrus.Debugf("copied %s to %s", envSamplePath, appEnvPath)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ func GetAppStatuses(appFiles AppFiles) (map[string]map[string]string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("retrieved app statuses: '%s'", statuses)
|
logrus.Debugf("retrieved app statuses: %s", statuses)
|
||||||
|
|
||||||
return statuses, nil
|
return statuses, nil
|
||||||
}
|
}
|
||||||
|
@ -343,13 +343,13 @@ func GetAppComposeFiles(recipe string, appEnv AppEnv) ([]string, error) {
|
||||||
|
|
||||||
composeFileEnvVar := appEnv["COMPOSE_FILE"]
|
composeFileEnvVar := appEnv["COMPOSE_FILE"]
|
||||||
envVars := strings.Split(composeFileEnvVar, ":")
|
envVars := strings.Split(composeFileEnvVar, ":")
|
||||||
logrus.Debugf("COMPOSE_FILE detected ('%s'), loading '%s'", composeFileEnvVar, strings.Join(envVars, ", "))
|
logrus.Debugf("COMPOSE_FILE detected (%s), loading %s", composeFileEnvVar, strings.Join(envVars, ", "))
|
||||||
for _, file := range strings.Split(composeFileEnvVar, ":") {
|
for _, file := range strings.Split(composeFileEnvVar, ":") {
|
||||||
path := fmt.Sprintf("%s/%s/%s", APPS_DIR, recipe, file)
|
path := fmt.Sprintf("%s/%s/%s", APPS_DIR, recipe, file)
|
||||||
composeFiles = append(composeFiles, path)
|
composeFiles = append(composeFiles, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("retrieved '%s' configs for '%s'", strings.Join(composeFiles, ", "), recipe)
|
logrus.Debugf("retrieved %s configs for %s", strings.Join(composeFiles, ", "), recipe)
|
||||||
|
|
||||||
return composeFiles, nil
|
return composeFiles, nil
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ func GetAppComposeConfig(recipe string, opts stack.Deploy, appEnv AppEnv) (*comp
|
||||||
return &composetypes.Config{}, err
|
return &composetypes.Config{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("retrieved '%s' for '%s'", compose.Filename, recipe)
|
logrus.Debugf("retrieved %s for %s", compose.Filename, recipe)
|
||||||
|
|
||||||
return compose, nil
|
return compose, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ var REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud"
|
||||||
func GetServers() ([]string, error) {
|
func GetServers() ([]string, error) {
|
||||||
var servers []string
|
var servers []string
|
||||||
|
|
||||||
servers, err := getAllFoldersInDirectory(ABRA_SERVER_FOLDER)
|
servers, err := GetAllFoldersInDirectory(ABRA_SERVER_FOLDER)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return servers, err
|
return servers, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("retrieved '%v' servers: '%s'", len(servers), servers)
|
logrus.Debugf("retrieved %v servers: %s", len(servers), servers)
|
||||||
|
|
||||||
return servers, nil
|
return servers, nil
|
||||||
}
|
}
|
||||||
|
@ -43,20 +43,20 @@ func ReadEnv(filePath string) (AppEnv, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("read '%s' from '%s'", envFile, filePath)
|
logrus.Debugf("read %s from %s", envFile, filePath)
|
||||||
|
|
||||||
return envFile, nil
|
return envFile, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadServerNames retrieves all server names.
|
// ReadServerNames retrieves all server names.
|
||||||
func ReadServerNames() ([]string, error) {
|
func ReadServerNames() ([]string, error) {
|
||||||
serverNames, err := getAllFoldersInDirectory(ABRA_SERVER_FOLDER)
|
serverNames, err := GetAllFoldersInDirectory(ABRA_SERVER_FOLDER)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("read '%s' from '%s'", strings.Join(serverNames, ","), ABRA_SERVER_FOLDER)
|
logrus.Debugf("read %s from %s", strings.Join(serverNames, ","), ABRA_SERVER_FOLDER)
|
||||||
|
|
||||||
return serverNames, nil
|
return serverNames, nil
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func getAllFilesInDirectory(directory string) ([]fs.FileInfo, error) {
|
||||||
|
|
||||||
realPath, err := filepath.EvalSymlinks(filePath)
|
realPath, err := filepath.EvalSymlinks(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Warningf("broken symlink in your abra config folders: '%s'", filePath)
|
logrus.Warningf("broken symlink in your abra config folders: %s", filePath)
|
||||||
} else {
|
} else {
|
||||||
realFile, err := os.Stat(realPath)
|
realFile, err := os.Stat(realPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -104,7 +104,7 @@ func getAllFoldersInDirectory(directory string) ([]string, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(files) == 0 {
|
if len(files) == 0 {
|
||||||
return nil, fmt.Errorf("directory is empty: '%s'", directory)
|
return nil, fmt.Errorf("directory is empty: %s", directory)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
|
@ -113,7 +113,7 @@ func getAllFoldersInDirectory(directory string) ([]string, error) {
|
||||||
filePath := path.Join(directory, file.Name())
|
filePath := path.Join(directory, file.Name())
|
||||||
realDir, err := filepath.EvalSymlinks(filePath)
|
realDir, err := filepath.EvalSymlinks(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Warningf("broken symlink in your abra config folders: '%s'", filePath)
|
logrus.Warningf("broken symlink in your abra config folders: %s", filePath)
|
||||||
} else if stat, err := os.Stat(realDir); err == nil && stat.IsDir() {
|
} else if stat, err := os.Stat(realDir); err == nil && stat.IsDir() {
|
||||||
// path is a directory
|
// path is a directory
|
||||||
folders = append(folders, file.Name())
|
folders = append(folders, file.Name())
|
||||||
|
@ -127,7 +127,7 @@ func getAllFoldersInDirectory(directory string) ([]string, error) {
|
||||||
// EnsureAbraDirExists checks for the abra config folder and throws error if not
|
// EnsureAbraDirExists checks for the abra config folder and throws error if not
|
||||||
func EnsureAbraDirExists() error {
|
func EnsureAbraDirExists() error {
|
||||||
if _, err := os.Stat(ABRA_DIR); os.IsNotExist(err) {
|
if _, err := os.Stat(ABRA_DIR); os.IsNotExist(err) {
|
||||||
logrus.Debugf("'%s' does not exist, creating it", ABRA_DIR)
|
logrus.Debugf("%s does not exist, creating it", ABRA_DIR)
|
||||||
if err := os.Mkdir(ABRA_DIR, 0777); err != nil {
|
if err := os.Mkdir(ABRA_DIR, 0777); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ func ReadAbraShEnvVars(abraSh string) (map[string]string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("read '%s' from '%s'", envVars, abraSh)
|
logrus.Debugf("read %s from %s", envVars, abraSh)
|
||||||
|
|
||||||
return envVars, nil
|
return envVars, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue