Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyFilters(secret v1.Secret, sub *appv1alpha1.Subscription) (v1.Secret, bool)
- func CheckAndInstallCRD(crdconfig *rest.Config, pathname string) error
- func CleanUpObject(s v1.Secret) v1.Secret
- func ConvertLabels(labelSelector *metav1.LabelSelector) (labels.Selector, error)
- func DplArrayToDplPointers(dplList []dplv1alpha1.Deployable) []*dplv1alpha1.Deployable
- func EnterFnString() string
- func ExitFuString(s string)
- func FiltePackageOut(filter *appv1alpha1.PackageFilter, dpl *dplv1alpha1.Deployable) bool
- func GenerateNextPoint(vhours RunHourRanges, rdays runDays, uniTime time.Time) time.Duration
- func GenerateVersionSet(dplPointers []*dplv1alpha1.Deployable, vsub string) map[string]VersionRep
- func GetClusterFromResourceObject(obj metav1.Object) *types.NamespacedName
- func GetFnName() string
- func GetHostDeployableFromObject(obj metav1.Object) *types.NamespacedName
- func GetHostSubscriptionFromObject(obj metav1.Object) *types.NamespacedName
- func GetSourceFromObject(obj metav1.Object) string
- func IsDeployableInVersionSet(vMap map[string]VersionRep, dpl *dplv1alpha1.Deployable) bool
- func IsLocalDeployable(instance *dplv1alpha1.Deployable) bool
- func IsResourceOwnedByCluster(obj metav1.Object, cluster types.NamespacedName) bool
- func KeywordsChecker(labelSelector *metav1.LabelSelector, ks []string) bool
- func LabelChecker(ls *metav1.LabelSelector, dplls map[string]string) bool
- func LabelsChecker(labelSelector *metav1.LabelSelector, ls map[string]string) bool
- func MatchLabelForSubAndDpl(ls *metav1.LabelSelector, dplls map[string]string) bool
- func MaxHour(a, b string) string
- func NamespacedNameFormat(str string) types.NamespacedName
- func NextStartPoint(tw *appv1alpha1.TimeWindow, t time.Time) time.Duration
- func OverrideResourceBySubscription(template *unstructured.Unstructured, pkgName string, ...) (*unstructured.Unstructured, error)
- func OverrideTemplate(template *unstructured.Unstructured, overrides []appv1alpha1.ClusterOverride) (*unstructured.Unstructured, error)
- func PackageSecert(s v1.Secret) *dplv1alpha1.Deployable
- func PrepareOverrides(cluster types.NamespacedName, instance *appv1alpha1.Deployable) ([]appv1alpha1.ClusterOverride, error)
- func SemverCheck(vSubStr, vDplStr string) bool
- func SetInClusterPackageStatus(substatus *appv1alpha1.SubscriptionStatus, pkgname string, pkgerr error, ...) error
- func UnifyTimeZone(tw *appv1alpha1.TimeWindow, t time.Time) time.Time
- func UpdateDeployableStatus(statusClient client.Client, templateerr error, tplunit metav1.Object, ...) error
- func UpdateSubscriptionStatus(statusClient client.Client, templateerr error, tplunit metav1.Object, ...) error
- func ValidatePackagesInSubscriptionStatus(statusClient client.StatusClient, sub *appv1alpha1.Subscription, ...) error
- type EventRecorder
- type RunHourRanges
- type VersionRep
Constants ¶
const NoiseLogLel = 5
NoiseLogLel - information inside "important functions"
const QuiteLogLel = 4
QuiteLogLel - "important" information
const VeryNoisy = 10
VeryNoisy = show call stack, routine and everything
Variables ¶
var CURDAY, _ = time.Parse(time.UnixDate, "Sat Jan 1 00:00:00 UTC 0000")
var MIDNIGHT, _ = time.Parse(time.UnixDate, "Sun Jan 2 00:00:00 UTC 0000")
var SubscriptionPredicateFunctions = predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { subOld := e.ObjectOld.(*appv1alpha1.Subscription) subNew := e.ObjectNew.(*appv1alpha1.Subscription) if len(subNew.GetFinalizers()) > 0 { return true } if !reflect.DeepEqual(subOld.GetLabels(), subNew.GetLabels()) { return true } if !reflect.DeepEqual(subOld.GetAnnotations(), subNew.GetAnnotations()) { return true } if !reflect.DeepEqual(subOld.Spec, subNew.Spec) { return true } if subNew.Status.Phase == "" || subNew.Status.Phase != subOld.Status.Phase { klog.V(5).Info("We care phase..", subNew.Status.Phase, " vs ", subOld.Status.Phase) return true } klog.V(5).Info("Something we don't care changed") return false }, }
SubscriptionPredicateFunctions filters status update
Functions ¶
func ApplyFilters ¶
func ApplyFilters(secret v1.Secret, sub *appv1alpha1.Subscription) (v1.Secret, bool)
ApplyFilters will apply the subscription level filters to the secret
func CheckAndInstallCRD ¶
CheckAndInstallCRD checks if deployable belongs to this cluster managed cluster annotation matches or no managed cluster annotation (local)
func CleanUpObject ¶
CleanUpObject is used to reset the sercet fields in order to put the secret into deployable template
func ConvertLabels ¶
func ConvertLabels(labelSelector *metav1.LabelSelector) (labels.Selector, error)
ConvertLabels coverts label selector to lables.Selector
func DplArrayToDplPointers ¶
func DplArrayToDplPointers(dplList []dplv1alpha1.Deployable) []*dplv1alpha1.Deployable
DplArrayToDplPointers covert the array to pointer array
func FiltePackageOut ¶
func FiltePackageOut(filter *appv1alpha1.PackageFilter, dpl *dplv1alpha1.Deployable) bool
func GenerateNextPoint ¶
func GenerateNextPoint(vhours RunHourRanges, rdays runDays, uniTime time.Time) time.Duration
next time will be: if current time is bigger than the last time point of the window, nextTime will be weekdays offset + the hour offset if current time is smaller than the lastSlot time point, nextTime will be a duration till next time slot start point or a 0(if current time is within a time window)
func GenerateVersionSet ¶
func GenerateVersionSet(dplPointers []*dplv1alpha1.Deployable, vsub string) map[string]VersionRep
GenerateVersionSet produce a map, key: dpl.GetGenerateName(), value: dpl.NamespacedName.String() the value is the largest version which meet the subscription version requirement.
func GetClusterFromResourceObject ¶
func GetClusterFromResourceObject(obj metav1.Object) *types.NamespacedName
GetClusterFromResourceObject return nil if no host is found
func GetHostDeployableFromObject ¶
func GetHostDeployableFromObject(obj metav1.Object) *types.NamespacedName
GetHostDeployableFromObject return nil if no host is found
func GetHostSubscriptionFromObject ¶
func GetHostSubscriptionFromObject(obj metav1.Object) *types.NamespacedName
GetHostSubscriptionFromObject extract the namespacedname of subscription hosting the object resource
func GetSourceFromObject ¶
GetHostSubscriptionFromObject extract the namespacedname of subscription hosting the object resource
func IsDeployableInVersionSet ¶
func IsDeployableInVersionSet(vMap map[string]VersionRep, dpl *dplv1alpha1.Deployable) bool
IsDeployableInVersionSet - check if deployable is in version
func IsLocalDeployable ¶
func IsLocalDeployable(instance *dplv1alpha1.Deployable) bool
IsLocalDeployable checks if the deployable meant to be deployed
func IsResourceOwnedByCluster ¶
func IsResourceOwnedByCluster(obj metav1.Object, cluster types.NamespacedName) bool
IsResourceOwnedByCluster checks if the deployable belongs to this controller by AnnotationManagedCluster only the managed cluster annotation matches
func KeywordsChecker ¶
func KeywordsChecker(labelSelector *metav1.LabelSelector, ks []string) bool
KeywordsChecker Checks if the helm chart has at least 1 keyword from the packageFilter.Keywords array
func LabelChecker ¶
func LabelChecker(ls *metav1.LabelSelector, dplls map[string]string) bool
func LabelsChecker ¶
func LabelsChecker(labelSelector *metav1.LabelSelector, ls map[string]string) bool
LabelsChecker checks labels against a labelSelector
func MatchLabelForSubAndDpl ¶
func MatchLabelForSubAndDpl(ls *metav1.LabelSelector, dplls map[string]string) bool
func NamespacedNameFormat ¶
func NamespacedNameFormat(str string) types.NamespacedName
func NextStartPoint ¶
func NextStartPoint(tw *appv1alpha1.TimeWindow, t time.Time) time.Duration
NextStartPoint will map the container's time to the location time specified by user then it will handle the window type as will the hour ange and weekdays for hour range and weekdays, it will handle as the following if hour range is empty and weekday is empty then retrun 0 if hour range is empty and weekday is not then return nextday durtion(here the window type will be considered again)
func OverrideResourceBySubscription ¶
func OverrideResourceBySubscription(template *unstructured.Unstructured, pkgName string, instance *appv1alpha1.Subscription) (*unstructured.Unstructured, error)
OverrideResourceBySubscription alter the given template with overrides
func OverrideTemplate ¶
func OverrideTemplate(template *unstructured.Unstructured, overrides []appv1alpha1.ClusterOverride) (*unstructured.Unstructured, error)
OverrideTemplate alter the given template with overrides
func PackageSecert ¶
func PackageSecert(s v1.Secret) *dplv1alpha1.Deployable
PackageSecert put the secret to the deployable template
func PrepareOverrides ¶
func PrepareOverrides(cluster types.NamespacedName, instance *appv1alpha1.Deployable) ([]appv1alpha1.ClusterOverride, error)
PrepareOverrides returns the overridemap for given deployable instance
func SemverCheck ¶
SemverCheck filter Deployable based on the version annotations from Subscription and Deployable. Assume the input version is a string which meets the Semver format(https://semver.org/) SemverCheck: if the subscription version is geater than deploayalbe, then return true, otherwise return false edge case: if the version of subscription or deployable is empty then return true
func SetInClusterPackageStatus ¶
func SetInClusterPackageStatus(substatus *appv1alpha1.SubscriptionStatus, pkgname string, pkgerr error, status interface{}) error
SetInClusterPackageStatus creates status strcuture and fill status
func UnifyTimeZone ¶
func UnifyTimeZone(tw *appv1alpha1.TimeWindow, t time.Time) time.Time
func UpdateDeployableStatus ¶
func UpdateDeployableStatus(statusClient client.Client, templateerr error, tplunit metav1.Object, status interface{}) error
UpdateDeployableStatus based on error message, and propagate resource status - nil: success - others: failed, with error message in reason
func UpdateSubscriptionStatus ¶
func UpdateSubscriptionStatus(statusClient client.Client, templateerr error, tplunit metav1.Object, status interface{}) error
UpdateSubscriptionStatus based on error message, and propagate resource status - nil: success - others: failed, with error message in reason
func ValidatePackagesInSubscriptionStatus ¶
func ValidatePackagesInSubscriptionStatus(statusClient client.StatusClient, sub *appv1alpha1.Subscription, pkgMap map[string]bool) error
ValidatePackagesInSubscriptionStatus validate the status struture for packages
Types ¶
type EventRecorder ¶
type EventRecorder struct {
record.EventRecorder
}
EventRecorder - record kubernetes event
func NewEventRecorder ¶
func NewEventRecorder(cfg *rest.Config, scheme *apiruntime.Scheme) (*EventRecorder, error)
NewEventRecorder - create new event recorder from rect config
func (*EventRecorder) RecordEvent ¶
func (rec *EventRecorder) RecordEvent(obj apiruntime.Object, reason, msg string, err error)
RecordEvent - record kuberentes event
type RunHourRanges ¶
type RunHourRanges []appv1alpha1.HourRange
func MergeHourRanges ¶
func MergeHourRanges(in RunHourRanges) RunHourRanges
func ReverseRange ¶
func ReverseRange(in RunHourRanges) RunHourRanges
func (RunHourRanges) Len ¶
func (rh RunHourRanges) Len() int
func (RunHourRanges) Less ¶
func (rh RunHourRanges) Less(i, j int) bool
func (RunHourRanges) Swap ¶
func (rh RunHourRanges) Swap(i, j int)
type VersionRep ¶
type VersionRep struct { DplKey string // contains filtered or unexported fields }
VersionRep represent version