utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SecretMapKeyAccessKeyID is key of accesskeyid in secret
	SecretMapKeyAccessKeyID = "AccessKeyID"
	// SecretMapKeySecretAccessKey is key of secretaccesskey in secret
	SecretMapKeySecretAccessKey = "SecretAccessKey"
	//metadata key for stroing the deployable generatename name
	DeployableGenerateNameMeta = "x-amz-meta-generatename"
	//Deployable generate name key within the meta map
	DployableMateGenerateNameKey = "Generatename"
	//metadata key for stroing the deployable generatename name
	DeployableVersionMeta = "x-amz-meta-deployableversion"
	//Deployable generate name key within the meta map
	DeployableMetaVersionKey = "Deployableversion"
)
View Source
const (
	// HelmCRKind is kind of the Helm CR
	HelmCRKind = "HelmRelease"
	// SubscriptionCRKind is kind of the Subscription CR
	SubscriptionCRKind = "Subscription"
	// HelmCRAPIVersion is APIVersion of the Helm CR
	HelmCRAPIVersion = "apps.open-cluster-management.io/v1"
	// HelmCRChartName is spec.ChartName of the Helm CR
	HelmCRChartName = "chartName"
	// HelmCRReleaseName is spec.ReleaseName of the Helm CR
	HelmCRReleaseName = "releaseName"
	// HelmCRVersion is spec.Version of the Helm CR
	HelmCRVersion = "version"
	// HelmCRSource is spec.Source of the Helm CR
	HelmCRSource = "source"
	// HelmCRSourceType is spec.Source.Type of the Helm CR
	HelmCRSourceType = "type"
	// HelmCRSourceHelm is spec.Source.Helmrepo of the Helm CR
	HelmCRSourceHelm = "helmrepo"
	// HelmCRSourceGit is spec.Source.Github of the Helm CR
	HelmCRSourceGit = "github"
	// HelmCRRepoURL is spec.Source.Github.Urls or spec.Source.Helmrepo.Urls of the Helm CR
	HelmCRRepoURL = "urls"
	// HelmCRGitRepoChartPath is spec.Source.Github.ChartPath of the Helm CR
	HelmCRGitRepoChartPath = "chartPath"

	//Channel type meta for testing case
	ChannelTypeKind       = "Channel"
	ChannelTypeAPIVersion = "v1"

	//Deployable type meta for testing case
	DeployableTypeKind       = "Deployable"
	DeployableTypeAPIVersion = "v1"
)
View Source
const InsecureSkipVerifyFlag = "insecureSkipVerify"

Variables

This section is empty.

Functions

func CleanupDeployables

func CleanupDeployables(cl client.Client, channel types.NamespacedName) error

CleanupDeployables check all deployables in certain namespace delete all has the channel set the given channel name

func DplGenerateNameStr

func DplGenerateNameStr(deployable *dplv1.Deployable) string

DplGenerateNameStr will generate a string for the dpl generate name

func FindDeployableForChannelsInMap added in v1.0.0

func FindDeployableForChannelsInMap(cl client.Client, deployable *dplv1.Deployable,
	channelnsMap map[string]string, log logr.Logger) (*dplv1.Deployable,
	map[string]*dplv1.Deployable, error)

FindDeployableForChannelsInMap check all deployables in certain namespace delete all has the channel set the given channel namespace channelnsMap is a set(), which is used to check up if the dpl is within a channel or not

func GenerateChannelMap

func GenerateChannelMap(cl client.Client, log logr.Logger) (map[string]*chv1.Channel, error)

GenerateChannelMap finds all channels and build map with key of channel name

func GenerateDeployableForChannel

func GenerateDeployableForChannel(deployable *dplv1.Deployable, channel types.NamespacedName) (*dplv1.Deployable, error)

GenerateDeployableForChannel generate a copy of deployable for channel with label, annotation, template and channel info

func GetChartIndex

func GetChartIndex(chnPathname string, chnRefCfgMap *corev1.ConfigMap, logger logr.Logger) (*http.Response, error)

func GetHelmRepoIndex

func GetHelmRepoIndex(channelPathName string, chnRefCfgMap *corev1.ConfigMap, loadIdx LoadIndexPageFunc, logger logr.Logger) (*repo.IndexFile, error)

GetHelmRepoIndex get the index file from helm repository

func LoadLocalIdx

func LoadLocalIdx(idxPath string, cfg *corev1.ConfigMap, lgger logr.Logger) (*http.Response, error)

func LocateChannel

func LocateChannel(cl client.Client, name string) (*chv1.Channel, error)

LocateChannel finds channel by name

func UpdateServingChannel

func UpdateServingChannel(servingChannel string, channelKey string, action string) string

UpdateServingChannel add/remove the given channel to the current serving channel

func ValidateDeployableInChannel

func ValidateDeployableInChannel(deployable *dplv1.Deployable, channel *chv1.Channel) bool

ValidateDeployableInChannel check if a deployable rightfully in channel

func ValidateDeployableToChannel

func ValidateDeployableToChannel(deployable *dplv1.Deployable, channel *chv1.Channel) bool

ValidateDeployableToChannel check if a deployable can be promoted to channel

Types

type AWSHandler

type AWSHandler struct {
	*s3.Client
}

AWSHandler handles connections to aws

func (*AWSHandler) Create

func (h *AWSHandler) Create(bucket string) error

Create a bucket

func (*AWSHandler) Delete

func (h *AWSHandler) Delete(bucket, name string) error

Delete delete existing object

func (*AWSHandler) Exists

func (h *AWSHandler) Exists(bucket string) error

Exists Checks whether a bucket exists and is accessible

func (*AWSHandler) Get

func (h *AWSHandler) Get(bucket, name string) (DeployableObject, error)

Get get existing object

func (*AWSHandler) InitObjectStoreConnection

func (h *AWSHandler) InitObjectStoreConnection(endpoint, accessKeyID, secretAccessKey string) error

InitObjectStoreConnection connect to object store

func (*AWSHandler) List

func (h *AWSHandler) List(bucket string) ([]string, error)

List all objects in bucket

func (*AWSHandler) Put

func (h *AWSHandler) Put(bucket string, dplObj DeployableObject) error

Put create new object

type ChannelDescription

type ChannelDescription struct {
	Channel *chv1.Channel
	Bucket  string
	ObjectStore
}

ChannelDescription contains channel and its object store information

type ChannelDescriptor

type ChannelDescriptor struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ChannelDescriptor stores channel descriptions and object store connections

func CreateObjectStorageChannelDescriptor

func CreateObjectStorageChannelDescriptor() (*ChannelDescriptor, error)

CreateChannelDescriptor - creates an instance of ChannelDescriptor

func (*ChannelDescriptor) ConnectWithResourceHost

func (desc *ChannelDescriptor) ConnectWithResourceHost(chn *chv1.Channel, kubeClient client.Client, log logr.Logger, objStoreHandler ...ObjectStore) error

ConnectWithResourceHost validates and makes channel object store connection

func (*ChannelDescriptor) Delete

func (desc *ChannelDescriptor) Delete(chname string)

Delete the channel description

func (*ChannelDescriptor) Get

func (desc *ChannelDescriptor) Get(chname string) (chdesc *ChannelDescription, ok bool)

Get channel description for a channel

func (*ChannelDescriptor) GetBucketNameByChannel

func (desc *ChannelDescriptor) GetBucketNameByChannel(chName string) string

func (*ChannelDescriptor) Put

func (desc *ChannelDescriptor) Put(chname string, chdesc *ChannelDescription)

Put a new channel description

func (*ChannelDescriptor) SetObjectStorageForChannel

func (desc *ChannelDescriptor) SetObjectStorageForChannel(chn *chv1.Channel, objStoreHandler ObjectStore) bool

SetObjectStorageForChannel is mainly for testing purpose

type DeployableObject

type DeployableObject struct {
	Name         string
	GenerateName string
	Version      string
	Content      []byte
}

type FakeObjectStore

type FakeObjectStore struct {
	//map[bucket]map[objName]DeployableObject[Name, Content]
	Clt map[string]map[string]DeployableObject
}

func (*FakeObjectStore) Create

func (m *FakeObjectStore) Create(bucket string) error

func (*FakeObjectStore) Delete

func (m *FakeObjectStore) Delete(bucket, name string) error

func (*FakeObjectStore) Exists

func (m *FakeObjectStore) Exists(bucket string) error

it's odd that we request the storage to be pre-set

func (*FakeObjectStore) Get

func (m *FakeObjectStore) Get(bucket, name string) (DeployableObject, error)

func (*FakeObjectStore) InitObjectStoreConnection

func (m *FakeObjectStore) InitObjectStoreConnection(endpoint, accessKeyID, secretAccessKey string) error

func (*FakeObjectStore) List

func (m *FakeObjectStore) List(bucket string) ([]string, error)

func (*FakeObjectStore) Put

func (m *FakeObjectStore) Put(bucket string, dplObj DeployableObject) error

type LoadIndexPageFunc

type LoadIndexPageFunc func(string, *corev1.ConfigMap, logr.Logger) (*http.Response, error)

type ObjectStore

type ObjectStore interface {
	InitObjectStoreConnection(endpoint, accessKeyID, secretAccessKey string) error
	Exists(bucket string) error
	Create(bucket string) error
	List(bucket string) ([]string, error)
	Put(bucket string, dplObj DeployableObject) error
	Delete(bucket, name string) error
	Get(bucket, name string) (DeployableObject, error)
}

ObjectStore interface

Jump to

Keyboard shortcuts

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