refactor: less quotes
continuous-integration/drone/push Build is passing Details

This commit is contained in:
decentral1se 2021-12-25 02:03:09 +01:00
parent 14400d4ed8
commit 3b5354b2a5
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
26 changed files with 51 additions and 51 deletions

View File

@ -41,7 +41,7 @@ var appBackupCommand = &cli.Command{
abraSh := path.Join(config.ABRA_DIR, "apps", app.Type, "abra.sh")
if _, err := os.Stat(abraSh); err != nil {
if os.IsNotExist(err) {
logrus.Fatalf("'%s' does not exist?", abraSh)
logrus.Fatalf("%s does not exist?", abraSh)
}
logrus.Fatal(err)
}
@ -62,7 +62,7 @@ var appBackupCommand = &cli.Command{
logrus.Fatal(err)
}
if !strings.Contains(string(bytes), execCmd) {
logrus.Fatalf("%s doesn't have a '%s' function", app.Type, execCmd)
logrus.Fatalf("%s doesn't have a %s function", app.Type, execCmd)
}
sourceAndExec := fmt.Sprintf("%s; %s", sourceCmd, execCmd)

View File

@ -23,7 +23,7 @@ var appCheckCommand = &cli.Command{
envSamplePath := path.Join(config.ABRA_DIR, "apps", app.Type, ".env.sample")
if _, err := os.Stat(envSamplePath); err != nil {
if os.IsNotExist(err) {
logrus.Fatalf("'%s' does not exist?", envSamplePath)
logrus.Fatalf("%s does not exist?", envSamplePath)
}
logrus.Fatal(err)
}
@ -45,7 +45,7 @@ var appCheckCommand = &cli.Command{
logrus.Fatalf("%s is missing %s", app.Path, missingEnvVars)
}
logrus.Infof("all necessary environment variables defined for '%s'", app.Name)
logrus.Infof("all necessary environment variables defined for %s", app.Name)
return nil
},

View File

@ -31,7 +31,7 @@ var appConfigCommand = &cli.Command{
appFile, exists := files[appName]
if !exists {
logrus.Fatalf("cannot find app with name '%s'", appName)
logrus.Fatalf("cannot find app with name %s", appName)
}
ed, ok := os.LookupEnv("EDITOR")

View File

@ -60,7 +60,7 @@ var appRemoveCommand = &cli.Command{
logrus.Fatal(err)
}
if isDeployed {
logrus.Fatalf("'%s' is still deployed. Run \"abra app undeploy %s \" or pass --force", app.Name, app.Name)
logrus.Fatalf("%s is still deployed. Run \"abra app undeploy %s \" or pass --force", app.Name, app.Name)
}
}

View File

@ -40,7 +40,7 @@ var appRestoreCommand = &cli.Command{
abraSh := path.Join(config.ABRA_DIR, "apps", app.Type, "abra.sh")
if _, err := os.Stat(abraSh); err != nil {
if os.IsNotExist(err) {
logrus.Fatalf("'%s' does not exist?", abraSh)
logrus.Fatalf("%s does not exist?", abraSh)
}
logrus.Fatal(err)
}
@ -60,7 +60,7 @@ var appRestoreCommand = &cli.Command{
logrus.Fatal(err)
}
if !strings.Contains(string(bytes), execCmd) {
logrus.Fatalf("%s doesn't have a '%s' function", app.Type, execCmd)
logrus.Fatalf("%s doesn't have a %s function", app.Type, execCmd)
}
backupFile := c.Args().Get(2)

View File

@ -50,7 +50,7 @@ recipes.
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 {
@ -58,7 +58,7 @@ recipes.
}
if !isDeployed {
logrus.Fatalf("'%s' is not deployed?", app.Name)
logrus.Fatalf("%s is not deployed?", app.Name)
}
catl, err := catalogue.ReadRecipeCatalogue()
@ -75,7 +75,7 @@ recipes.
if deployedVersion == "" {
deployedVersion = "unknown"
availableDowngrades = versions
logrus.Warnf("failed to determine version of deployed '%s'", app.Name)
logrus.Warnf("failed to determine version of deployed %s", app.Name)
}
if deployedVersion != "unknown" && !internal.Chaos {
@ -108,10 +108,10 @@ recipes.
if !internal.Chaos {
if internal.Force {
chosenDowngrade = availableDowngrades[0]
logrus.Debugf("choosing '%s' as version to downgrade to (--force)", chosenDowngrade)
logrus.Debugf("choosing %s as version to downgrade to (--force)", chosenDowngrade)
} else {
prompt := &survey.Select{
Message: fmt.Sprintf("Please select a downgrade (current version: '%s'):", deployedVersion),
Message: fmt.Sprintf("Please select a downgrade (current version: %s):", deployedVersion),
Options: availableDowngrades,
}
if err := survey.AskOne(prompt, &chosenDowngrade); err != nil {

View File

@ -60,7 +60,7 @@ var appSecretGenerateCommand = &cli.Command{
}
}
if !matches {
logrus.Fatalf("'%s' doesn't exist in the env config?", secretName)
logrus.Fatalf("%s doesn't exist in the env config?", secretName)
}
}

View File

@ -27,7 +27,7 @@ volumes as eligiblef or pruning once undeployed.
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 {
@ -35,7 +35,7 @@ volumes as eligiblef or pruning once undeployed.
}
if !isDeployed {
logrus.Fatalf("'%s' is not deployed?", stackName)
logrus.Fatalf("%s is not deployed?", stackName)
}
if err := internal.DeployOverview(app, deployedVersion, "continue with undeploy?"); err != nil {

View File

@ -142,7 +142,7 @@ A new catalogue copy can be published to the recipes repository by passing the
}
if !isClean {
logrus.Fatalf("'%s' has locally unstaged changes", rm.Name)
logrus.Fatalf("%s has locally unstaged changes", rm.Name)
}
if err := gitPkg.EnsureUpToDate(recipeDir); err != nil {

View File

@ -85,7 +85,7 @@ convenient command-line experience. See "abra autocomplete -h" for more.
}
}
logrus.Debugf("abra version '%s', commit '%s'", version, commit)
logrus.Debugf("abra version %s, commit %s", version, commit)
return nil
}

View File

@ -23,7 +23,7 @@ var recipeVersionCommand = &cli.Command{
recipeMeta, ok := catalogue[recipe.Name]
if !ok {
logrus.Fatalf("'%s' recipe doesn't exist?", recipe.Name)
logrus.Fatalf("%s recipe doesn't exist?", recipe.Name)
}
tableCol := []string{"Version", "Service", "Image", "Tag", "Digest"}

View File

@ -46,7 +46,7 @@ are listed. This zone must already be created on your provider account.
logrus.Fatal(err)
}
default:
logrus.Fatalf("'%s' is not a supported DNS provider", internal.DNSProvider)
logrus.Fatalf("%s is not a supported DNS provider", internal.DNSProvider)
}
records, err := provider.GetRecords(c.Context, zone)

View File

@ -59,7 +59,7 @@ You may also invoke this command in "wizard" mode and be prompted for input
logrus.Fatal(err)
}
default:
logrus.Fatalf("'%s' is not a supported DNS provider", internal.DNSProvider)
logrus.Fatalf("%s is not a supported DNS provider", internal.DNSProvider)
}
if err := internal.EnsureDNSTypeFlag(c); err != nil {

View File

@ -168,7 +168,7 @@ like tears in rain.
logrus.Fatal(err)
}
logrus.Infof("server at '%s' has been lost in time, like tears in rain", serverName)
logrus.Infof("server at %s has been lost in time, like tears in rain", serverName)
return nil
},

View File

@ -33,7 +33,7 @@ testing efforts!
cmd = exec.Command("bash", "-c", fmt.Sprintf("curl -s %s | bash -s -- --rc", releaseCandidateURL))
}
logrus.Debugf("attempting to run '%s'", cmd)
logrus.Debugf("attempting to run %s", cmd)
if err := internal.RunCmd(cmd); err != nil {
logrus.Fatal(err)

View File

@ -23,7 +23,7 @@ func Get(appName string) (config.App, error) {
return config.App{}, err
}
logrus.Debugf("retrieved '%s' for '%s'", app, appName)
logrus.Debugf("retrieved %s for %s", app, appName)
return app, nil
}

View File

@ -384,12 +384,12 @@ func GetStringInBetween(str, start, end string) (result string, err error) {
// GetStringInBetween returns empty string if no start or end string found
s := strings.Index(str, start)
if s == -1 {
return "", fmt.Errorf("marker string '%s' not found", start)
return "", fmt.Errorf("marker string %s not found", start)
}
s += len(start)
e := strings.Index(str[s:], end)
if e == -1 {
return "", fmt.Errorf("end marker '%s' not found", end)
return "", fmt.Errorf("end marker %s not found", end)
}
return str[s : s+e], nil
}

View File

@ -55,7 +55,7 @@ func New(contextName string) (*client.Client, error) {
return nil, err
}
logrus.Debugf("created client for '%s'", contextName)
logrus.Debugf("created client for %s", contextName)
return cl, nil
}

View File

@ -26,7 +26,7 @@ func CreateContext(contextName string, user string, port string) error {
if err := createContext(contextName, host); err != nil {
return err
}
logrus.Debugf("created the '%s' context", contextName)
logrus.Debugf("created the %s context", contextName)
return nil
}

View File

@ -182,7 +182,7 @@ func GetTagDigest(cl *client.Client, image reference.Named) (string, error) {
}
if digest == "" {
return "", fmt.Errorf("Unable to retrieve amd64 digest for '%s'", image)
return "", fmt.Errorf("Unable to retrieve amd64 digest for %s", image)
}
return digest, nil

View File

@ -22,7 +22,7 @@ func UpdateTag(pattern, image, tag, recipeName string) error {
return err
}
logrus.Debugf("considering '%s' config(s) for tag update", strings.Join(composeFiles, ", "))
logrus.Debugf("considering %s config(s) for tag update", strings.Join(composeFiles, ", "))
for _, composeFile := range composeFiles {
opts := stack.Deploy{Composefiles: []string{composeFile}}
@ -57,7 +57,7 @@ func UpdateTag(pattern, image, tag, recipeName string) error {
}
composeTag := img.(reference.NamedTagged).Tag()
logrus.Debugf("parsed '%s' from '%s'", composeTag, service.Image)
logrus.Debugf("parsed %s from %s", composeTag, service.Image)
if image == composeImage {
bytes, err := ioutil.ReadFile(composeFile)
@ -69,7 +69,7 @@ func UpdateTag(pattern, image, tag, recipeName string) error {
new := fmt.Sprintf("%s:%s", composeImage, tag)
replacedBytes := strings.Replace(string(bytes), old, new, -1)
logrus.Debugf("updating '%s' to '%s' in '%s'", old, new, compose.Filename)
logrus.Debugf("updating %s to %s in %s", old, new, compose.Filename)
if err := ioutil.WriteFile(compose.Filename, []byte(replacedBytes), 0764); err != nil {
return err

View File

@ -96,14 +96,14 @@ func (a ByName) Less(i, j int) bool {
func readAppEnvFile(appFile AppFile, name AppName) (App, error) {
env, err := ReadEnv(appFile.Path)
if err != nil {
return App{}, fmt.Errorf("env file for '%s' couldn't be read: %s", name, err.Error())
return App{}, fmt.Errorf("env file for %s couldn't be read: %s", name, err.Error())
}
logrus.Debugf("read env '%s' from '%s'", env, appFile.Path)
logrus.Debugf("read env %s from %s", env, appFile.Path)
app, err := newApp(env, name, appFile)
if err != nil {
return App{}, fmt.Errorf("env file for '%s' has issues: %s", name, err.Error())
return App{}, fmt.Errorf("env file for %s has issues: %s", name, err.Error())
}
return app, nil

View File

@ -47,7 +47,7 @@ func EnsureIPv4(domainName string) (string, error) {
},
}
logrus.Debugf("created DNS resolver via '%s'", freifunkDNS)
logrus.Debugf("created DNS resolver via %s", freifunkDNS)
ctx := context.Background()
ips, err := resolver.LookupIPAddr(ctx, domainName)

View File

@ -64,7 +64,7 @@ func (r Recipe) Tags() ([]string, error) {
return tags, err
}
logrus.Debugf("detected '%s' as tags for recipe '%s'", strings.Join(tags, ", "), r.Name)
logrus.Debugf("detected %s as tags for recipe %s", strings.Join(tags, ", "), r.Name)
return tags, nil
}
@ -129,7 +129,7 @@ func EnsureVersion(recipeName, version string) error {
}
if !isClean {
return fmt.Errorf("'%s' has locally unstaged changes", recipeName)
return fmt.Errorf("%s has locally unstaged changes", recipeName)
}
if err := gitPkg.EnsureGitRepo(recipeDir); err != nil {

View File

@ -19,13 +19,13 @@ func PassInsertSecret(secretValue, secretName, appName, server string) error {
secretValue, server, appName, secretName,
)
logrus.Debugf("attempting to run '%s'", cmd)
logrus.Debugf("attempting to run %s", cmd)
if err := exec.Command("bash", "-c", cmd).Run(); err != nil {
return err
}
logrus.Infof("'%s' inserted into pass store", secretName)
logrus.Infof("%s inserted into pass store", secretName)
return nil
}
@ -41,13 +41,13 @@ func PassRmSecret(secretName, appName, server string) error {
server, appName, secretName,
)
logrus.Debugf("attempting to run '%s'", cmd)
logrus.Debugf("attempting to run %s", cmd)
if err := exec.Command("bash", "-c", cmd).Run(); err != nil {
return err
}
logrus.Infof("'%s' removed from pass store", secretName)
logrus.Infof("%s removed from pass store", secretName)
return nil
}

View File

@ -34,7 +34,7 @@ func GeneratePasswords(count, length uint) ([]string, error) {
return nil, err
}
logrus.Debugf("generated '%s'", strings.Join(passwords, ", "))
logrus.Debugf("generated %s", strings.Join(passwords, ", "))
return passwords, nil
}
@ -53,7 +53,7 @@ func GeneratePassphrases(count uint) ([]string, error) {
return nil, err
}
logrus.Debugf("generated '%s'", strings.Join(passphrases, ", "))
logrus.Debugf("generated %s", strings.Join(passphrases, ", "))
return passphrases, nil
}
@ -69,7 +69,7 @@ func ReadSecretEnvVars(appEnv config.AppEnv) map[string]string {
}
}
logrus.Debugf("read '%s' as secrets from '%s'", secretEnvVars, appEnv)
logrus.Debugf("read %s as secrets from %s", secretEnvVars, appEnv)
return secretEnvVars
}
@ -79,7 +79,7 @@ func ParseSecretEnvVarName(secretEnvVar string) string {
withoutPrefix := strings.TrimPrefix(secretEnvVar, "SECRET_")
withoutSuffix := strings.TrimSuffix(withoutPrefix, "_VERSION")
name := strings.ToLower(withoutSuffix)
logrus.Debugf("parsed '%s' as name from '%s'", name, secretEnvVar)
logrus.Debugf("parsed %s as name from %s", name, secretEnvVar)
return name
}
@ -89,7 +89,7 @@ func ParseGeneratedSecretName(secret string, appEnv config.App) string {
withoutAppName := strings.TrimPrefix(secret, name)
idx := strings.LastIndex(withoutAppName, "_")
parsed := withoutAppName[:idx]
logrus.Debugf("parsed '%s' as name from '%s'", parsed, secret)
logrus.Debugf("parsed %s as name from %s", parsed, secret)
return parsed
}
@ -97,7 +97,7 @@ func ParseGeneratedSecretName(secret string, appEnv config.App) string {
func ParseSecretEnvVarValue(secret string) (secretValue, error) {
values := strings.Split(secret, "#")
if len(values) == 0 {
return secretValue{}, fmt.Errorf("unable to parse '%s'", secret)
return secretValue{}, fmt.Errorf("unable to parse %s", secret)
}
if len(values) == 1 {
@ -113,7 +113,7 @@ func ParseSecretEnvVarValue(secret string) (secretValue, error) {
}
version := strings.ReplaceAll(values[0], " ", "")
logrus.Debugf("parsed version '%s' and length '%v' from '%s'", version, length, secret)
logrus.Debugf("parsed version %s and length '%v' from %s", version, length, secret)
return secretValue{Version: version, Length: length}, nil
}
@ -132,7 +132,7 @@ func GenerateSecrets(secretEnvVars map[string]string, appName, server string) (m
return
}
secretRemoteName := fmt.Sprintf("%s_%s_%s", appName, secretName, secretValue.Version)
logrus.Debugf("attempting to generate and store '%s' on '%s'", secretRemoteName, server)
logrus.Debugf("attempting to generate and store %s on %s", secretRemoteName, server)
if secretValue.Length > 0 {
passwords, err := GeneratePasswords(1, uint(secretValue.Length))
if err != nil {
@ -177,7 +177,7 @@ func GenerateSecrets(secretEnvVars map[string]string, appName, server string) (m
}
}
logrus.Debugf("generated and stored '%s' on '%s'", secrets, server)
logrus.Debugf("generated and stored %s on %s", secrets, server)
return secrets, nil
}