refactor: less quotes
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
14400d4ed8
commit
3b5354b2a5
|
@ -41,7 +41,7 @@ var appBackupCommand = &cli.Command{
|
||||||
abraSh := path.Join(config.ABRA_DIR, "apps", app.Type, "abra.sh")
|
abraSh := path.Join(config.ABRA_DIR, "apps", app.Type, "abra.sh")
|
||||||
if _, err := os.Stat(abraSh); err != nil {
|
if _, err := os.Stat(abraSh); err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
logrus.Fatalf("'%s' does not exist?", abraSh)
|
logrus.Fatalf("%s does not exist?", abraSh)
|
||||||
}
|
}
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ var appBackupCommand = &cli.Command{
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
if !strings.Contains(string(bytes), execCmd) {
|
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)
|
sourceAndExec := fmt.Sprintf("%s; %s", sourceCmd, execCmd)
|
||||||
|
|
|
@ -23,7 +23,7 @@ var appCheckCommand = &cli.Command{
|
||||||
envSamplePath := path.Join(config.ABRA_DIR, "apps", app.Type, ".env.sample")
|
envSamplePath := path.Join(config.ABRA_DIR, "apps", app.Type, ".env.sample")
|
||||||
if _, err := os.Stat(envSamplePath); err != nil {
|
if _, err := os.Stat(envSamplePath); err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
logrus.Fatalf("'%s' does not exist?", envSamplePath)
|
logrus.Fatalf("%s does not exist?", envSamplePath)
|
||||||
}
|
}
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ var appCheckCommand = &cli.Command{
|
||||||
logrus.Fatalf("%s is missing %s", app.Path, missingEnvVars)
|
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
|
return nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -31,7 +31,7 @@ var appConfigCommand = &cli.Command{
|
||||||
|
|
||||||
appFile, exists := files[appName]
|
appFile, exists := files[appName]
|
||||||
if !exists {
|
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")
|
ed, ok := os.LookupEnv("EDITOR")
|
||||||
|
|
|
@ -60,7 +60,7 @@ var appRemoveCommand = &cli.Command{
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
if isDeployed {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ var appRestoreCommand = &cli.Command{
|
||||||
abraSh := path.Join(config.ABRA_DIR, "apps", app.Type, "abra.sh")
|
abraSh := path.Join(config.ABRA_DIR, "apps", app.Type, "abra.sh")
|
||||||
if _, err := os.Stat(abraSh); err != nil {
|
if _, err := os.Stat(abraSh); err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
logrus.Fatalf("'%s' does not exist?", abraSh)
|
logrus.Fatalf("%s does not exist?", abraSh)
|
||||||
}
|
}
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ var appRestoreCommand = &cli.Command{
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
if !strings.Contains(string(bytes), execCmd) {
|
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)
|
backupFile := c.Args().Get(2)
|
||||||
|
|
|
@ -50,7 +50,7 @@ recipes.
|
||||||
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 {
|
||||||
|
@ -58,7 +58,7 @@ recipes.
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isDeployed {
|
if !isDeployed {
|
||||||
logrus.Fatalf("'%s' is not deployed?", app.Name)
|
logrus.Fatalf("%s is not deployed?", app.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
catl, err := catalogue.ReadRecipeCatalogue()
|
catl, err := catalogue.ReadRecipeCatalogue()
|
||||||
|
@ -75,7 +75,7 @@ recipes.
|
||||||
if deployedVersion == "" {
|
if deployedVersion == "" {
|
||||||
deployedVersion = "unknown"
|
deployedVersion = "unknown"
|
||||||
availableDowngrades = versions
|
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 {
|
if deployedVersion != "unknown" && !internal.Chaos {
|
||||||
|
@ -108,10 +108,10 @@ recipes.
|
||||||
if !internal.Chaos {
|
if !internal.Chaos {
|
||||||
if internal.Force {
|
if internal.Force {
|
||||||
chosenDowngrade = availableDowngrades[0]
|
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 {
|
} else {
|
||||||
prompt := &survey.Select{
|
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,
|
Options: availableDowngrades,
|
||||||
}
|
}
|
||||||
if err := survey.AskOne(prompt, &chosenDowngrade); err != nil {
|
if err := survey.AskOne(prompt, &chosenDowngrade); err != nil {
|
||||||
|
|
|
@ -60,7 +60,7 @@ var appSecretGenerateCommand = &cli.Command{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !matches {
|
if !matches {
|
||||||
logrus.Fatalf("'%s' doesn't exist in the env config?", secretName)
|
logrus.Fatalf("%s doesn't exist in the env config?", secretName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ volumes as eligiblef or pruning once undeployed.
|
||||||
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 {
|
||||||
|
@ -35,7 +35,7 @@ volumes as eligiblef or pruning once undeployed.
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isDeployed {
|
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 {
|
if err := internal.DeployOverview(app, deployedVersion, "continue with undeploy?"); err != nil {
|
||||||
|
|
|
@ -142,7 +142,7 @@ A new catalogue copy can be published to the recipes repository by passing the
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isClean {
|
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 {
|
if err := gitPkg.EnsureUpToDate(recipeDir); err != nil {
|
||||||
|
|
|
@ -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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ var recipeVersionCommand = &cli.Command{
|
||||||
|
|
||||||
recipeMeta, ok := catalogue[recipe.Name]
|
recipeMeta, ok := catalogue[recipe.Name]
|
||||||
if !ok {
|
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"}
|
tableCol := []string{"Version", "Service", "Image", "Tag", "Digest"}
|
||||||
|
|
|
@ -46,7 +46,7 @@ are listed. This zone must already be created on your provider account.
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
default:
|
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)
|
records, err := provider.GetRecords(c.Context, zone)
|
||||||
|
|
|
@ -59,7 +59,7 @@ You may also invoke this command in "wizard" mode and be prompted for input
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
default:
|
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 {
|
if err := internal.EnsureDNSTypeFlag(c); err != nil {
|
||||||
|
|
|
@ -168,7 +168,7 @@ like tears in rain.
|
||||||
logrus.Fatal(err)
|
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
|
return nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -33,7 +33,7 @@ testing efforts!
|
||||||
cmd = exec.Command("bash", "-c", fmt.Sprintf("curl -s %s | bash -s -- --rc", releaseCandidateURL))
|
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 {
|
if err := internal.RunCmd(cmd); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
|
|
@ -23,7 +23,7 @@ func Get(appName string) (config.App, error) {
|
||||||
return config.App{}, err
|
return config.App{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("retrieved '%s' for '%s'", app, appName)
|
logrus.Debugf("retrieved %s for %s", app, appName)
|
||||||
|
|
||||||
return app, nil
|
return app, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// GetStringInBetween returns empty string if no start or end string found
|
||||||
s := strings.Index(str, start)
|
s := strings.Index(str, start)
|
||||||
if s == -1 {
|
if s == -1 {
|
||||||
return "", fmt.Errorf("marker string '%s' not found", start)
|
return "", fmt.Errorf("marker string %s not found", start)
|
||||||
}
|
}
|
||||||
s += len(start)
|
s += len(start)
|
||||||
e := strings.Index(str[s:], end)
|
e := strings.Index(str[s:], end)
|
||||||
if e == -1 {
|
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
|
return str[s : s+e], nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ func New(contextName string) (*client.Client, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("created client for '%s'", contextName)
|
logrus.Debugf("created client for %s", contextName)
|
||||||
|
|
||||||
return cl, nil
|
return cl, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ func CreateContext(contextName string, user string, port string) error {
|
||||||
if err := createContext(contextName, host); err != nil {
|
if err := createContext(contextName, host); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.Debugf("created the '%s' context", contextName)
|
logrus.Debugf("created the %s context", contextName)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ func GetTagDigest(cl *client.Client, image reference.Named) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if digest == "" {
|
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
|
return digest, nil
|
||||||
|
|
|
@ -22,7 +22,7 @@ func UpdateTag(pattern, image, tag, recipeName string) error {
|
||||||
return err
|
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 {
|
for _, composeFile := range composeFiles {
|
||||||
opts := stack.Deploy{Composefiles: []string{composeFile}}
|
opts := stack.Deploy{Composefiles: []string{composeFile}}
|
||||||
|
@ -57,7 +57,7 @@ func UpdateTag(pattern, image, tag, recipeName string) error {
|
||||||
}
|
}
|
||||||
composeTag := img.(reference.NamedTagged).Tag()
|
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 {
|
if image == composeImage {
|
||||||
bytes, err := ioutil.ReadFile(composeFile)
|
bytes, err := ioutil.ReadFile(composeFile)
|
||||||
|
@ -69,7 +69,7 @@ func UpdateTag(pattern, image, tag, recipeName string) error {
|
||||||
new := fmt.Sprintf("%s:%s", composeImage, tag)
|
new := fmt.Sprintf("%s:%s", composeImage, tag)
|
||||||
replacedBytes := strings.Replace(string(bytes), old, new, -1)
|
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 {
|
if err := ioutil.WriteFile(compose.Filename, []byte(replacedBytes), 0764); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -96,14 +96,14 @@ func (a ByName) Less(i, j int) bool {
|
||||||
func readAppEnvFile(appFile AppFile, name AppName) (App, error) {
|
func readAppEnvFile(appFile AppFile, name AppName) (App, error) {
|
||||||
env, err := ReadEnv(appFile.Path)
|
env, err := ReadEnv(appFile.Path)
|
||||||
if err != nil {
|
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)
|
app, err := newApp(env, name, appFile)
|
||||||
if err != nil {
|
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
|
return app, nil
|
||||||
|
|
|
@ -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()
|
ctx := context.Background()
|
||||||
ips, err := resolver.LookupIPAddr(ctx, domainName)
|
ips, err := resolver.LookupIPAddr(ctx, domainName)
|
||||||
|
|
|
@ -64,7 +64,7 @@ func (r Recipe) Tags() ([]string, error) {
|
||||||
return tags, err
|
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
|
return tags, nil
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ func EnsureVersion(recipeName, version string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isClean {
|
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 {
|
if err := gitPkg.EnsureGitRepo(recipeDir); err != nil {
|
||||||
|
|
|
@ -19,13 +19,13 @@ func PassInsertSecret(secretValue, secretName, appName, server string) error {
|
||||||
secretValue, server, appName, secretName,
|
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 {
|
if err := exec.Command("bash", "-c", cmd).Run(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("'%s' inserted into pass store", secretName)
|
logrus.Infof("%s inserted into pass store", secretName)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -41,13 +41,13 @@ func PassRmSecret(secretName, appName, server string) error {
|
||||||
server, appName, secretName,
|
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 {
|
if err := exec.Command("bash", "-c", cmd).Run(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("'%s' removed from pass store", secretName)
|
logrus.Infof("%s removed from pass store", secretName)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ func GeneratePasswords(count, length uint) ([]string, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("generated '%s'", strings.Join(passwords, ", "))
|
logrus.Debugf("generated %s", strings.Join(passwords, ", "))
|
||||||
|
|
||||||
return passwords, nil
|
return passwords, nil
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ func GeneratePassphrases(count uint) ([]string, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("generated '%s'", strings.Join(passphrases, ", "))
|
logrus.Debugf("generated %s", strings.Join(passphrases, ", "))
|
||||||
|
|
||||||
return passphrases, nil
|
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
|
return secretEnvVars
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ func ParseSecretEnvVarName(secretEnvVar string) string {
|
||||||
withoutPrefix := strings.TrimPrefix(secretEnvVar, "SECRET_")
|
withoutPrefix := strings.TrimPrefix(secretEnvVar, "SECRET_")
|
||||||
withoutSuffix := strings.TrimSuffix(withoutPrefix, "_VERSION")
|
withoutSuffix := strings.TrimSuffix(withoutPrefix, "_VERSION")
|
||||||
name := strings.ToLower(withoutSuffix)
|
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
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ func ParseGeneratedSecretName(secret string, appEnv config.App) string {
|
||||||
withoutAppName := strings.TrimPrefix(secret, name)
|
withoutAppName := strings.TrimPrefix(secret, name)
|
||||||
idx := strings.LastIndex(withoutAppName, "_")
|
idx := strings.LastIndex(withoutAppName, "_")
|
||||||
parsed := withoutAppName[:idx]
|
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
|
return parsed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ func ParseGeneratedSecretName(secret string, appEnv config.App) string {
|
||||||
func ParseSecretEnvVarValue(secret string) (secretValue, error) {
|
func ParseSecretEnvVarValue(secret string) (secretValue, error) {
|
||||||
values := strings.Split(secret, "#")
|
values := strings.Split(secret, "#")
|
||||||
if len(values) == 0 {
|
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 {
|
if len(values) == 1 {
|
||||||
|
@ -113,7 +113,7 @@ func ParseSecretEnvVarValue(secret string) (secretValue, error) {
|
||||||
}
|
}
|
||||||
version := strings.ReplaceAll(values[0], " ", "")
|
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
|
return secretValue{Version: version, Length: length}, nil
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ func GenerateSecrets(secretEnvVars map[string]string, appName, server string) (m
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
secretRemoteName := fmt.Sprintf("%s_%s_%s", appName, secretName, secretValue.Version)
|
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 {
|
if secretValue.Length > 0 {
|
||||||
passwords, err := GeneratePasswords(1, uint(secretValue.Length))
|
passwords, err := GeneratePasswords(1, uint(secretValue.Length))
|
||||||
if err != nil {
|
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
|
return secrets, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue