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

Commit 423c434

Browse files
authored
feat: define Store interface (#38)
Resolves #27 Signed-off-by: Sylvia Lei <lixlei@microsoft.com>
1 parent a03bb24 commit 423c434

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
module github.com/oras-project/oras-credentials-go
22

33
go 1.19
4+
5+
require oras.land/oras-go/v2 v2.0.2
6+
7+
require golang.org/x/sync v0.1.0 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
2+
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
3+
oras.land/oras-go/v2 v2.0.2 h1:3aSQdJ7EUC0ft2e9PjJB9Jzastz5ojPA4LzZ3Q4YbUc=
4+
oras.land/oras-go/v2 v2.0.2/go.mod h1:PWnWc/Kyyg7wUTUsDHshrsJkzuxXzreeMd6NrfdnFSo=

store.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright The ORAS Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package credentials
17+
18+
import (
19+
"context"
20+
21+
"oras.land/oras-go/v2/registry/remote/auth"
22+
)
23+
24+
// Store is the interface that any credentials store must implement.
25+
type Store interface {
26+
// Get retrieves credentials from the store for the given server address.
27+
Get(ctx context.Context, serverAddress string) (auth.Credential, error)
28+
// Put saves credentials into the store for the given server address.
29+
Put(ctx context.Context, serverAddress string, cred auth.Credential) error
30+
// Delete removes credentials from the store for the given server address.
31+
Delete(ctx context.Context, serverAddress string) error
32+
}

0 commit comments

Comments
 (0)