storage

package
v1.2.0-alpha11 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LocalStage_ImageRepoFormat = "%s"
	LocalStage_ImageFormat     = "%s:%s-%d"

	LocalManagedImageRecord_ImageNameFormat = "werf-managed-images/%s"
	LocalManagedImageRecord_ImageFormat     = "werf-managed-images/%s:%s"

	LocalImageMetadataByCommitRecord_ImageNameFormat = "werf-images-metadata-by-commit/%s"
	LocalImageMetadataByCommitRecord_TagFormat       = "%s_%s_%s"

	LocalClientIDRecord_ImageNameFormat = "werf-client-id/%s"
	LocalClientIDRecord_ImageFormat     = "werf-client-id/%s:%s-%d"
)
View Source
const (
	RepoStage_ImageFormat = "%s:%s-%d"

	RepoManagedImageRecord_ImageTagPrefix  = "managed-image-"
	RepoManagedImageRecord_ImageNameFormat = "%s:managed-image-%s"

	RepoImageMetadataByCommitRecord_ImageTagPrefix = "meta-"
	RepoImageMetadataByCommitRecord_TagFormat      = "meta-%s_%s_%s"

	RepoClientIDRecrod_ImageTagPrefix  = "client-id-"
	RepoClientIDRecrod_ImageNameFormat = "%s:client-id-%s-%d"

	UnexpectedTagFormatErrorPrefix = "unexpected tag format"
)
View Source
const (
	LocalStorageAddress             = ":local"
	DefaultKubernetesStorageAddress = "kubernetes://werf-synchronization"
	NamelessImageRecordTag          = "__nameless__"
)
View Source
const ImageDeletionFailedDueToUsedByContainerErrorTip = "Use --force option to remove all containers that are based on deleting werf docker images"
View Source
const (
	StagesStorageCacheConfigMapKey = "stagesStorageCache"
)

Variables

View Source
var (
	ErrBadKubernetesSyncrhonizationAddress = errors.New("bad kubernetes synchronization address")
)

Functions

func IsImageDeletionFailedDueToUsingByContainerError added in v1.1.23

func IsImageDeletionFailedDueToUsingByContainerError(err error) bool

Types

type ClientIDRecord added in v1.1.23

type ClientIDRecord struct {
	ClientID          string
	TimestampMillisec int64
}

func (*ClientIDRecord) String added in v1.1.23

func (rec *ClientIDRecord) String() string

type DeleteImageOptions

type DeleteImageOptions struct {
	RmiForce bool
}

type FileStagesStorageCache

type FileStagesStorageCache struct {
	CacheDir string
}

func NewFileStagesStorageCache

func NewFileStagesStorageCache(cacheDir string) *FileStagesStorageCache

func (*FileStagesStorageCache) DeleteAllStages

func (cache *FileStagesStorageCache) DeleteAllStages(_ context.Context, projectName string) error

func (*FileStagesStorageCache) DeleteStagesByDigest added in v1.2.0

func (cache *FileStagesStorageCache) DeleteStagesByDigest(ctx context.Context, projectName, digest string) error

func (*FileStagesStorageCache) GetAllStages

func (cache *FileStagesStorageCache) GetAllStages(ctx context.Context, projectName string) (bool, []image.StageID, error)

func (*FileStagesStorageCache) GetStagesByDigest added in v1.2.0

func (cache *FileStagesStorageCache) GetStagesByDigest(ctx context.Context, projectName, digest string) (bool, []image.StageID, error)

func (*FileStagesStorageCache) StoreStagesByDigest added in v1.2.0

func (cache *FileStagesStorageCache) StoreStagesByDigest(ctx context.Context, projectName, digest string, stages []image.StageID) error

func (*FileStagesStorageCache) String

func (cache *FileStagesStorageCache) String() string

type FilterStagesAndProcessRelatedDataOptions added in v1.1.23

type FilterStagesAndProcessRelatedDataOptions struct {
	SkipUsedImage            bool
	RmForce                  bool
	RmContainersThatUseImage bool
}

type GenericLockManager

type GenericLockManager struct {
	// Single Locker for all projects
	Locker lockgate.Locker
}

func NewGenericLockManager

func NewGenericLockManager(locker lockgate.Locker) *GenericLockManager

func (*GenericLockManager) LockImage

func (manager *GenericLockManager) LockImage(ctx context.Context, projectName, imageName string) (LockHandle, error)

func (*GenericLockManager) LockStage

func (manager *GenericLockManager) LockStage(ctx context.Context, projectName, digest string) (LockHandle, error)

func (*GenericLockManager) LockStageCache

func (manager *GenericLockManager) LockStageCache(ctx context.Context, projectName, digest string) (LockHandle, error)

func (*GenericLockManager) LockStagesAndImages

func (manager *GenericLockManager) LockStagesAndImages(ctx context.Context, projectName string, opts LockStagesAndImagesOptions) (LockHandle, error)

func (*GenericLockManager) Unlock

func (manager *GenericLockManager) Unlock(ctx context.Context, lock LockHandle) error

type ImageMetadata

type ImageMetadata struct {
	ContentDigest string
}

type KubernetesStagesStorageCache

type KubernetesStagesStorageCache struct {
	KubeClient           kubernetes.Interface
	Namespace            string
	GetConfigMapNameFunc func(projectName string) string
}

func NewKubernetesStagesStorageCache

func NewKubernetesStagesStorageCache(namespace string, kubeClient kubernetes.Interface, getConfigMapNameFunc func(projectName string) string) *KubernetesStagesStorageCache

func (*KubernetesStagesStorageCache) DeleteAllStages

func (cache *KubernetesStagesStorageCache) DeleteAllStages(ctx context.Context, projectName string) error

func (*KubernetesStagesStorageCache) DeleteStagesByDigest added in v1.2.0

func (cache *KubernetesStagesStorageCache) DeleteStagesByDigest(ctx context.Context, projectName, digest string) error

func (*KubernetesStagesStorageCache) GetAllStages

func (cache *KubernetesStagesStorageCache) GetAllStages(ctx context.Context, projectName string) (bool, []image.StageID, error)

func (*KubernetesStagesStorageCache) GetStagesByDigest added in v1.2.0

func (cache *KubernetesStagesStorageCache) GetStagesByDigest(ctx context.Context, projectName, digest string) (bool, []image.StageID, error)

func (*KubernetesStagesStorageCache) StoreStagesByDigest added in v1.2.0

func (cache *KubernetesStagesStorageCache) StoreStagesByDigest(ctx context.Context, projectName, digest string, stages []image.StageID) error

func (*KubernetesStagesStorageCache) String

func (cache *KubernetesStagesStorageCache) String() string

type KubernetesStagesStorageCacheData

type KubernetesStagesStorageCacheData struct {
	StagesByDigest map[string][]image.StageID `json:"stagesByDigest"`
}

type KubernetesStagesStorageCacheOptions added in v1.1.23

type KubernetesStagesStorageCacheOptions struct {
	GetConfigMapNameFunc func(projectName string) string
}

type KubernetesSynchronizationParams added in v1.1.23

type KubernetesSynchronizationParams struct {
	ConfigDataBase64 string
	ConfigPath       string
	ConfigContext    string
	Namespace        string
}

func ParseKubernetesSynchronization added in v1.1.23

func ParseKubernetesSynchronization(address string) (*KubernetesSynchronizationParams, error)

type KuberntesLockManager

type KuberntesLockManager struct {
	KubeClient           kubernetes.Interface
	KubeDynamicClient    dynamic.Interface
	Namespace            string
	LockerPerProject     map[string]lockgate.Locker
	GetConfigMapNameFunc func(projectName string) string
	// contains filtered or unexported fields
}

func NewKubernetesLockManager

func NewKubernetesLockManager(namespace string, kubeClient kubernetes.Interface, kubeDynamicClient dynamic.Interface, getConfigMapNameFunc func(projectName string) string) *KuberntesLockManager

func (*KuberntesLockManager) LockImage

func (manager *KuberntesLockManager) LockImage(ctx context.Context, projectName, imageName string) (LockHandle, error)

func (*KuberntesLockManager) LockStage

func (manager *KuberntesLockManager) LockStage(ctx context.Context, projectName, digest string) (LockHandle, error)

func (*KuberntesLockManager) LockStageCache

func (manager *KuberntesLockManager) LockStageCache(ctx context.Context, projectName, digest string) (LockHandle, error)

func (*KuberntesLockManager) LockStagesAndImages

func (manager *KuberntesLockManager) LockStagesAndImages(ctx context.Context, projectName string, opts LockStagesAndImagesOptions) (LockHandle, error)

func (*KuberntesLockManager) Unlock

func (manager *KuberntesLockManager) Unlock(ctx context.Context, lock LockHandle) error

type LocalDockerServerStagesStorage

type LocalDockerServerStagesStorage struct {
	// Local stages storage is compatible only with docker-server backed runtime
	LocalDockerServerRuntime *container_runtime.LocalDockerServerRuntime
}

func NewLocalDockerServerStagesStorage

func NewLocalDockerServerStagesStorage(localDockerServerRuntime *container_runtime.LocalDockerServerRuntime) *LocalDockerServerStagesStorage

func (*LocalDockerServerStagesStorage) AddManagedImage

func (storage *LocalDockerServerStagesStorage) AddManagedImage(ctx context.Context, projectName, imageName string) error

func (*LocalDockerServerStagesStorage) Address

func (storage *LocalDockerServerStagesStorage) Address() string

func (*LocalDockerServerStagesStorage) ConstructStageImageName

func (storage *LocalDockerServerStagesStorage) ConstructStageImageName(projectName, digest string, uniqueID int64) string

func (*LocalDockerServerStagesStorage) CreateRepo

func (storage *LocalDockerServerStagesStorage) CreateRepo(_ context.Context) error

func (*LocalDockerServerStagesStorage) DeleteRepo

func (storage *LocalDockerServerStagesStorage) DeleteRepo(_ context.Context) error

func (*LocalDockerServerStagesStorage) DeleteStage added in v1.1.23

func (storage *LocalDockerServerStagesStorage) DeleteStage(ctx context.Context, stageDescription *image.StageDescription, options DeleteImageOptions) error

func (*LocalDockerServerStagesStorage) FetchImage

func (*LocalDockerServerStagesStorage) FilterStagesAndProcessRelatedData added in v1.1.23

func (storage *LocalDockerServerStagesStorage) FilterStagesAndProcessRelatedData(ctx context.Context, stageDescriptions []*image.StageDescription, options FilterStagesAndProcessRelatedDataOptions) ([]*image.StageDescription, error)

func (*LocalDockerServerStagesStorage) GetAllAndGroupImageMetadataByImageName added in v1.2.0

func (storage *LocalDockerServerStagesStorage) GetAllAndGroupImageMetadataByImageName(ctx context.Context, projectName string, imageNameList []string) (map[string]map[string][]string, map[string]map[string][]string, error)

func (*LocalDockerServerStagesStorage) GetClientIDRecords added in v1.1.23

func (storage *LocalDockerServerStagesStorage) GetClientIDRecords(ctx context.Context, projectName string) ([]*ClientIDRecord, error)

func (*LocalDockerServerStagesStorage) GetManagedImages

func (storage *LocalDockerServerStagesStorage) GetManagedImages(ctx context.Context, projectName string) ([]string, error)

func (*LocalDockerServerStagesStorage) GetStageDescription

func (storage *LocalDockerServerStagesStorage) GetStageDescription(ctx context.Context, projectName, digest string, uniqueID int64) (*image.StageDescription, error)

func (*LocalDockerServerStagesStorage) GetStagesIDs added in v1.1.23

func (storage *LocalDockerServerStagesStorage) GetStagesIDs(ctx context.Context, projectName string) ([]image.StageID, error)

func (*LocalDockerServerStagesStorage) GetStagesIDsByDigest added in v1.2.0

func (storage *LocalDockerServerStagesStorage) GetStagesIDsByDigest(ctx context.Context, projectName, digest string) ([]image.StageID, error)

func (*LocalDockerServerStagesStorage) IsImageMetadataExist added in v1.2.0

func (storage *LocalDockerServerStagesStorage) IsImageMetadataExist(ctx context.Context, projectName, imageName, commit, stageID string) (bool, error)

func (*LocalDockerServerStagesStorage) PostClientIDRecord added in v1.1.23

func (storage *LocalDockerServerStagesStorage) PostClientIDRecord(ctx context.Context, projectName string, rec *ClientIDRecord) error

func (*LocalDockerServerStagesStorage) PutImageMetadata added in v1.2.0

func (storage *LocalDockerServerStagesStorage) PutImageMetadata(ctx context.Context, projectName, imageName, commit, stageID string) error

func (*LocalDockerServerStagesStorage) RmImageMetadata added in v1.2.0

func (storage *LocalDockerServerStagesStorage) RmImageMetadata(ctx context.Context, projectName, imageNameOrID, commit, stageID string) error

func (*LocalDockerServerStagesStorage) RmManagedImage

func (storage *LocalDockerServerStagesStorage) RmManagedImage(ctx context.Context, projectName, imageName string) error

func (*LocalDockerServerStagesStorage) ShouldFetchImage

func (storage *LocalDockerServerStagesStorage) ShouldFetchImage(_ context.Context, _ container_runtime.Image) (bool, error)

func (*LocalDockerServerStagesStorage) StoreImage

func (*LocalDockerServerStagesStorage) String

func (storage *LocalDockerServerStagesStorage) String() string

type LockHandle

type LockHandle struct {
	ProjectName    string              `json:"projectName"`
	LockgateHandle lockgate.LockHandle `json:"lockgateHandle"`
}

type LockManager

type LockManager interface {
	LockStage(ctx context.Context, projectName, digest string) (LockHandle, error)
	LockStageCache(ctx context.Context, projectName, digest string) (LockHandle, error)
	LockImage(ctx context.Context, projectName, imageName string) (LockHandle, error)
	LockStagesAndImages(ctx context.Context, projectName string, opts LockStagesAndImagesOptions) (LockHandle, error)
	Unlock(ctx context.Context, lockHandle LockHandle) error
}

type LockStagesAndImagesOptions

type LockStagesAndImagesOptions struct {
	GetOrCreateImagesOnly bool `json:"getOrCreateImagesOnly"`
}

type RepoStagesStorage

type RepoStagesStorage struct {
	RepoAddress      string
	DockerRegistry   docker_registry.DockerRegistry
	ContainerRuntime container_runtime.ContainerRuntime
}

func NewRepoStagesStorage

func NewRepoStagesStorage(repoAddress string, containerRuntime container_runtime.ContainerRuntime, options RepoStagesStorageOptions) (*RepoStagesStorage, error)

func (*RepoStagesStorage) AddManagedImage

func (storage *RepoStagesStorage) AddManagedImage(ctx context.Context, projectName, imageName string) error

func (*RepoStagesStorage) Address

func (storage *RepoStagesStorage) Address() string

func (*RepoStagesStorage) ConstructStageImageName

func (storage *RepoStagesStorage) ConstructStageImageName(_, digest string, uniqueID int64) string

func (*RepoStagesStorage) CreateRepo

func (storage *RepoStagesStorage) CreateRepo(ctx context.Context) error

func (*RepoStagesStorage) DeleteRepo

func (storage *RepoStagesStorage) DeleteRepo(ctx context.Context) error

func (*RepoStagesStorage) DeleteStage added in v1.1.23

func (storage *RepoStagesStorage) DeleteStage(ctx context.Context, stageDescription *image.StageDescription, _ DeleteImageOptions) error

func (*RepoStagesStorage) FetchImage

func (storage *RepoStagesStorage) FetchImage(ctx context.Context, img container_runtime.Image) error

func (*RepoStagesStorage) FilterStagesAndProcessRelatedData added in v1.1.23

func (storage *RepoStagesStorage) FilterStagesAndProcessRelatedData(_ context.Context, stageDescriptions []*image.StageDescription, _ FilterStagesAndProcessRelatedDataOptions) ([]*image.StageDescription, error)

func (*RepoStagesStorage) GetAllAndGroupImageMetadataByImageName added in v1.2.0

func (storage *RepoStagesStorage) GetAllAndGroupImageMetadataByImageName(ctx context.Context, projectName string, imageNameList []string) (map[string]map[string][]string, map[string]map[string][]string, error)

func (*RepoStagesStorage) GetClientIDRecords added in v1.1.23

func (storage *RepoStagesStorage) GetClientIDRecords(ctx context.Context, projectName string) ([]*ClientIDRecord, error)

func (*RepoStagesStorage) GetManagedImages

func (storage *RepoStagesStorage) GetManagedImages(ctx context.Context, projectName string) ([]string, error)

func (*RepoStagesStorage) GetStageDescription

func (storage *RepoStagesStorage) GetStageDescription(ctx context.Context, projectName, digest string, uniqueID int64) (*image.StageDescription, error)

func (*RepoStagesStorage) GetStagesIDs added in v1.1.23

func (storage *RepoStagesStorage) GetStagesIDs(ctx context.Context, projectName string) ([]image.StageID, error)

func (*RepoStagesStorage) GetStagesIDsByDigest added in v1.2.0

func (storage *RepoStagesStorage) GetStagesIDsByDigest(ctx context.Context, projectName, digest string) ([]image.StageID, error)

func (*RepoStagesStorage) IsImageMetadataExist added in v1.2.0

func (storage *RepoStagesStorage) IsImageMetadataExist(ctx context.Context, projectName, imageName, commit, stageID string) (bool, error)

func (*RepoStagesStorage) PostClientIDRecord added in v1.1.23

func (storage *RepoStagesStorage) PostClientIDRecord(ctx context.Context, projectName string, rec *ClientIDRecord) error

func (*RepoStagesStorage) PutImageMetadata added in v1.2.0

func (storage *RepoStagesStorage) PutImageMetadata(ctx context.Context, projectName, imageName, commit, stageID string) error

func (*RepoStagesStorage) RmImageMetadata added in v1.2.0

func (storage *RepoStagesStorage) RmImageMetadata(ctx context.Context, projectName, imageNameOrID, commit, stageID string) error

func (*RepoStagesStorage) RmManagedImage

func (storage *RepoStagesStorage) RmManagedImage(ctx context.Context, projectName, imageName string) error

func (*RepoStagesStorage) ShouldFetchImage

func (storage *RepoStagesStorage) ShouldFetchImage(_ context.Context, img container_runtime.Image) (bool, error)

func (*RepoStagesStorage) StoreImage

func (storage *RepoStagesStorage) StoreImage(ctx context.Context, img container_runtime.Image) error

func (*RepoStagesStorage) String

func (storage *RepoStagesStorage) String() string

type RepoStagesStorageOptions

type RepoStagesStorageOptions struct {
	docker_registry.DockerRegistryOptions
	Implementation string
}

type StagesStorage

type StagesStorage interface {
	GetStagesIDs(ctx context.Context, projectName string) ([]image.StageID, error)
	GetStagesIDsByDigest(ctx context.Context, projectName, digest string) ([]image.StageID, error)
	GetStageDescription(ctx context.Context, projectName, digest string, uniqueID int64) (*image.StageDescription, error)
	DeleteStage(ctx context.Context, stageDescription *image.StageDescription, options DeleteImageOptions) error
	FilterStagesAndProcessRelatedData(ctx context.Context, stageDescriptions []*image.StageDescription, options FilterStagesAndProcessRelatedDataOptions) ([]*image.StageDescription, error)

	ConstructStageImageName(projectName, digest string, uniqueID int64) string

	// FetchImage will create a local image in the container-runtime
	FetchImage(ctx context.Context, img container_runtime.Image) error
	// StoreImage will store a local image into the container-runtime, local built image should exist prior running store
	StoreImage(ctx context.Context, img container_runtime.Image) error
	ShouldFetchImage(ctx context.Context, img container_runtime.Image) (bool, error)

	CreateRepo(ctx context.Context) error
	DeleteRepo(ctx context.Context) error

	AddManagedImage(ctx context.Context, projectName, imageName string) error
	RmManagedImage(ctx context.Context, projectName, imageName string) error
	GetManagedImages(ctx context.Context, projectName string) ([]string, error)

	PutImageMetadata(ctx context.Context, projectName, imageName, commit, stageID string) error
	RmImageMetadata(ctx context.Context, projectName, imageNameOrID, commit, stageID string) error
	IsImageMetadataExist(ctx context.Context, projectName, imageName, commit, stageID string) (bool, error)
	GetAllAndGroupImageMetadataByImageName(ctx context.Context, projectName string, imageNameList []string) (map[string]map[string][]string, map[string]map[string][]string, error)

	GetClientIDRecords(ctx context.Context, projectName string) ([]*ClientIDRecord, error)
	PostClientIDRecord(ctx context.Context, projectName string, rec *ClientIDRecord) error

	String() string
	Address() string
}

func NewStagesStorage

func NewStagesStorage(stagesStorageAddress string, containerRuntime container_runtime.ContainerRuntime, options StagesStorageOptions) (StagesStorage, error)

type StagesStorageCache

type StagesStorageCache interface {
	GetAllStages(ctx context.Context, projectName string) (bool, []image.StageID, error)
	DeleteAllStages(ctx context.Context, projectName string) error
	GetStagesByDigest(ctx context.Context, projectName, digest string) (bool, []image.StageID, error)
	StoreStagesByDigest(ctx context.Context, projectName, digest string, stages []image.StageID) error
	DeleteStagesByDigest(ctx context.Context, projectName, digest string) error

	String() string
}

type StagesStorageCacheRecord

type StagesStorageCacheRecord struct {
	Stages []image.StageID `json:"stages"`
}

type StagesStorageOptions

type StagesStorageOptions struct {
	RepoStagesStorageOptions
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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