...

Source file src/github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cache/mocks/cache_mocks.go

Documentation: github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cache/mocks

     1  // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"). You may
     4  // not use this file except in compliance with the License. A copy of the
     5  // License is located at
     6  //
     7  //     http://aws.amazon.com/apache2.0/
     8  //
     9  // or in the "license" file accompanying this file. This file is distributed
    10  // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
    11  // express or implied. See the License for the specific language governing
    12  // permissions and limitations under the License.
    13  
    14  package mock_cache
    15  
    16  import (
    17  	"github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cache"
    18  )
    19  
    20  type MockCredentialsCache struct {
    21  	GetFn       func(registry string) *cache.AuthEntry
    22  	GetPublicFn func() *cache.AuthEntry
    23  	SetFn       func(registry string, entry *cache.AuthEntry)
    24  	ListFn      func() []*cache.AuthEntry
    25  	ClearFn     func()
    26  }
    27  
    28  var _ cache.CredentialsCache = (*MockCredentialsCache)(nil)
    29  
    30  func (m MockCredentialsCache) Get(registry string) *cache.AuthEntry {
    31  	return m.GetFn(registry)
    32  }
    33  
    34  func (m MockCredentialsCache) GetPublic() *cache.AuthEntry {
    35  	return m.GetPublicFn()
    36  }
    37  
    38  func (m MockCredentialsCache) Set(registry string, entry *cache.AuthEntry) {
    39  	m.SetFn(registry, entry)
    40  }
    41  
    42  func (m MockCredentialsCache) List() []*cache.AuthEntry {
    43  	return m.ListFn()
    44  }
    45  
    46  func (m MockCredentialsCache) Clear() {
    47  	m.ClearFn()
    48  }
    49  

View as plain text