credstore.go 841 B

123456789101112131415161718192021222324252627282930313233343536
  1. package credstore
  2. import "github.com/docker/docker-credential-helpers/credentials"
  3. const (
  4. url = "https://github.com/porter-dev/porter"
  5. label = "Porter Credentials"
  6. )
  7. // Set stores a given username/pw with a given credentials label in the OS-specific
  8. // credentials store
  9. func Set(username, pw string) error {
  10. cr := &credentials.Credentials{
  11. ServerURL: url,
  12. Username: username,
  13. Secret: pw,
  14. }
  15. credentials.SetCredsLabel(label)
  16. return ns.Add(cr)
  17. }
  18. // Get retrieves a given username/pw with a given credentials label in the OS-specific
  19. // credentials store
  20. func Get() (string, string, error) {
  21. credentials.SetCredsLabel(label)
  22. return ns.Get(url)
  23. }
  24. // Del removes a given credential that uses a label in the OS-specific
  25. // credentials store
  26. func Del() error {
  27. credentials.SetCredsLabel(label)
  28. return ns.Delete(url)
  29. }