cache

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcKey

func CalcKey(id string, analyzerVersions analyzer.Versions, hookVersions map[string]int, artifactOpt artifact.Option) (string, error)

func DefaultDir

func DefaultDir() string

DefaultDir returns/creates the cache-dir to be used for tunnel operations

func GetTLSConfig

func GetTLSConfig(caCertPath, certPath, keyPath string) (*x509.CertPool, tls.Certificate, error)

GetTLSConfig gets tls config from CA, Cert and Key file

Types

type ArtifactCache

type ArtifactCache interface {
	// MissingBlobs returns missing blob IDs such as layer IDs in cache
	MissingBlobs(artifactID string, blobIDs []string) (missingArtifact bool, missingBlobIDs []string, err error)

	// PutArtifact stores artifact information such as image metadata in cache
	PutArtifact(artifactID string, artifactInfo types.ArtifactInfo) (err error)

	// PutBlob stores blob information such as layer information in local cache
	PutBlob(blobID string, blobInfo types.BlobInfo) (err error)

	// DeleteBlobs removes blobs by IDs
	DeleteBlobs(blobIDs []string) error
}

ArtifactCache uses local or remote cache

type ArtifactCacheDeleteBlobsArgs

type ArtifactCacheDeleteBlobsArgs struct {
	BlobIDs         []string
	BlobIDsAnything bool
}

type ArtifactCacheDeleteBlobsExpectation

type ArtifactCacheDeleteBlobsExpectation struct {
	Args    ArtifactCacheDeleteBlobsArgs
	Returns ArtifactCacheDeleteBlobsReturns
}

type ArtifactCacheDeleteBlobsReturns

type ArtifactCacheDeleteBlobsReturns struct {
	// contains filtered or unexported fields
}

type ArtifactCacheMissingBlobsArgs

type ArtifactCacheMissingBlobsArgs struct {
	ArtifactID         string
	ArtifactIDAnything bool
	BlobIDs            []string
	BlobIDsAnything    bool
}

type ArtifactCacheMissingBlobsExpectation

type ArtifactCacheMissingBlobsExpectation struct {
	Args    ArtifactCacheMissingBlobsArgs
	Returns ArtifactCacheMissingBlobsReturns
}

type ArtifactCacheMissingBlobsReturns

type ArtifactCacheMissingBlobsReturns struct {
	MissingArtifact bool
	MissingBlobIDs  []string
	Err             error
}

type ArtifactCachePutArtifactArgs

type ArtifactCachePutArtifactArgs struct {
	ArtifactID           string
	ArtifactIDAnything   bool
	ArtifactInfo         types.ArtifactInfo
	ArtifactInfoAnything bool
}

type ArtifactCachePutArtifactExpectation

type ArtifactCachePutArtifactExpectation struct {
	Args    ArtifactCachePutArtifactArgs
	Returns ArtifactCachePutArtifactReturns
}

type ArtifactCachePutArtifactReturns

type ArtifactCachePutArtifactReturns struct {
	Err error
}

type ArtifactCachePutBlobArgs

type ArtifactCachePutBlobArgs struct {
	BlobID           string
	BlobIDAnything   bool
	BlobInfo         types.BlobInfo
	BlobInfoAnything bool
}

type ArtifactCachePutBlobExpectation

type ArtifactCachePutBlobExpectation struct {
	Args    ArtifactCachePutBlobArgs
	Returns ArtifactCachePutBlobReturns
}

type ArtifactCachePutBlobReturns

type ArtifactCachePutBlobReturns struct {
	Err error
}

type Cache

type Cache interface {
	ArtifactCache
	LocalArtifactCache
}

func New

func New(opts Options) (Cache, func(), error)

New returns a new cache client

type CacheClearExpectation

type CacheClearExpectation struct {
	Returns CacheClearReturns
}

type CacheClearReturns

type CacheClearReturns struct {
	Err error
}

type CacheCloseExpectation

type CacheCloseExpectation struct {
	Returns CacheCloseReturns
}

type CacheCloseReturns

type CacheCloseReturns struct {
	Err error
}

type CacheDeleteBlobArgs

type CacheDeleteBlobArgs struct {
	BlobID         string
	BlobIDAnything bool
}

type CacheDeleteBlobExpectation

type CacheDeleteBlobExpectation struct {
	Args    CacheDeleteBlobArgs
	Returns CacheDeleteBlobReturns
}

type CacheDeleteBlobReturns

type CacheDeleteBlobReturns struct {
	// contains filtered or unexported fields
}

type CacheGetArtifactArgs

type CacheGetArtifactArgs struct {
	ArtifactID         string
	ArtifactIDAnything bool
}

type CacheGetArtifactExpectation

type CacheGetArtifactExpectation struct {
	Args    CacheGetArtifactArgs
	Returns CacheGetArtifactReturns
}

type CacheGetArtifactReturns

type CacheGetArtifactReturns struct {
	ArtifactInfo types.ArtifactInfo
	Err          error
}

type CacheGetBlobArgs

type CacheGetBlobArgs struct {
	BlobID         string
	BlobIDAnything bool
}

type CacheGetBlobExpectation

type CacheGetBlobExpectation struct {
	Args    CacheGetBlobArgs
	Returns CacheGetBlobReturns
}

type CacheGetBlobReturns

type CacheGetBlobReturns struct {
	BlobInfo types.BlobInfo
	Err      error
}

type CacheMissingBlobsArgs

type CacheMissingBlobsArgs struct {
	ArtifactID         string
	ArtifactIDAnything bool
	BlobIDs            []string
	BlobIDsAnything    bool
}

type CacheMissingBlobsExpectation

type CacheMissingBlobsExpectation struct {
	Args    CacheMissingBlobsArgs
	Returns CacheMissingBlobsReturns
}

type CacheMissingBlobsReturns

type CacheMissingBlobsReturns struct {
	MissingArtifact bool
	MissingBlobIDs  []string
	Err             error
}

type CachePutArtifactArgs

type CachePutArtifactArgs struct {
	ArtifactID           string
	ArtifactIDAnything   bool
	ArtifactInfo         types.ArtifactInfo
	ArtifactInfoAnything bool
}

type CachePutArtifactExpectation

type CachePutArtifactExpectation struct {
	Args    CachePutArtifactArgs
	Returns CachePutArtifactReturns
}

type CachePutArtifactReturns

type CachePutArtifactReturns struct {
	Err error
}

type CachePutBlobArgs

type CachePutBlobArgs struct {
	BlobID           string
	BlobIDAnything   bool
	BlobInfo         types.BlobInfo
	BlobInfoAnything bool
}

type CachePutBlobExpectation

type CachePutBlobExpectation struct {
	Args    CachePutBlobArgs
	Returns CachePutBlobReturns
}

type CachePutBlobReturns

type CachePutBlobReturns struct {
	Err error
}

type FSCache

type FSCache struct {
	// contains filtered or unexported fields
}

func NewFSCache

func NewFSCache(cacheDir string) (FSCache, error)

func (FSCache) Clear

func (fs FSCache) Clear() error

Clear removes the database

func (FSCache) Close

func (fs FSCache) Close() error

Close closes the database

func (FSCache) DeleteBlobs

func (fs FSCache) DeleteBlobs(blobIDs []string) error

DeleteBlobs removes blobs by IDs

func (FSCache) GetArtifact

func (fs FSCache) GetArtifact(artifactID string) (types.ArtifactInfo, error)

GetArtifact gets artifact information such as image metadata from local cache

func (FSCache) GetBlob

func (fs FSCache) GetBlob(blobID string) (types.BlobInfo, error)

GetBlob gets blob information such as layer data from local cache

func (FSCache) MissingBlobs

func (fs FSCache) MissingBlobs(artifactID string, blobIDs []string) (bool, []string, error)

MissingBlobs returns missing blob IDs such as layer IDs

func (FSCache) PutArtifact

func (fs FSCache) PutArtifact(artifactID string, artifactInfo types.ArtifactInfo) (err error)

PutArtifact stores artifact information such as image metadata in local cache

func (FSCache) PutBlob

func (fs FSCache) PutBlob(blobID string, blobInfo types.BlobInfo) error

PutBlob stores blob information such as layer information in local cache

type LocalArtifactCache

type LocalArtifactCache interface {
	// GetArtifact gets artifact information such as image metadata from local cache
	GetArtifact(artifactID string) (artifactInfo types.ArtifactInfo, err error)

	// GetBlob gets blob information such as layer data from local cache
	GetBlob(blobID string) (blobInfo types.BlobInfo, err error)

	// Close closes the local database
	Close() (err error)

	// Clear deletes the local database
	Clear() (err error)
}

LocalArtifactCache always uses local cache

type LocalArtifactCacheClearExpectation

type LocalArtifactCacheClearExpectation struct {
	Returns LocalArtifactCacheClearReturns
}

type LocalArtifactCacheClearReturns

type LocalArtifactCacheClearReturns struct {
	Err error
}

type LocalArtifactCacheCloseExpectation

type LocalArtifactCacheCloseExpectation struct {
	Returns LocalArtifactCacheCloseReturns
}

type LocalArtifactCacheCloseReturns

type LocalArtifactCacheCloseReturns struct {
	Err error
}

type LocalArtifactCacheGetArtifactArgs

type LocalArtifactCacheGetArtifactArgs struct {
	ArtifactID         string
	ArtifactIDAnything bool
}

type LocalArtifactCacheGetArtifactExpectation

type LocalArtifactCacheGetArtifactExpectation struct {
	Args    LocalArtifactCacheGetArtifactArgs
	Returns LocalArtifactCacheGetArtifactReturns
}

type LocalArtifactCacheGetArtifactReturns

type LocalArtifactCacheGetArtifactReturns struct {
	ArtifactInfo types.ArtifactInfo
	Err          error
}

type LocalArtifactCacheGetBlobArgs

type LocalArtifactCacheGetBlobArgs struct {
	BlobID         string
	BlobIDAnything bool
}

type LocalArtifactCacheGetBlobExpectation

type LocalArtifactCacheGetBlobExpectation struct {
	Args    LocalArtifactCacheGetBlobArgs
	Returns LocalArtifactCacheGetBlobReturns
}

type LocalArtifactCacheGetBlobReturns

type LocalArtifactCacheGetBlobReturns struct {
	BlobInfo types.BlobInfo
	Err      error
}

type MemoryCache

type MemoryCache struct {
	// contains filtered or unexported fields
}

func NewMemoryCache

func NewMemoryCache() *MemoryCache

func (*MemoryCache) Clear

func (c *MemoryCache) Clear() error

Clear clears the artifact and blob information from the memory cache

func (*MemoryCache) Close

func (c *MemoryCache) Close() error

Close clears the artifact and blob information from the memory cache

func (*MemoryCache) DeleteBlobs

func (c *MemoryCache) DeleteBlobs(blobIDs []string) error

DeleteBlobs removes the specified blobs from the memory cache

func (*MemoryCache) GetArtifact

func (c *MemoryCache) GetArtifact(artifactID string) (types.ArtifactInfo, error)

GetArtifact retrieves the artifact information from the memory cache

func (*MemoryCache) GetBlob

func (c *MemoryCache) GetBlob(blobID string) (types.BlobInfo, error)

GetBlob retrieves the blob information from the memory cache

func (*MemoryCache) MissingBlobs

func (c *MemoryCache) MissingBlobs(artifactID string, blobIDs []string) (bool, []string, error)

MissingBlobs determines the missing artifact and blob information in the memory cache

func (*MemoryCache) PutArtifact

func (c *MemoryCache) PutArtifact(artifactID string, artifactInfo types.ArtifactInfo) error

PutArtifact stores the artifact information in the memory cache

func (*MemoryCache) PutBlob

func (c *MemoryCache) PutBlob(blobID string, blobInfo types.BlobInfo) error

PutBlob stores the blob information in the memory cache

type MockArtifactCache

type MockArtifactCache struct {
	mock.Mock
}

MockArtifactCache is an autogenerated mock type for the ArtifactCache type

func (*MockArtifactCache) ApplyDeleteBlobsExpectation

func (_m *MockArtifactCache) ApplyDeleteBlobsExpectation(e ArtifactCacheDeleteBlobsExpectation)

func (*MockArtifactCache) ApplyDeleteBlobsExpectations

func (_m *MockArtifactCache) ApplyDeleteBlobsExpectations(expectations []ArtifactCacheDeleteBlobsExpectation)

func (*MockArtifactCache) ApplyMissingBlobsExpectation

func (_m *MockArtifactCache) ApplyMissingBlobsExpectation(e ArtifactCacheMissingBlobsExpectation)

func (*MockArtifactCache) ApplyMissingBlobsExpectations

func (_m *MockArtifactCache) ApplyMissingBlobsExpectations(expectations []ArtifactCacheMissingBlobsExpectation)

func (*MockArtifactCache) ApplyPutArtifactExpectation

func (_m *MockArtifactCache) ApplyPutArtifactExpectation(e ArtifactCachePutArtifactExpectation)

func (*MockArtifactCache) ApplyPutArtifactExpectations

func (_m *MockArtifactCache) ApplyPutArtifactExpectations(expectations []ArtifactCachePutArtifactExpectation)

func (*MockArtifactCache) ApplyPutBlobExpectation

func (_m *MockArtifactCache) ApplyPutBlobExpectation(e ArtifactCachePutBlobExpectation) *mock.Call

func (*MockArtifactCache) ApplyPutBlobExpectations

func (_m *MockArtifactCache) ApplyPutBlobExpectations(expectations []ArtifactCachePutBlobExpectation)

func (*MockArtifactCache) DeleteBlobs

func (_m *MockArtifactCache) DeleteBlobs(blobIDs []string) error

DeleteBlobs provides a mock function with given fields: blobIDs

func (*MockArtifactCache) MissingBlobs

func (_m *MockArtifactCache) MissingBlobs(artifactID string, blobIDs []string) (bool, []string, error)

MissingBlobs provides a mock function with given fields: artifactID, blobIDs

func (*MockArtifactCache) PutArtifact

func (_m *MockArtifactCache) PutArtifact(artifactID string, artifactInfo types.ArtifactInfo) error

PutArtifact provides a mock function with given fields: artifactID, artifactInfo

func (*MockArtifactCache) PutBlob

func (_m *MockArtifactCache) PutBlob(blobID string, blobInfo types.BlobInfo) error

PutBlob provides a mock function with given fields: blobID, blobInfo

type MockCache

type MockCache struct {
	mock.Mock
}

MockCache is an autogenerated mock type for the Cache type

func (*MockCache) ApplyClearExpectation

func (_m *MockCache) ApplyClearExpectation(e CacheClearExpectation)

func (*MockCache) ApplyClearExpectations

func (_m *MockCache) ApplyClearExpectations(expectations []CacheClearExpectation)

func (*MockCache) ApplyCloseExpectation

func (_m *MockCache) ApplyCloseExpectation(e CacheCloseExpectation)

func (*MockCache) ApplyCloseExpectations

func (_m *MockCache) ApplyCloseExpectations(expectations []CacheCloseExpectation)

func (*MockCache) ApplyDeleteBlobExpectation

func (_m *MockCache) ApplyDeleteBlobExpectation(e CacheDeleteBlobExpectation)

func (*MockCache) ApplyDeleteBlobExpectations

func (_m *MockCache) ApplyDeleteBlobExpectations(expectations []CacheDeleteBlobExpectation)

func (*MockCache) ApplyGetArtifactExpectation

func (_m *MockCache) ApplyGetArtifactExpectation(e CacheGetArtifactExpectation)

func (*MockCache) ApplyGetArtifactExpectations

func (_m *MockCache) ApplyGetArtifactExpectations(expectations []CacheGetArtifactExpectation)

func (*MockCache) ApplyGetBlobExpectation

func (_m *MockCache) ApplyGetBlobExpectation(e CacheGetBlobExpectation)

func (*MockCache) ApplyGetBlobExpectations

func (_m *MockCache) ApplyGetBlobExpectations(expectations []CacheGetBlobExpectation)

func (*MockCache) ApplyMissingBlobsExpectation

func (_m *MockCache) ApplyMissingBlobsExpectation(e CacheMissingBlobsExpectation)

func (*MockCache) ApplyMissingBlobsExpectations

func (_m *MockCache) ApplyMissingBlobsExpectations(expectations []CacheMissingBlobsExpectation)

func (*MockCache) ApplyPutArtifactExpectation

func (_m *MockCache) ApplyPutArtifactExpectation(e CachePutArtifactExpectation)

func (*MockCache) ApplyPutArtifactExpectations

func (_m *MockCache) ApplyPutArtifactExpectations(expectations []CachePutArtifactExpectation)

func (*MockCache) ApplyPutBlobExpectation

func (_m *MockCache) ApplyPutBlobExpectation(e CachePutBlobExpectation)

func (*MockCache) ApplyPutBlobExpectations

func (_m *MockCache) ApplyPutBlobExpectations(expectations []CachePutBlobExpectation)

func (*MockCache) Clear

func (_m *MockCache) Clear() error

Clear provides a mock function with given fields:

func (*MockCache) Close

func (_m *MockCache) Close() error

Close provides a mock function with given fields:

func (*MockCache) DeleteBlob

func (_m *MockCache) DeleteBlob(blobID string) error

DeleteBlob provides a mock function with given fields: blobID

func (*MockCache) GetArtifact

func (_m *MockCache) GetArtifact(artifactID string) (types.ArtifactInfo, error)

GetArtifact provides a mock function with given fields: artifactID

func (*MockCache) GetBlob

func (_m *MockCache) GetBlob(blobID string) (types.BlobInfo, error)

GetBlob provides a mock function with given fields: blobID

func (*MockCache) MissingBlobs

func (_m *MockCache) MissingBlobs(artifactID string, blobIDs []string) (bool, []string, error)

MissingBlobs provides a mock function with given fields: artifactID, blobIDs

func (*MockCache) PutArtifact

func (_m *MockCache) PutArtifact(artifactID string, artifactInfo types.ArtifactInfo) error

PutArtifact provides a mock function with given fields: artifactID, artifactInfo

func (*MockCache) PutBlob

func (_m *MockCache) PutBlob(blobID string, blobInfo types.BlobInfo) error

PutBlob provides a mock function with given fields: blobID, blobInfo

type MockLocalArtifactCache

type MockLocalArtifactCache struct {
	mock.Mock
}

MockLocalArtifactCache is an autogenerated mock type for the LocalArtifactCache type

func (*MockLocalArtifactCache) ApplyClearExpectation

func (_m *MockLocalArtifactCache) ApplyClearExpectation(e LocalArtifactCacheClearExpectation)

func (*MockLocalArtifactCache) ApplyClearExpectations

func (_m *MockLocalArtifactCache) ApplyClearExpectations(expectations []LocalArtifactCacheClearExpectation)

func (*MockLocalArtifactCache) ApplyCloseExpectation

func (_m *MockLocalArtifactCache) ApplyCloseExpectation(e LocalArtifactCacheCloseExpectation)

func (*MockLocalArtifactCache) ApplyCloseExpectations

func (_m *MockLocalArtifactCache) ApplyCloseExpectations(expectations []LocalArtifactCacheCloseExpectation)

func (*MockLocalArtifactCache) ApplyGetArtifactExpectation

func (_m *MockLocalArtifactCache) ApplyGetArtifactExpectation(e LocalArtifactCacheGetArtifactExpectation)

func (*MockLocalArtifactCache) ApplyGetArtifactExpectations

func (_m *MockLocalArtifactCache) ApplyGetArtifactExpectations(expectations []LocalArtifactCacheGetArtifactExpectation)

func (*MockLocalArtifactCache) ApplyGetBlobExpectation

func (_m *MockLocalArtifactCache) ApplyGetBlobExpectation(e LocalArtifactCacheGetBlobExpectation)

func (*MockLocalArtifactCache) ApplyGetBlobExpectations

func (_m *MockLocalArtifactCache) ApplyGetBlobExpectations(expectations []LocalArtifactCacheGetBlobExpectation)

func (*MockLocalArtifactCache) Clear

func (_m *MockLocalArtifactCache) Clear() error

Clear provides a mock function with given fields:

func (*MockLocalArtifactCache) Close

func (_m *MockLocalArtifactCache) Close() error

Close provides a mock function with given fields:

func (*MockLocalArtifactCache) GetArtifact

func (_m *MockLocalArtifactCache) GetArtifact(artifactID string) (types.ArtifactInfo, error)

GetArtifact provides a mock function with given fields: artifactID

func (*MockLocalArtifactCache) GetBlob

func (_m *MockLocalArtifactCache) GetBlob(blobID string) (types.BlobInfo, error)

GetBlob provides a mock function with given fields: blobID

type NopCache

type NopCache struct{}

func NewNopCache

func NewNopCache() NopCache

func (NopCache) Clear

func (NopCache) Clear() error

func (NopCache) Close

func (NopCache) Close() error

func (NopCache) GetArtifact

func (NopCache) GetArtifact(string) (types.ArtifactInfo, error)

func (NopCache) GetBlob

func (NopCache) GetBlob(string) (types.BlobInfo, error)

type Options

type Options struct {
	Backend     string
	CacheDir    string
	RedisCACert string
	RedisCert   string
	RedisKey    string
	RedisTLS    bool
	TTL         time.Duration
}

type RedisCache

type RedisCache struct {
	// contains filtered or unexported fields
}

func NewRedisCache

func NewRedisCache(backend, caCertPath, certPath, keyPath string, enableTLS bool, ttl time.Duration) (RedisCache, error)

func (RedisCache) Clear

func (c RedisCache) Clear() error

func (RedisCache) Close

func (c RedisCache) Close() error

func (RedisCache) DeleteBlobs

func (c RedisCache) DeleteBlobs(blobIDs []string) error

func (RedisCache) GetArtifact

func (c RedisCache) GetArtifact(artifactID string) (types.ArtifactInfo, error)

func (RedisCache) GetBlob

func (c RedisCache) GetBlob(blobID string) (types.BlobInfo, error)

func (RedisCache) MissingBlobs

func (c RedisCache) MissingBlobs(artifactID string, blobIDs []string) (bool, []string, error)

func (RedisCache) PutArtifact

func (c RedisCache) PutArtifact(artifactID string, artifactConfig types.ArtifactInfo) error

func (RedisCache) PutBlob

func (c RedisCache) PutBlob(blobID string, blobInfo types.BlobInfo) error

type RedisOptions

type RedisOptions struct {
	Backend    string
	TLS        bool
	TLSOptions RedisTLSOptions
}

func NewRedisOptions

func NewRedisOptions(backend, caCert, cert, key string, enableTLS bool) (RedisOptions, error)

func (*RedisOptions) BackendMasked

func (o *RedisOptions) BackendMasked() string

BackendMasked returns the redis connection string masking credentials

type RedisTLSOptions

type RedisTLSOptions struct {
	CACert string
	Cert   string
	Key    string
}

RedisTLSOptions holds the options for redis cache

func NewRedisTLSOptions

func NewRedisTLSOptions(caCert, cert, key string) (RedisTLSOptions, error)

type RemoteCache

type RemoteCache struct {
	// contains filtered or unexported fields
}

RemoteCache implements remote cache

func NewRemoteCache

func NewRemoteCache(opts RemoteOptions) *RemoteCache

NewRemoteCache is the factory method for RemoteCache

func (RemoteCache) DeleteBlobs

func (c RemoteCache) DeleteBlobs(blobIDs []string) error

DeleteBlobs removes blobs by IDs from RemoteCache

func (RemoteCache) MissingBlobs

func (c RemoteCache) MissingBlobs(imageID string, layerIDs []string) (bool, []string, error)

MissingBlobs fetches missing blobs from RemoteCache

func (RemoteCache) PutArtifact

func (c RemoteCache) PutArtifact(imageID string, artifactInfo types.ArtifactInfo) error

PutArtifact sends artifact to remote client

func (RemoteCache) PutBlob

func (c RemoteCache) PutBlob(diffID string, blobInfo types.BlobInfo) error

PutBlob sends blobInfo to remote client

type RemoteOptions

type RemoteOptions struct {
	ServerAddr    string
	CustomHeaders http.Header
	Insecure      bool
	PathPrefix    string
}

type Type

type Type string
const (
	TypeUnknown Type = "unknown"
	TypeFS      Type = "fs"
	TypeRedis   Type = "redis"
	TypeMemory  Type = "memory"
)

func NewType

func NewType(backend string) Type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL