utils

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SecretMapKeyAccessKeyID is key of accesskeyid in secret
	SecretMapKeyAccessKeyID = "AccessKeyID"
	USERNAME                = "username"
	// SecretMapKeySecretAccessKey is key of secretaccesskey in secret
	SecretMapKeySecretAccessKey = "SecretAccessKey"
	PASSWORD                    = "password"
	// SecretMapKeyRegion is key of region in secret.
	SecretMapKeyRegion = "Region"
	//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.Git of the Helm CR
	HelmCRSourceGit = "git"
	// HelmCRRepoURL is spec.Source.Git.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

View Source
var ClusterPredicateFunc = predicate.Funcs{
	UpdateFunc: func(e event.UpdateEvent) bool {
		oldcl := e.ObjectOld.(*spokeClusterV1.ManagedCluster)
		newcl := e.ObjectNew.(*spokeClusterV1.ManagedCluster)

		if !reflect.DeepEqual(oldcl.DeletionTimestamp, newcl.DeletionTimestamp) {
			return true
		}

		if !reflect.DeepEqual(oldcl.Labels, newcl.Labels) {
			return true
		}

		oldcondMap := make(map[string]metav1.ConditionStatus)
		for _, cond := range oldcl.Status.Conditions {
			oldcondMap[cond.Type] = cond.Status
		}
		for _, cond := range newcl.Status.Conditions {
			oldcondst, ok := oldcondMap[cond.Type]
			if !ok || oldcondst != cond.Status {
				return true
			}
			delete(oldcondMap, cond.Type)
		}

		if len(oldcondMap) > 0 {
			return true
		}

		klog.V(1).Info("Out Cluster Predicate Func ", oldcl.Name, " with false possitive")
		return false
	},
}

Functions

func ConvertLabels added in v0.5.0

func ConvertLabels(labelSelector *metav1.LabelSelector) (labels.Selector, error)

func DetectClusterRegistry added in v0.5.0

func DetectClusterRegistry(ctx context.Context, clReader client.Reader)

DetectClusterRegistry - Detect the cluster API service every 10 seconds. the controller will be exited when it is ready The controller will be auto restarted by the multicluster-operators-application deployment CR later.

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 GetHelmRepoIndex

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

GetHelmRepoIndex get the index file from helm repository

func IsReadyClusterRegistry added in v0.5.0

func IsReadyClusterRegistry(clReader client.Reader) bool

IsReadyClusterRegistry check if Cluster API service is ready or not.

func LoadLocalIdx

func LoadLocalIdx(idxPath string, insecureSkipVerify bool, srt *corev1.Secret, 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 ParseSecretInfo added in v0.9.0

func ParseSecretInfo(secret *corev1.Secret) (username string, password string, region string)

func UpdateServingChannel

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

UpdateServingChannel add/remove the given channel to the current serving 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, region 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) 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

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
}

type LoadIndexPageFunc

type LoadIndexPageFunc func(idxPath string, secureSkip bool, srt *corev1.Secret, cfg *corev1.ConfigMap, logger logr.Logger) (*http.Response, error)

type ObjectStore

type ObjectStore interface {
	InitObjectStoreConnection(endpoint, accessKeyID, secretAccessKey, region 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