Skip to content
This repository was archived by the owner on Apr 7, 2024. It is now read-only.

Commit 8f27cf8

Browse files
fix: make Native Store private (#48)
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
1 parent 9d0706f commit 8f27cf8

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

native_store.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ const (
2828
emptyUsername = "<token>"
2929
)
3030

31-
// NativeStore implements a credentials store using native keychain to keep
31+
// nativeStore implements a credentials store using native keychain to keep
3232
// credentials secure.
33-
type NativeStore struct {
33+
type nativeStore struct {
3434
programFunc client.ProgramFunc
3535
}
3636

3737
// NewNativeStore creates a new native store that uses a remote helper program to
3838
// manage credentials.
3939
func NewNativeStore(helperSuffix string) Store {
40-
return &NativeStore{
40+
return &nativeStore{
4141
programFunc: client.NewShellProgramFunc(remoteCredentialsPrefix + helperSuffix),
4242
}
4343
}
4444

4545
// Get retrieves credentials from the store for the given server.
46-
func (ns *NativeStore) Get(_ context.Context, serverAddress string) (auth.Credential, error) {
46+
func (ns *nativeStore) Get(_ context.Context, serverAddress string) (auth.Credential, error) {
4747
var cred auth.Credential
4848
dockerCred, err := client.Get(ns.programFunc, serverAddress)
4949
if err != nil {
@@ -64,7 +64,7 @@ func (ns *NativeStore) Get(_ context.Context, serverAddress string) (auth.Creden
6464
}
6565

6666
// Put saves credentials into the store.
67-
func (ns *NativeStore) Put(_ context.Context, serverAddress string, cred auth.Credential) error {
67+
func (ns *nativeStore) Put(_ context.Context, serverAddress string, cred auth.Credential) error {
6868
dockerCred := &credentials.Credentials{
6969
ServerURL: serverAddress,
7070
Username: cred.Username,
@@ -78,6 +78,6 @@ func (ns *NativeStore) Put(_ context.Context, serverAddress string, cred auth.Cr
7878
}
7979

8080
// Delete removes credentials from the store for the given server.
81-
func (ns *NativeStore) Delete(_ context.Context, serverAddress string) error {
81+
func (ns *nativeStore) Delete(_ context.Context, serverAddress string) error {
8282
return client.Erase(ns.programFunc, serverAddress)
8383
}

native_store_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ func testCommandFn(args ...string) client.Program {
101101
}
102102

103103
func TestNativeStore_interface(t *testing.T) {
104-
var ns interface{} = &NativeStore{}
104+
var ns interface{} = &nativeStore{}
105105
if _, ok := ns.(Store); !ok {
106106
t.Error("&NativeStore{} does not conform Store")
107107
}
108108
}
109109

110110
func TestNativeStore_basicAuth(t *testing.T) {
111-
ns := &NativeStore{
111+
ns := &nativeStore{
112112
programFunc: testCommandFn,
113113
}
114114
// Put
@@ -135,7 +135,7 @@ func TestNativeStore_basicAuth(t *testing.T) {
135135
}
136136

137137
func TestNativeStore_refreshToken(t *testing.T) {
138-
ns := &NativeStore{
138+
ns := &nativeStore{
139139
programFunc: testCommandFn,
140140
}
141141
// Put

0 commit comments

Comments
 (0)