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

Commit

Permalink
revise
Browse files Browse the repository at this point in the history
Signed-off-by: Lixia (Sylvia) Lei <[email protected]>
  • Loading branch information
Wwwsylvia committed Sep 22, 2023
1 parent 8ed30b1 commit e5c5b08
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
14 changes: 7 additions & 7 deletions file_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
// Reference: https://docs.docker.com/engine/reference/commandline/cli/#docker-cli-configuration-file-configjson-properties
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
type FileStore struct {
// DisablePut disables putting credentials in plaintext.
// If DisablePut is set to true, Put() will return ErrPlaintextPutDisabled.
Expand All @@ -45,13 +45,13 @@ var (
// to true.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
ErrPlaintextPutDisabled = errors.New("putting plaintext credentials is disabled")
// ErrBadCredentialFormat is returned by Put() when the credential format
// is bad.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
ErrBadCredentialFormat = errors.New("bad credential format")
)

Expand All @@ -60,7 +60,7 @@ var (
// Reference: https://docs.docker.com/engine/reference/commandline/cli/#docker-cli-configuration-file-configjson-properties
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func NewFileStore(configPath string) (*FileStore, error) {
cfg, err := config.Load(configPath)
if err != nil {
Expand All @@ -77,7 +77,7 @@ func newFileStore(cfg *config.Config) *FileStore {
// Get retrieves credentials from the store for the given server address.
//
// Deprecated: This method is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (fs *FileStore) Get(_ context.Context, serverAddress string) (auth.Credential, error) {
return fs.config.GetCredential(serverAddress)
}
Expand All @@ -86,7 +86,7 @@ func (fs *FileStore) Get(_ context.Context, serverAddress string) (auth.Credenti
// Returns ErrPlaintextPutDisabled if fs.DisablePut is set to true.
//
// Deprecated: This method is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (fs *FileStore) Put(_ context.Context, serverAddress string, cred auth.Credential) error {
if fs.DisablePut {
return ErrPlaintextPutDisabled
Expand All @@ -101,7 +101,7 @@ func (fs *FileStore) Put(_ context.Context, serverAddress string, cred auth.Cred
// Delete removes credentials from the store for the given server address.
//
// Deprecated: This method is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (fs *FileStore) Delete(_ context.Context, serverAddress string) error {
return fs.config.DeleteCredential(serverAddress)
}
Expand Down
10 changes: 5 additions & 5 deletions memory_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ import (
// MemoryStore is a store that keeps credentials in memory.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
type MemoryStore struct {
store sync.Map
}

// NewMemoryStore creates a new in-memory credentials store.
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func NewMemoryStore() *MemoryStore {
return &MemoryStore{}
}

// Get retrieves credentials from the store for the given server address.
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (ms *MemoryStore) Get(_ context.Context, serverAddress string) (auth.Credential, error) {
cred, found := ms.store.Load(serverAddress)
if !found {
Expand All @@ -53,7 +53,7 @@ func (ms *MemoryStore) Get(_ context.Context, serverAddress string) (auth.Creden
// Put saves credentials into the store for the given server address.
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (ms *MemoryStore) Put(_ context.Context, serverAddress string, cred auth.Credential) error {
ms.store.Store(serverAddress, cred)
return nil
Expand All @@ -62,7 +62,7 @@ func (ms *MemoryStore) Put(_ context.Context, serverAddress string, cred auth.Cr
// Delete removes credentials from the store for the given server address.
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (ms *MemoryStore) Delete(_ context.Context, serverAddress string) error {
ms.store.Delete(serverAddress)
return nil
Expand Down
4 changes: 2 additions & 2 deletions native_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type nativeStore struct {
// - https://docs.docker.com/engine/reference/commandline/login#credentials-store
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func NewNativeStore(helperSuffix string) Store {
return &nativeStore{
exec: executer.New(remoteCredentialsPrefix + helperSuffix),
Expand All @@ -77,7 +77,7 @@ func NewNativeStore(helperSuffix string) Store {
// - https://docs.docker.com/engine/reference/commandline/login/#credentials-store
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func NewDefaultNativeStore() (Store, bool) {
if helper := getDefaultHelperSuffix(); helper != "" {
return NewNativeStore(helper), true
Expand Down
12 changes: 6 additions & 6 deletions registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
// is not supported.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
var ErrClientTypeUnsupported = errors.New("client type not supported")

// Login provides the login functionality with the given credentials. The target
Expand All @@ -37,7 +37,7 @@ var ErrClientTypeUnsupported = errors.New("client type not supported")
// the registry.
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func Login(ctx context.Context, store Store, reg *remote.Registry, cred auth.Credential) error {
// create a clone of the original registry for login purpose
regClone := *reg
Expand Down Expand Up @@ -68,7 +68,7 @@ func Login(ctx context.Context, store Store, reg *remote.Registry, cred auth.Cre
// Logout provides the logout functionality given the registry name.
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func Logout(ctx context.Context, store Store, registryName string) error {
registryName = ServerAddressFromRegistry(registryName)
if err := store.Delete(ctx, registryName); err != nil {
Expand All @@ -80,7 +80,7 @@ func Logout(ctx context.Context, store Store, registryName string) error {
// Credential returns a Credential() function that can be used by auth.Client.
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func Credential(store Store) func(context.Context, string) (auth.Credential, error) {
return func(ctx context.Context, reg string) (auth.Credential, error) {
reg = ServerAddressFromHostname(reg)
Expand All @@ -97,7 +97,7 @@ func Credential(store Store) func(context.Context, string) (auth.Credential, err
// See: https://github.com/moby/moby/blob/v24.0.2/registry/config.go#L25-L48
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func ServerAddressFromRegistry(registry string) string {
if registry == "docker.io" {
return "https://index.docker.io/v1/"
Expand All @@ -111,7 +111,7 @@ func ServerAddressFromRegistry(registry string) string {
// See: https://github.com/moby/moby/blob/v24.0.2/registry/config.go#L25-L48
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func ServerAddressFromHostname(hostname string) string {
if hostname == "registry-1.docker.io" {
return "https://index.docker.io/v1/"
Expand Down
24 changes: 12 additions & 12 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ limitations under the License.
*/

// Deprecated: This package is deprecated.
// The same functionality is now provided by [oras-go v2].
// The same functionality is now provided by [oras-go].
//
// [oras-go v2]: https://pkg.go.dev/oras.land/oras-go/v2/registry/remote/credentials
// [oras-go]: https://pkg.go.dev/oras.land/oras-go/v2/registry/remote/credentials
package credentials

import (
Expand All @@ -39,7 +39,7 @@ const (
// Store is the interface that any credentials store must implement.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
type Store interface {
// Get retrieves credentials from the store for the given server address.
Get(ctx context.Context, serverAddress string) (auth.Credential, error)
Expand All @@ -53,7 +53,7 @@ type Store interface {
// in the config file.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
type DynamicStore struct {
config *config.Config
options StoreOptions
Expand All @@ -64,7 +64,7 @@ type DynamicStore struct {
// StoreOptions provides options for NewStore.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
type StoreOptions struct {
// AllowPlaintextPut allows saving credentials in plaintext in the config
// file.
Expand Down Expand Up @@ -104,7 +104,7 @@ type StoreOptions struct {
// - https://docs.docker.com/engine/reference/commandline/cli/#docker-cli-configuration-file-configjson-properties
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func NewStore(configPath string, opts StoreOptions) (*DynamicStore, error) {
cfg, err := config.Load(configPath)
if err != nil {
Expand Down Expand Up @@ -133,7 +133,7 @@ func NewStore(configPath string, opts StoreOptions) (*DynamicStore, error) {
// - https://docs.docker.com/engine/reference/commandline/cli/#change-the-docker-directory
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func NewStoreFromDocker(opt StoreOptions) (*DynamicStore, error) {
configPath, err := getDockerConfigPath()
if err != nil {
Expand All @@ -145,7 +145,7 @@ func NewStoreFromDocker(opt StoreOptions) (*DynamicStore, error) {
// Get retrieves credentials from the store for the given server address.
//
// Deprecated: This method is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (ds *DynamicStore) Get(ctx context.Context, serverAddress string) (auth.Credential, error) {
return ds.getStore(serverAddress).Get(ctx, serverAddress)
}
Expand All @@ -155,7 +155,7 @@ func (ds *DynamicStore) Get(ctx context.Context, serverAddress string) (auth.Cre
// [StoreOptions].AllowPlaintextPut is set to false.
//
// Deprecated: This method is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (ds *DynamicStore) Put(ctx context.Context, serverAddress string, cred auth.Credential) (returnErr error) {
if err := ds.getStore(serverAddress).Put(ctx, serverAddress, cred); err != nil {
return err
Expand All @@ -174,7 +174,7 @@ func (ds *DynamicStore) Put(ctx context.Context, serverAddress string, cred auth
// Delete removes credentials from the store for the given server address.
//
// Deprecated: This method is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (ds *DynamicStore) Delete(ctx context.Context, serverAddress string) error {
return ds.getStore(serverAddress).Delete(ctx, serverAddress)
}
Expand All @@ -188,7 +188,7 @@ func (ds *DynamicStore) Delete(ctx context.Context, serverAddress string) error
// - Or there is any entry in the "auths" field
//
// Deprecated: This method is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func (ds *DynamicStore) IsAuthConfigured() bool {
return ds.config.IsAuthConfigured()
}
Expand Down Expand Up @@ -247,7 +247,7 @@ type storeWithFallbacks struct {
// - Delete() deletes the credentials from the primary store.
//
// Deprecated: This function is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func NewStoreWithFallbacks(primary Store, fallbacks ...Store) Store {
if len(fallbacks) == 0 {
return primary
Expand Down
10 changes: 5 additions & 5 deletions trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ limitations under the License.
*/

// Deprecated: This package is deprecated.
// The same functionality is now provided by [oras-go v2].
// The same functionality is now provided by [oras-go].
//
// [oras-go v2]: https://pkg.go.dev/oras.land/oras-go/v2/registry/remote/credentials/trace
// [oras-go]: https://pkg.go.dev/oras.land/oras-go/v2/registry/remote/credentials/trace
package trace

import (
Expand All @@ -31,7 +31,7 @@ type executableTraceContextKey struct{}
// executables. Any particular hook may be nil.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
type ExecutableTrace struct {
// ExecuteStart is called before the execution of the executable. The
// executableName parameter is the name of the credential helper executable
Expand All @@ -57,7 +57,7 @@ type ExecutableTrace struct {
// context. If none, it returns nil.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func ContextExecutableTrace(ctx context.Context) *ExecutableTrace {
trace, _ := ctx.Value(executableTraceContextKey{}).(*ExecutableTrace)
return trace
Expand All @@ -69,7 +69,7 @@ func ContextExecutableTrace(ctx context.Context) *ExecutableTrace {
// in addition to the previous ones. The recent hooks will be called first.
//
// Deprecated: This type is deprecated.
// The same functionality is now provided by oras-go v2.
// The same functionality is now provided by oras-go.
func WithExecutableTrace(ctx context.Context, trace *ExecutableTrace) context.Context {
if trace == nil {
return ctx
Expand Down

0 comments on commit e5c5b08

Please sign in to comment.