mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
Merge pull request #205 from thaJeztah/fix_ci2
travis: temporarily disabling ppc64le, and fix some linting issues
This commit is contained in:
+1
-2
@@ -7,7 +7,6 @@
|
|||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
- osx
|
- osx
|
||||||
- linux-ppc64le
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
go:
|
go:
|
||||||
@@ -20,6 +19,6 @@
|
|||||||
before_script:
|
before_script:
|
||||||
- make deps
|
- make deps
|
||||||
- "export DISPLAY=:99.0"
|
- "export DISPLAY=:99.0"
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$HOSTTYPE" != "powerpc64le" ]]; then sh ci/before_script_linux.sh; fi
|
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh ci/before_script_linux.sh; fi
|
||||||
- make validate
|
- make validate
|
||||||
script: make test
|
script: make test
|
||||||
|
|||||||
+13
-12
@@ -1,7 +1,7 @@
|
|||||||
// A `pass` based credential helper. Passwords are stored as arguments to pass
|
// Package pass implements a `pass` based credential helper. Passwords are stored
|
||||||
// of the form: "$PASS_FOLDER/base64-url(serverURL)/username". We base64-url
|
// as arguments to pass of the form: "$PASS_FOLDER/base64-url(serverURL)/username".
|
||||||
// encode the serverURL, because under the hood pass uses files and folders, so
|
// We base64-url encode the serverURL, because under the hood pass uses files and
|
||||||
// /s will get translated into additional folders.
|
// folders, so /s will get translated into additional folders.
|
||||||
package pass
|
package pass
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -19,7 +19,8 @@ import (
|
|||||||
"github.com/docker/docker-credential-helpers/credentials"
|
"github.com/docker/docker-credential-helpers/credentials"
|
||||||
)
|
)
|
||||||
|
|
||||||
const PASS_FOLDER = "docker-credential-helpers"
|
// PASS_FOLDER contains the directory where credentials are stored
|
||||||
|
const PASS_FOLDER = "docker-credential-helpers" //nolint: golint
|
||||||
|
|
||||||
// Pass handles secrets using Linux secret-service as a store.
|
// Pass handles secrets using Linux secret-service as a store.
|
||||||
type Pass struct{}
|
type Pass struct{}
|
||||||
@@ -79,25 +80,25 @@ func (p Pass) runPassHelper(stdinContent string, args ...string) (string, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add adds new credentials to the keychain.
|
// Add adds new credentials to the keychain.
|
||||||
func (h Pass) Add(creds *credentials.Credentials) error {
|
func (p Pass) Add(creds *credentials.Credentials) error {
|
||||||
if creds == nil {
|
if creds == nil {
|
||||||
return errors.New("missing credentials")
|
return errors.New("missing credentials")
|
||||||
}
|
}
|
||||||
|
|
||||||
encoded := base64.URLEncoding.EncodeToString([]byte(creds.ServerURL))
|
encoded := base64.URLEncoding.EncodeToString([]byte(creds.ServerURL))
|
||||||
|
|
||||||
_, err := h.runPass(creds.Secret, "insert", "-f", "-m", path.Join(PASS_FOLDER, encoded, creds.Username))
|
_, err := p.runPass(creds.Secret, "insert", "-f", "-m", path.Join(PASS_FOLDER, encoded, creds.Username))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete removes credentials from the store.
|
// Delete removes credentials from the store.
|
||||||
func (h Pass) Delete(serverURL string) error {
|
func (p Pass) Delete(serverURL string) error {
|
||||||
if serverURL == "" {
|
if serverURL == "" {
|
||||||
return errors.New("missing server url")
|
return errors.New("missing server url")
|
||||||
}
|
}
|
||||||
|
|
||||||
encoded := base64.URLEncoding.EncodeToString([]byte(serverURL))
|
encoded := base64.URLEncoding.EncodeToString([]byte(serverURL))
|
||||||
_, err := h.runPass("", "rm", "-rf", path.Join(PASS_FOLDER, encoded))
|
_, err := p.runPass("", "rm", "-rf", path.Join(PASS_FOLDER, encoded))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +129,7 @@ func listPassDir(args ...string) ([]os.FileInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get returns the username and secret to use for a given registry server URL.
|
// Get returns the username and secret to use for a given registry server URL.
|
||||||
func (h Pass) Get(serverURL string) (string, string, error) {
|
func (p Pass) Get(serverURL string) (string, string, error) {
|
||||||
if serverURL == "" {
|
if serverURL == "" {
|
||||||
return "", "", errors.New("missing server url")
|
return "", "", errors.New("missing server url")
|
||||||
}
|
}
|
||||||
@@ -153,12 +154,12 @@ func (h Pass) Get(serverURL string) (string, string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actual := strings.TrimSuffix(usernames[0].Name(), ".gpg")
|
actual := strings.TrimSuffix(usernames[0].Name(), ".gpg")
|
||||||
secret, err := h.runPass("", "show", path.Join(PASS_FOLDER, encoded, actual))
|
secret, err := p.runPass("", "show", path.Join(PASS_FOLDER, encoded, actual))
|
||||||
return actual, secret, err
|
return actual, secret, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// List returns the stored URLs and corresponding usernames for a given credentials label
|
// List returns the stored URLs and corresponding usernames for a given credentials label
|
||||||
func (h Pass) List() (map[string]string, error) {
|
func (p Pass) List() (map[string]string, error) {
|
||||||
servers, err := listPassDir()
|
servers, err := listPassDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ import (
|
|||||||
url "net/url"
|
url "net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetHostname returns the hostname of the URL
|
||||||
func GetHostname(u *url.URL) string {
|
func GetHostname(u *url.URL) string {
|
||||||
return u.Hostname()
|
return u.Hostname()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPort returns the port number of the URL
|
||||||
func GetPort(u *url.URL) string {
|
func GetPort(u *url.URL) string {
|
||||||
return u.Port()
|
return u.Port()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,14 @@ func TestSecretServiceHelper(t *testing.T) {
|
|||||||
helper := Secretservice{}
|
helper := Secretservice{}
|
||||||
|
|
||||||
// Check how many docker credentials we have when starting the test
|
// Check how many docker credentials we have when starting the test
|
||||||
old_auths, err := helper.List()
|
oldAuths, err := helper.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If any docker credentials with the tests values we are providing, we
|
// If any docker credentials with the tests values we are providing, we
|
||||||
// remove them as they probably come from a previous failed test
|
// remove them as they probably come from a previous failed test
|
||||||
for k, v := range old_auths {
|
for k, v := range oldAuths {
|
||||||
if strings.Compare(k, creds.ServerURL) == 0 && strings.Compare(v, creds.Username) == 0 {
|
if strings.Compare(k, creds.ServerURL) == 0 && strings.Compare(v, creds.Username) == 0 {
|
||||||
|
|
||||||
if err := helper.Delete(creds.ServerURL); err != nil {
|
if err := helper.Delete(creds.ServerURL); err != nil {
|
||||||
@@ -36,7 +36,7 @@ func TestSecretServiceHelper(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check again how many docker credentials we have when starting the test
|
// Check again how many docker credentials we have when starting the test
|
||||||
old_auths, err = helper.List()
|
oldAuths, err = helper.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -61,11 +61,11 @@ func TestSecretServiceHelper(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We should have one more credential than before adding
|
// We should have one more credential than before adding
|
||||||
new_auths, err := helper.List()
|
newAuths, err := helper.List()
|
||||||
if err != nil || (len(new_auths)-len(old_auths) != 1) {
|
if err != nil || (len(newAuths)-len(oldAuths) != 1) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
old_auths = new_auths
|
oldAuths = newAuths
|
||||||
|
|
||||||
// Deleting the credentials associated to current server url should succeed
|
// Deleting the credentials associated to current server url should succeed
|
||||||
if err := helper.Delete(creds.ServerURL); err != nil {
|
if err := helper.Delete(creds.ServerURL); err != nil {
|
||||||
@@ -73,8 +73,8 @@ func TestSecretServiceHelper(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We should have one less credential than before deleting
|
// We should have one less credential than before deleting
|
||||||
new_auths, err = helper.List()
|
newAuths, err = helper.List()
|
||||||
if err != nil || (len(old_auths)-len(new_auths) != 1) {
|
if err != nil || (len(oldAuths)-len(newAuths) != 1) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user