Documentation ¶
Index ¶
- Variables
- type Secret
- type SecretKey
- type Secrets
- type Service
- func (s *Service) Create(name, privateKeyPath string) (string, error)
- func (s *Service) CredentialsFromLocation(secret string) (*cred.Config, error)
- func (s *Service) CredentialsLocation(secret string) (string, error)
- func (s *Service) Expand(input string, credentials map[SecretKey]Secret) (string, error)
- func (s *Service) GetCredentials(secret string) (*cred.Config, error)
- func (s *Service) GetOrCreate(secret string) (*cred.Config, error)
Constants ¶
This section is empty.
Variables ¶
var ReadUserAndPassword = func(timeout time.Duration) (user string, pass string, err error) { completed := make(chan bool) var reader = func() { defer func() { completed <- true }() var bytePassword, bytePassword2 []byte reader := bufio.NewReader(os.Stdin) fmt.Print("Enter Username: ") user, _ = reader.ReadString('\n') fmt.Print("Enter Password: ") bytePassword, err = terminal.ReadPassword(int(syscall.Stdin)) if err != nil { err = fmt.Errorf("failed to read password %v", err) return } fmt.Print("\nRetype Password: ") bytePassword2, err = terminal.ReadPassword(int(syscall.Stdin)) if err != nil { err = fmt.Errorf("failed to read password %v", err) return } password := string(bytePassword) if string(bytePassword2) != password { err = errors.New("password did not match") } } go reader() select { case <-completed: case <-time.After(timeout): err = fmt.Errorf("reading credential timeout") } user = strings.TrimSpace(user) pass = strings.TrimSpace(pass) return user, pass, err }
var ReadingCredentialTimeout = time.Second * 45
ReadingCredentialTimeout represents max time for providing CredentialsFromLocation
Functions ¶
This section is empty.
Types ¶
type Secret ¶
type Secret string
Secret represents a secret
func (Secret) IsLocation ¶
IsLocation returns true if secret is a location
type SecretKey ¶
type SecretKey string
* SecretKey represent secret key Take the following secrets as example: <pre>
"secrets": { "git": "${env.HOME}/.secret/git.json", "github.com": "${env.HOME}/.secret/github.json", "github.private.com": "${env.HOME}/.secret/github-private.json", "**replace**": "${env.HOME}/.secret/git.json", }
</pre>
The secret key can be static or dynamic. The first type is already enclosed with '*' or '#', the later is not.
In the command corresponding dynamic key can be enclosed with the following '**' for password expansion i.e. command: **git** will expand to password from git secret key '##' for username expansion i.e. command: ##git## will expand to username from git secret key
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
represents a secret service
func (*Service) CredentialsFromLocation ¶
Credentials returns credential config for supplied location.
func (*Service) CredentialsLocation ¶
func (*Service) GetCredentials ¶
Credentials returns credential config