utils

package
v0.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: Apache-2.0 Imports: 30 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 (
	// UserID is key of GitHub user ID in secret
	UserID = "user"
	// Password is key of GitHub user password or personal token in secret
	Password = "accessToken"
)
View Source
const (

	// HelmCRKind is kind of the Helm CR
	HelmCRKind = "HelmRelease"
	// HelmCRAPIVersion is APIVersion of the Helm CR
	HelmCRAPIVersion = "app.ibm.com/v1alpha1"
	// 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"
)

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 CloneGitRepo

func CloneGitRepo(chn *chv1.Channel, kubeClient client.Client) (*repo.IndexFile, map[string]string, error)

CloneGitRepo clones the GitHub repo

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) (*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) (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 GetHelmRepoIndex

func GetHelmRepoIndex(channelPathName string) (*repo.IndexFile, error)

GetHelmRepoIndex get the index file from helm repository

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) 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) Put

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

Put a new channel description

func (*ChannelDescriptor) ValidateChannel

func (desc *ChannelDescriptor) ValidateChannel(chn *chv1.Channel, kubeClient client.Client, objStoreHandler ...ObjectStore) error

ValidateChannel validates and makes channel object store connection

type DeployableObject

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

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