forked from toolshed/abra
docs: more doc strings for secret package
This commit is contained in:
parent
4e92057f61
commit
5e4114036b
@ -21,6 +21,7 @@ type secretValue struct {
|
|||||||
Length int
|
Length int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GeneratePasswords generates passwords.
|
||||||
func GeneratePasswords(count, length uint) ([]string, error) {
|
func GeneratePasswords(count, length uint) ([]string, error) {
|
||||||
passwords, err := passgen.GeneratePasswords(
|
passwords, err := passgen.GeneratePasswords(
|
||||||
count,
|
count,
|
||||||
@ -35,6 +36,7 @@ func GeneratePasswords(count, length uint) ([]string, error) {
|
|||||||
return passwords, nil
|
return passwords, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GeneratePassphrases generates human readable and rememberable passphrases.
|
||||||
func GeneratePassphrases(count uint) ([]string, error) {
|
func GeneratePassphrases(count uint) ([]string, error) {
|
||||||
passphrases, err := passgen.GeneratePassphrases(
|
passphrases, err := passgen.GeneratePassphrases(
|
||||||
count,
|
count,
|
||||||
@ -62,12 +64,14 @@ func ReadSecretEnvVars(appEnv config.AppEnv) map[string]string {
|
|||||||
return secretEnvVars
|
return secretEnvVars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: should probably go in the config/app package?
|
||||||
func ParseSecretEnvVarName(secretEnvVar string) string {
|
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")
|
||||||
return strings.ToLower(withoutSuffix)
|
return strings.ToLower(withoutSuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: should probably go in the config/app package?
|
||||||
func ParseGeneratedSecretName(secret string, appEnv config.App) string {
|
func ParseGeneratedSecretName(secret string, appEnv config.App) string {
|
||||||
name := fmt.Sprintf("%s_", appEnv.StackName())
|
name := fmt.Sprintf("%s_", appEnv.StackName())
|
||||||
withoutAppName := strings.TrimPrefix(secret, name)
|
withoutAppName := strings.TrimPrefix(secret, name)
|
||||||
@ -75,6 +79,7 @@ func ParseGeneratedSecretName(secret string, appEnv config.App) string {
|
|||||||
return withoutAppName[:idx]
|
return withoutAppName[:idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: should probably go in the config/app package?
|
||||||
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 {
|
||||||
@ -95,6 +100,7 @@ func ParseSecretEnvVarValue(secret string) (secretValue, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GenerateSecrets generates secrets locally and sends them to a remote server for storage.
|
||||||
func GenerateSecrets(secretEnvVars map[string]string, appName, server string) (map[string]string, error) {
|
func GenerateSecrets(secretEnvVars map[string]string, appName, server string) (map[string]string, error) {
|
||||||
secrets := make(map[string]string)
|
secrets := make(map[string]string)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user