From 0a903f041f1404d29f5a3b69da62226f0658d300 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Mon, 20 Dec 2021 00:49:36 +0100 Subject: [PATCH] refactor: less quotes --- cli/app/version.go | 13 ++++++++----- cli/internal/validate.go | 8 ++++---- cli/recipe/upgrade.go | 4 ++-- pkg/config/app.go | 14 +++++++------- pkg/config/env.go | 20 ++++++++++---------- 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/cli/app/version.go b/cli/app/version.go index 8f3f090f..bbfd1d4a 100644 --- a/cli/app/version.go +++ b/cli/app/version.go @@ -20,11 +20,14 @@ func getImagePath(image string) (string, error) { if err != nil { return "", err } + path := reference.Path(img) if strings.Contains(path, "library") { path = strings.Split(path, "/")[1] } - logrus.Debugf("parsed '%s' from '%s'", path, image) + + logrus.Debugf("parsed %s from %s", path, image) + return path, nil } @@ -46,7 +49,7 @@ Cloud recipe version. 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) if err != nil { @@ -54,11 +57,11 @@ Cloud recipe version. } 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 { - logrus.Fatalf("'%s' is not deployed?", app.Name) + logrus.Fatalf("%s is not deployed?", app.Name) } recipeMeta, err := catalogue.GetRecipeMeta(app.Type) @@ -74,7 +77,7 @@ Cloud recipe version. } 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"} diff --git a/cli/internal/validate.go b/cli/internal/validate.go index 462e023d..af8b8d80 100644 --- a/cli/internal/validate.go +++ b/cli/internal/validate.go @@ -79,7 +79,7 @@ func ValidateRecipeWithPrompt(c *cli.Context) recipe.Recipe { logrus.Fatal(err) } - logrus.Debugf("validated '%s' as recipe argument", recipeName) + logrus.Debugf("validated %s as recipe argument", recipeName) return recipe } @@ -110,7 +110,7 @@ func ValidateApp(c *cli.Context) config.App { logrus.Fatal(err) } - logrus.Debugf("validated '%s' as app argument", appName) + logrus.Debugf("validated %s as app argument", appName) return app } @@ -133,7 +133,7 @@ func ValidateDomain(c *cli.Context) (string, error) { 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 } @@ -175,7 +175,7 @@ func ValidateServer(c *cli.Context) (string, error) { 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 } diff --git a/cli/recipe/upgrade.go b/cli/recipe/upgrade.go index bb733c85..1602343b 100644 --- a/cli/recipe/upgrade.go +++ b/cli/recipe/upgrade.go @@ -112,7 +112,7 @@ You may invoke this command in "wizard" mode and be prompted for input: if err != nil { 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") { // ParseNormalizedNamed prepends 'library' to images like nginx:, @@ -148,7 +148,7 @@ You may invoke this command in "wizard" mode and be prompted for input: sort.Sort(tagcmp.ByTagDesc(compatible)) 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 } diff --git a/pkg/config/app.go b/pkg/config/app.go index 3fd37749..25d3711d 100644 --- a/pkg/config/app.go +++ b/pkg/config/app.go @@ -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 { 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) { appFile, exists := apps[name] 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) @@ -268,7 +268,7 @@ func TemplateAppEnvSample(appType, appName, server, domain, recipe string) error return err } - logrus.Debugf("copied '%s' to '%s'", envSamplePath, appEnvPath) + logrus.Debugf("copied %s to %s", envSamplePath, appEnvPath) 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 } @@ -343,13 +343,13 @@ func GetAppComposeFiles(recipe string, appEnv AppEnv) ([]string, error) { composeFileEnvVar := appEnv["COMPOSE_FILE"] 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, ":") { path := fmt.Sprintf("%s/%s/%s", APPS_DIR, recipe, file) 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 } @@ -363,7 +363,7 @@ func GetAppComposeConfig(recipe string, opts stack.Deploy, appEnv AppEnv) (*comp 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 } diff --git a/pkg/config/env.go b/pkg/config/env.go index 4cbf53a6..7c4ba3e5 100644 --- a/pkg/config/env.go +++ b/pkg/config/env.go @@ -24,12 +24,12 @@ var REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud" func GetServers() ([]string, error) { var servers []string - servers, err := getAllFoldersInDirectory(ABRA_SERVER_FOLDER) + servers, err := GetAllFoldersInDirectory(ABRA_SERVER_FOLDER) if err != nil { return servers, err } - logrus.Debugf("retrieved '%v' servers: '%s'", len(servers), servers) + logrus.Debugf("retrieved %v servers: %s", len(servers), servers) return servers, nil } @@ -43,20 +43,20 @@ func ReadEnv(filePath string) (AppEnv, error) { return nil, err } - logrus.Debugf("read '%s' from '%s'", envFile, filePath) + logrus.Debugf("read %s from %s", envFile, filePath) return envFile, nil } // ReadServerNames retrieves all server names. func ReadServerNames() ([]string, error) { - serverNames, err := getAllFoldersInDirectory(ABRA_SERVER_FOLDER) + serverNames, err := GetAllFoldersInDirectory(ABRA_SERVER_FOLDER) 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, ","), ABRA_SERVER_FOLDER) return serverNames, nil } @@ -80,7 +80,7 @@ func getAllFilesInDirectory(directory string) ([]fs.FileInfo, error) { realPath, err := filepath.EvalSymlinks(filePath) 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 { realFile, err := os.Stat(realPath) if err != nil { @@ -104,7 +104,7 @@ func getAllFoldersInDirectory(directory string) ([]string, error) { return nil, err } 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 { @@ -113,7 +113,7 @@ func getAllFoldersInDirectory(directory string) ([]string, error) { filePath := path.Join(directory, file.Name()) realDir, err := filepath.EvalSymlinks(filePath) 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() { // path is a directory 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 func EnsureAbraDirExists() error { 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 { 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 }