refactor: less quotes

This commit is contained in:
2021-12-25 02:03:09 +01:00
parent 14400d4ed8
commit 3b5354b2a5
26 changed files with 51 additions and 51 deletions

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
}