resolver

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 43 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// APILabelKeyPrefix is the key prefix for a CSV's APIs label
	APILabelKeyPrefix = "olm.api."
)
View Source
const (
	BundleLookupConditionPacked v1alpha1.BundleLookupConditionType = "BundleLookupNotPersisted"
)
View Source
const (
	BundleSecretKind = "BundleSecret"
)
View Source
const SkipPackageAnnotationKey = "olm.skipRange"

Variables

View Source
var ExistingOperator = OperatorSourceInfo{Package: "", Channel: "", StartingCSV: "", Catalog: NoCatalog, DefaultChannel: false}
View Source
var NoCatalog = registry.CatalogKey{Name: "", Namespace: ""}

Functions

func APIKeyToGVKHash

func APIKeyToGVKHash(key opregistry.APIKey) (string, error)

func APIKeyToGVKString

func APIKeyToGVKString(key opregistry.APIKey) string

func LabelSetsFor

func LabelSetsFor(obj interface{}) ([]labels.Set, error)

LabelSetsFor returns API label sets for the given object. Concrete types other than OperatorSurface and CustomResource definition no-op.

func Matches

func Matches(o *Operator, p ...OperatorPredicate) bool

func NewInvalidSubscriptionInstallable added in v0.18.0

func NewInvalidSubscriptionInstallable(name string, reason string) solver.Installable

func NewServiceAccountStepResources

func NewServiceAccountStepResources(csv *v1alpha1.ClusterServiceVersion, catalogSourceName, catalogSourceNamespace string) ([]v1alpha1.StepResource, error)

NewServiceAccountStepResources returns a list of step resources required to satisfy the RBAC requirements of the given CSV's InstallStrategy

func NewSingleAPIProviderInstallable added in v0.18.0

func NewSingleAPIProviderInstallable(group, version, kind string, providers []solver.Identifier) solver.Installable

func NewSinglePackageInstanceInstallable added in v0.18.0

func NewSinglePackageInstanceInstallable(pkg string, providers []solver.Identifier) solver.Installable

func NewStepResourceFromBundle

func NewStepResourceFromBundle(bundle *api.Bundle, namespace, replaces, catalogSourceName, catalogSourceNamespace string) ([]v1alpha1.StepResource, error)

func NewStepResourceFromObject

func NewStepResourceFromObject(obj runtime.Object, catalogSourceName, catalogSourceNamespace string) (v1alpha1.StepResource, error)

NewStepResourceForObject returns a new StepResource for the provided object

func NewStepsFromBundle

func NewStepsFromBundle(bundle *api.Bundle, namespace, replaces, catalogSourceName, catalogSourceNamespace string) ([]*v1alpha1.Step, error)

func NewSubscriptionInstallable

func NewSubscriptionInstallable(name string, dependencies []solver.Identifier) solver.Installable

func NewSubscriptionStepResource

func NewSubscriptionStepResource(namespace string, info OperatorSourceInfo) (v1alpha1.StepResource, error)

func PrettyConstraint added in v0.18.0

func PrettyConstraint(c solver.Constraint, msg string) solver.Constraint

func RBACForClusterServiceVersion

func RBACForClusterServiceVersion(csv *v1alpha1.ClusterServiceVersion) (map[string]*OperatorPermissions, error)

func V1alpha1CSVFromBundle

func V1alpha1CSVFromBundle(bundle *api.Bundle) (*v1alpha1.ClusterServiceVersion, error)

Types

type APIIntersectionReconcileFunc

type APIIntersectionReconcileFunc func(add APISet, group OperatorGroupSurface, otherGroups ...OperatorGroupSurface) APIReconciliationResult

func (APIIntersectionReconcileFunc) Reconcile

type APIIntersectionReconciler

type APIIntersectionReconciler interface {
	Reconcile(add APISet, group OperatorGroupSurface, otherGroups ...OperatorGroupSurface) APIReconciliationResult
}

type APIMultiOwnerSet

type APIMultiOwnerSet map[opregistry.APIKey]OperatorSet

func EmptyAPIMultiOwnerSet

func EmptyAPIMultiOwnerSet() APIMultiOwnerSet

func (APIMultiOwnerSet) PopAPIKey

func (s APIMultiOwnerSet) PopAPIKey() *opregistry.APIKey

func (APIMultiOwnerSet) PopAPIRequirers

func (s APIMultiOwnerSet) PopAPIRequirers() OperatorSet

type APIOwnerSet

type APIOwnerSet map[opregistry.APIKey]OperatorSurface

func EmptyAPIOwnerSet

func EmptyAPIOwnerSet() APIOwnerSet

type APIReconciliationResult

type APIReconciliationResult int
const (
	RemoveAPIs APIReconciliationResult = iota
	AddAPIs
	APIConflict
	NoAPIConflict
)

func ReconcileAPIIntersection

func ReconcileAPIIntersection(add APISet, group OperatorGroupSurface, otherGroups ...OperatorGroupSurface) APIReconciliationResult

type APISet

type APISet map[opregistry.APIKey]struct{}

func EmptyAPISet

func EmptyAPISet() APISet

func GVKStringToProvidedAPISet

func GVKStringToProvidedAPISet(gvksStr string) APISet

func (APISet) Difference

func (s APISet) Difference(set APISet) APISet

func (APISet) Intersection

func (s APISet) Intersection(sets ...APISet) APISet

Intersection returns the intersection of the APISet and the given list of APISets

func (APISet) IsSubset

func (s APISet) IsSubset(set APISet) bool

IsSubset returns true if the APISet is a subset of the given one

func (APISet) PopAPIKey

func (s APISet) PopAPIKey() *opregistry.APIKey

func (APISet) String

func (s APISet) String() string

func (APISet) StripPlural

func (s APISet) StripPlural() APISet

StripPlural returns the APISet with the Plural field of all APIKeys removed

func (APISet) Union

func (s APISet) Union(sets ...APISet) APISet

Union returns the union of the APISet and the given list of APISets

type BundleInstallable

type BundleInstallable struct {
	Replaces string
	// contains filtered or unexported fields
}

func NewBundleInstallable

func NewBundleInstallable(bundle, channel string, catalog registry.CatalogKey, constraints ...solver.Constraint) BundleInstallable

func (*BundleInstallable) AddConflict

func (i *BundleInstallable) AddConflict(id solver.Identifier)

func (*BundleInstallable) AddDependency

func (i *BundleInstallable) AddDependency(dependencies []solver.Identifier)

func (*BundleInstallable) BundleSourceInfo

func (i *BundleInstallable) BundleSourceInfo() (string, string, registry.CatalogKey, error)

func (BundleInstallable) Constraints

func (i BundleInstallable) Constraints() []solver.Constraint

func (BundleInstallable) Identifier

func (i BundleInstallable) Identifier() solver.Identifier

func (*BundleInstallable) MakeProhibited

func (i *BundleInstallable) MakeProhibited()

type CatalogSnapshot

type CatalogSnapshot struct {
	// contains filtered or unexported fields
}

func NewRunningOperatorSnapshot

func NewRunningOperatorSnapshot(logger logrus.FieldLogger, key registry.CatalogKey, o []*Operator) *CatalogSnapshot

NewRunningOperatorSnapshot creates a CatalogSnapshot that represents a set of existing installed operators in the cluster.

func (*CatalogSnapshot) Cancel

func (s *CatalogSnapshot) Cancel()

func (*CatalogSnapshot) Expired

func (s *CatalogSnapshot) Expired(at time.Time) bool

func (*CatalogSnapshot) Find

func (s *CatalogSnapshot) Find(p ...OperatorPredicate) []*Operator

type DefaultRegistryClientProvider

type DefaultRegistryClientProvider struct {
	// contains filtered or unexported fields
}

func (*DefaultRegistryClientProvider) ClientsForNamespaces

func (rcp *DefaultRegistryClientProvider) ClientsForNamespaces(namespaces ...string) map[registry.CatalogKey]client.Interface

type EmptyOperatorFinder

type EmptyOperatorFinder struct{}

func (EmptyOperatorFinder) Find

type GenericInstallable added in v0.18.0

type GenericInstallable struct {
	// contains filtered or unexported fields
}

func (GenericInstallable) Constraints added in v0.18.0

func (i GenericInstallable) Constraints() []solver.Constraint

func (GenericInstallable) Identifier added in v0.18.0

func (i GenericInstallable) Identifier() solver.Identifier

type InstrumentedResolver

type InstrumentedResolver struct {
	// contains filtered or unexported fields
}

func NewInstrumentedResolver

func NewInstrumentedResolver(resolver StepResolver, successMetricsEmitter, failureMetricsEmitter func(time.Duration)) *InstrumentedResolver

func (*InstrumentedResolver) Expire

func (ir *InstrumentedResolver) Expire(key registry.CatalogKey)

func (*InstrumentedResolver) ResolveSteps

func (ir *InstrumentedResolver) ResolveSteps(namespace string, sourceQuerier SourceQuerier) ([]*v1alpha1.Step, []v1alpha1.BundleLookup, []*v1alpha1.Subscription, error)

type MultiCatalogOperatorFinder

type MultiCatalogOperatorFinder interface {
	Catalog(registry.CatalogKey) OperatorFinder
	FindPreferred(*registry.CatalogKey, ...OperatorPredicate) []*Operator
	WithExistingOperators(*CatalogSnapshot) MultiCatalogOperatorFinder
	OperatorFinder
}

type NamespaceSet

type NamespaceSet map[string]struct{}

func NewNamespaceSet

func NewNamespaceSet(namespaces []string) NamespaceSet

func NewNamespaceSetFromString

func NewNamespaceSetFromString(namespaces string) NamespaceSet

NewNamespaceSetFromString creates a namespace set from a comma-delimited list of namespaces

func (NamespaceSet) Contains

func (n NamespaceSet) Contains(namespace string) bool

func (NamespaceSet) Intersection

func (n NamespaceSet) Intersection(set NamespaceSet) NamespaceSet

func (NamespaceSet) IsAllNamespaces

func (n NamespaceSet) IsAllNamespaces() bool

func (NamespaceSet) Peek

func (n NamespaceSet) Peek() string

func (NamespaceSet) Union

func (n NamespaceSet) Union(set NamespaceSet) NamespaceSet

type NamespaceSourceQuerier

type NamespaceSourceQuerier struct {
	// contains filtered or unexported fields
}

func (*NamespaceSourceQuerier) FindBundle

func (q *NamespaceSourceQuerier) FindBundle(pkgName, channelName, bundleName string, initialSource registry.CatalogKey) (*api.Bundle, *registry.CatalogKey, error)

func (*NamespaceSourceQuerier) FindLatestBundle

func (q *NamespaceSourceQuerier) FindLatestBundle(pkgName, channelName string, initialSource registry.CatalogKey) (*api.Bundle, *registry.CatalogKey, error)

func (*NamespaceSourceQuerier) FindProvider

func (q *NamespaceSourceQuerier) FindProvider(api opregistry.APIKey, initialSource registry.CatalogKey, excludedPackages map[string]struct{}) (*registryapi.Bundle, *registry.CatalogKey, error)

func (*NamespaceSourceQuerier) FindReplacement

func (q *NamespaceSourceQuerier) FindReplacement(currentVersion *semver.Version, bundleName, pkgName, channelName string, initialSource registry.CatalogKey) (*api.Bundle, *registry.CatalogKey, error)

func (*NamespaceSourceQuerier) Queryable

func (q *NamespaceSourceQuerier) Queryable() error

type NamespacedOperatorCache

type NamespacedOperatorCache struct {
	// contains filtered or unexported fields
}

func (*NamespacedOperatorCache) Catalog

func (*NamespacedOperatorCache) Find

func (*NamespacedOperatorCache) FindPreferred

func (c *NamespacedOperatorCache) FindPreferred(preferred *registry.CatalogKey, p ...OperatorPredicate) []*Operator

func (*NamespacedOperatorCache) WithExistingOperators

func (c *NamespacedOperatorCache) WithExistingOperators(snapshot *CatalogSnapshot) MultiCatalogOperatorFinder

type Operator

type Operator struct {
	// contains filtered or unexported fields
}

func AtLeast

func AtLeast(n int, operators []*Operator) ([]*Operator, error)

func ExactlyOne

func ExactlyOne(operators []*Operator) (*Operator, error)

func Filter

func Filter(operators []*Operator, p ...OperatorPredicate) []*Operator

func NewOperatorFromBundle

func NewOperatorFromBundle(bundle *api.Bundle, startingCSV string, sourceKey registry.CatalogKey, defaultChannel string) (*Operator, error)

func NewOperatorFromV1Alpha1CSV

func NewOperatorFromV1Alpha1CSV(csv *v1alpha1.ClusterServiceVersion) (*Operator, error)

func (*Operator) Bundle

func (o *Operator) Bundle() *api.Bundle

func (*Operator) Channel

func (o *Operator) Channel() string

func (*Operator) Dependencies

func (o *Operator) Dependencies() []*api.Dependency

func (*Operator) DependencyPredicates

func (o *Operator) DependencyPredicates() (predicates []OperatorPredicate, err error)

func (*Operator) Identifier

func (o *Operator) Identifier() string

func (*Operator) Inline

func (o *Operator) Inline() bool

func (*Operator) Package

func (o *Operator) Package() string

func (*Operator) Properties

func (o *Operator) Properties() []*api.Property

func (*Operator) ProvidedAPIs

func (o *Operator) ProvidedAPIs() APISet

func (*Operator) Replaces

func (o *Operator) Replaces() string

func (*Operator) RequiredAPIs

func (o *Operator) RequiredAPIs() APISet

func (*Operator) SetReplaces

func (o *Operator) SetReplaces(replacing string)

func (*Operator) Skips

func (o *Operator) Skips() []string

func (*Operator) SourceInfo

func (o *Operator) SourceInfo() *OperatorSourceInfo

func (*Operator) Version

func (o *Operator) Version() *semver.Version

type OperatorCache

type OperatorCache struct {
	// contains filtered or unexported fields
}

func (*OperatorCache) Expire

func (c *OperatorCache) Expire(catalog registry.CatalogKey)

func (*OperatorCache) Namespaced

func (c *OperatorCache) Namespaced(namespaces ...string) MultiCatalogOperatorFinder

type OperatorCacheProvider

type OperatorCacheProvider interface {
	Namespaced(namespaces ...string) MultiCatalogOperatorFinder
	Expire(catalog registry.CatalogKey)
}

type OperatorFinder

type OperatorFinder interface {
	Find(...OperatorPredicate) []*Operator
}

type OperatorGroup

type OperatorGroup struct {
	// contains filtered or unexported fields
}

func NewOperatorGroup

func NewOperatorGroup(group *v1.OperatorGroup) *OperatorGroup

func (*OperatorGroup) GroupIntersection

func (g *OperatorGroup) GroupIntersection(groups ...OperatorGroupSurface) []OperatorGroupSurface

func (*OperatorGroup) Identifier

func (g *OperatorGroup) Identifier() string

func (*OperatorGroup) Namespace

func (g *OperatorGroup) Namespace() string

func (*OperatorGroup) ProvidedAPIs

func (g *OperatorGroup) ProvidedAPIs() APISet

func (*OperatorGroup) Targets

func (g *OperatorGroup) Targets() NamespaceSet

type OperatorGroupSurface

type OperatorGroupSurface interface {
	Identifier() string
	Namespace() string
	Targets() NamespaceSet
	ProvidedAPIs() APISet
	GroupIntersection(groups ...OperatorGroupSurface) []OperatorGroupSurface
}

func NewOperatorGroupSurfaces

func NewOperatorGroupSurfaces(groups ...v1.OperatorGroup) []OperatorGroupSurface

type OperatorPermissions

type OperatorPermissions struct {
	ServiceAccount      *corev1.ServiceAccount
	Roles               []*rbacv1.Role
	RoleBindings        []*rbacv1.RoleBinding
	ClusterRoles        []*rbacv1.ClusterRole
	ClusterRoleBindings []*rbacv1.ClusterRoleBinding
}

func NewOperatorPermissions

func NewOperatorPermissions(serviceAccount *corev1.ServiceAccount) *OperatorPermissions

func (*OperatorPermissions) AddClusterRole

func (o *OperatorPermissions) AddClusterRole(clusterRole *rbacv1.ClusterRole)

func (*OperatorPermissions) AddClusterRoleBinding

func (o *OperatorPermissions) AddClusterRoleBinding(clusterRoleBinding *rbacv1.ClusterRoleBinding)

func (*OperatorPermissions) AddRole

func (o *OperatorPermissions) AddRole(role *rbacv1.Role)

func (*OperatorPermissions) AddRoleBinding

func (o *OperatorPermissions) AddRoleBinding(roleBinding *rbacv1.RoleBinding)

type OperatorPredicate

type OperatorPredicate interface {
	Test(*Operator) bool
}

func CountingPredicate added in v0.18.0

func CountingPredicate(p OperatorPredicate, n *int) OperatorPredicate

func False added in v0.18.0

func False() OperatorPredicate

func PredicateForDependency

func PredicateForDependency(dependency *api.Dependency) (OperatorPredicate, error)

TODO: this should go in its own dependency/predicate builder package TODO: can we make this more extensible, i.e. via cue

func ProvidingAPI

func ProvidingAPI(api opregistry.APIKey) OperatorPredicate

func Replaces

func Replaces(name string) OperatorPredicate

func SkipRangeIncludes

func SkipRangeIncludes(version semver.Version) OperatorPredicate

func True added in v0.18.0

func True() OperatorPredicate

func WithCSVName

func WithCSVName(name string) OperatorPredicate

func WithCatalog added in v0.18.0

func WithCatalog(key registry.CatalogKey) OperatorPredicate

func WithChannel

func WithChannel(channel string) OperatorPredicate

func WithLabel

func WithLabel(label string) OperatorPredicate

func WithPackage

func WithPackage(pkg string) OperatorPredicate

func WithVersionInRange

func WithVersionInRange(r semver.Range) OperatorPredicate

func WithoutDeprecatedProperty

func WithoutDeprecatedProperty() OperatorPredicate

type OperatorPredicateFunc added in v0.18.0

type OperatorPredicateFunc func(*Operator) bool

func (OperatorPredicateFunc) Test added in v0.18.0

func (opf OperatorPredicateFunc) Test(o *Operator) bool

type OperatorResolver

type OperatorResolver interface {
	SolveOperators(csvs []*v1alpha1.ClusterServiceVersion, subs []*v1alpha1.Subscription, add map[OperatorSourceInfo]struct{}) (OperatorSet, error)
}

type OperatorSet

type OperatorSet map[string]OperatorSurface

func EmptyOperatorSet

func EmptyOperatorSet() OperatorSet

func (OperatorSet) Snapshot

func (o OperatorSet) Snapshot() OperatorSet

Snapshot returns a new set, pointing to the same values

type OperatorSourceInfo

type OperatorSourceInfo struct {
	Package        string
	Channel        string
	StartingCSV    string
	Catalog        registry.CatalogKey
	DefaultChannel bool
}

func (*OperatorSourceInfo) String

func (i *OperatorSourceInfo) String() string

type OperatorStepResolver

type OperatorStepResolver struct {
	// contains filtered or unexported fields
}

func NewOperatorStepResolver

func NewOperatorStepResolver(lister operatorlister.OperatorLister, client versioned.Interface, kubeclient kubernetes.Interface,
	globalCatalogNamespace string, provider RegistryClientProvider, log logrus.FieldLogger) *OperatorStepResolver

func (*OperatorStepResolver) Expire

func (r *OperatorStepResolver) Expire(key registry.CatalogKey)

func (*OperatorStepResolver) ResolveSteps

type OperatorSurface

type OperatorSurface interface {
	ProvidedAPIs() APISet
	RequiredAPIs() APISet
	Identifier() string
	Replaces() string
	Version() *semver.Version
	SourceInfo() *OperatorSourceInfo
	Bundle() *api.Bundle
	Inline() bool
	Dependencies() []*api.Dependency
	Properties() []*api.Property
	Skips() []string
}

OperatorSurface describes the API surfaces provided and required by an Operator.

type RegistryClientProvider

type RegistryClientProvider interface {
	ClientsForNamespaces(namespaces ...string) map[registry.CatalogKey]client.Interface
}

type SatResolver

type SatResolver struct {
	// contains filtered or unexported fields
}

func (*SatResolver) SolveOperators

func (r *SatResolver) SolveOperators(namespaces []string, csvs []*v1alpha1.ClusterServiceVersion, subs []*v1alpha1.Subscription) (OperatorSet, error)

type SortableSnapshots

type SortableSnapshots struct {
	// contains filtered or unexported fields
}

func NewSortableSnapshots

func NewSortableSnapshots(existing, preferred *registry.CatalogKey, namespaces []string, snapshots map[registry.CatalogKey]*CatalogSnapshot) SortableSnapshots

func (SortableSnapshots) Len

func (s SortableSnapshots) Len() int

Len is the number of elements in the collection.

func (SortableSnapshots) Less

func (s SortableSnapshots) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (SortableSnapshots) Swap

func (s SortableSnapshots) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type SourceQuerier

type SourceQuerier interface {
	FindProvider(api opregistry.APIKey, initialSource registry.CatalogKey, excludedPackages map[string]struct{}) (*api.Bundle, *registry.CatalogKey, error)
	FindBundle(pkgName, channelName, bundleName string, initialSource registry.CatalogKey) (*api.Bundle, *registry.CatalogKey, error)
	FindLatestBundle(pkgName, channelName string, initialSource registry.CatalogKey) (*api.Bundle, *registry.CatalogKey, error)
	FindReplacement(currentVersion *semver.Version, bundleName, pkgName, channelName string, initialSource registry.CatalogKey) (*api.Bundle, *registry.CatalogKey, error)
	Queryable() error
}

type SourceRef

type SourceRef struct {
	Address     string
	Client      client.Interface
	LastConnect metav1.Time
	LastHealthy metav1.Time
}

type StepResolver

type StepResolver interface {
	ResolveSteps(namespace string, sourceQuerier SourceQuerier) ([]*v1alpha1.Step, []v1alpha1.BundleLookup, []*v1alpha1.Subscription, error)
	Expire(key registry.CatalogKey)
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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