Documentation ¶
Index ¶
- Constants
- Variables
- func GetContainerImage(pod *v1.Pod, name string, initContainer bool) (string, error)
- func GetContainerImagePullPolicy(pod *v1.Pod, name string, initContainer bool) (v1.PullPolicy, error)
- func GetMatchingContainer(containers []v1.Container, name string) (v1.Container, error)
- func GetRunningPod(ctx context.Context, kube client.Client) (*v1.Pod, error)
- func GetSpecContainer(spec v1.PodSpec, name string, initContainer bool) (v1.Container, error)
- func HasPrefixedLabel(obj metav1.Object, prefixes ...string) bool
- func MultiParentLabel(packageParent metav1.Object) string
- func MultiParentLabelPrefix(packageParent metav1.Object) string
- func ParentLabels(i KindlyIdentifier) map[string]string
- func PersonaRoleName(p *v1alpha1.Package, persona string) string
- func Unpack(rw walker.ResourceWalker, out io.StringWriter, baseDir, permissionScope string, ...) error
- type ExecutorInfo
- type ExecutorInfoDiscoverer
- type KindlyIdentifier
- type KubeExecutorInfoDiscoverer
- type PackageGroup
- type PackagePackage
- func (sp *PackagePackage) AddCRD(path string, crd *apiextensions.CustomResourceDefinition)
- func (sp *PackagePackage) AddGroup(path string, sg PackageGroup)
- func (sp *PackagePackage) AddIcon(path string, icon v1alpha1.IconSpec)
- func (sp *PackagePackage) AddResource(filepath string, sr PackageResource)
- func (sp *PackagePackage) AddUI(filepath string, ui string)
- func (sp *PackagePackage) GetDefaultTmplCtrlImage() string
- func (sp *PackagePackage) GotApp() bool
- func (sp *PackagePackage) GotBehavior() bool
- func (sp *PackagePackage) IsNamespaced() bool
- func (sp *PackagePackage) SetApp(app v1alpha1.AppMetadataSpec)
- func (sp *PackagePackage) SetBehavior(sd v1alpha1.Behavior)
- func (sp *PackagePackage) SetInstall(install unstructured.Unstructured) error
- func (sp *PackagePackage) SetRBAC(rbac v1alpha1.PermissionsSpec)
- func (sp *PackagePackage) Yaml() (string, error)
- type PackagePackager
- type PackageResource
Constants ¶
const ( // rbac.crossplane.io/aggregate-to-{scope}-{persona} // {scope} is namespace or environment and may include "-default" // persona is one of admin, edit, or view LabelAggregateFmt = "rbac.crossplane.io/aggregate-to-%s-%s" // namespace.crossplane.io/{namespace} LabelNamespacePrefix = "namespace.crossplane.io/" LabelNamespaceFmt = LabelNamespacePrefix + "%s" LabelScope = "crossplane.io/scope" // crossplane:ns:{namespace}:{persona} NamespaceClusterRoleNameFmt = "crossplane:ns:%s:%s" )
Labels used to track ownership across namespaces and scopes.
const ( NamespaceScoped = "namespace" EnvironmentScoped = "environment" )
Crossplane ClusterRole Scopes
const ( // PodNameEnvVar is the env variable for getting the pod name via downward api PodNameEnvVar = "POD_NAME" // PodNamespaceEnvVar is the env variable for getting the pod namespace via downward api PodNamespaceEnvVar = "POD_NAMESPACE" )
const ( LabelParentGroup = "core.crossplane.io/parent-group" LabelParentVersion = "core.crossplane.io/parent-version" LabelParentKind = "core.crossplane.io/parent-kind" LabelParentNamespace = "core.crossplane.io/parent-namespace" LabelParentName = "core.crossplane.io/parent-name" LabelMultiParentPrefix = "parent.packages.crossplane.io/" LabelMultiParentNSFormat = LabelMultiParentPrefix + "%s" // LabelMultiParentFormat defines the format for combining a // LabelMultiParentNSFormat with a named resource // Example: // fmt.Sprintf(LabelMultiParentFormat, // fmt.Sprintf(LabelMultiParentNSFormat, // nsName, // ), resourceName) LabelMultiParentFormat = "%s-%s" )
Labels used to track ownership across namespaces and scopes.
const ( // StackDefinitionNamespaceEnv is an environment variable used in the // StackDefinition controllers deployment to find the StackDefinition StackDefinitionNamespaceEnv = "SD_NAMESPACE" // StackDefinitionNameEnv is an environment variable used in the // StackDefinition controllers deployment to find the StackDefinition StackDefinitionNameEnv = "SD_NAME" // PackageImageEnv is an environment variable used by the unpack job to select // the stack version if there is no version provided in the application // metadata. PackageImageEnv = "STACK_IMAGE" // LabelKubernetesManagedBy identifies the resource manager LabelKubernetesManagedBy = "app.kubernetes.io/managed-by" // LabelValuePackageManager is the Crossplane Package Manager managed-by value LabelValuePackageManager = "package-manager" )
Variables ¶
var ( // PodImageNameEnvVar is the env variable for setting the image name used // for the package manager unpack/install process. When this env variable is // not set the parent Pod will be detected and the associated image will be // used. Overriding this variable is only useful when debugging the main // package manager process, since there is no Pod to detect. Use of this env // variable requires use of its ImagePullPolicy counterpart. PodImageNameEnvVar = "PACKAGE_MANAGER_IMAGE" // PodImagePullPolicyEnvVar is the env variable for setting the image pull // policy used for the package manager unpack/install process. When this env // variable is not set the parent Pod will be detected and the associated // image pull policy will be used. Overriding this variable is only useful // when debugging the main package manager process, since there is no Pod to // detect. Use of this env variable requires use of its Image counterpart. PodImagePullPolicyEnvVar = "PACKAGE_MANAGER_IMAGEPULLPOLICY" )
var ( // PackageCoreRBACRules are the rules that all Package controllers receive PackageCoreRBACRules = []rbacv1.PolicyRule{{ APIGroups: []string{""}, ResourceNames: []string{}, Resources: []string{"configmaps", "events", "secrets"}, Verbs: []string{"*"}, }} )
Functions ¶
func GetContainerImage ¶
GetContainerImage will get the container image for the container with the given name in the given pod.
func GetContainerImagePullPolicy ¶
func GetContainerImagePullPolicy(pod *v1.Pod, name string, initContainer bool) (v1.PullPolicy, error)
GetContainerImagePullPolicy will get the container image pull policy for the container with the given name in the given pod.
func GetMatchingContainer ¶
GetMatchingContainer returns the container from the given set of containers that matches the given name. If the given container list has only 1 item then the name field is ignored and that container is returned.
func GetRunningPod ¶
GetRunningPod will get the pod object for the currently running pod. This assumes that the downward API has been used to inject the pod name and namespace as env vars.
func GetSpecContainer ¶
GetSpecContainer will get the container with the given name in the given pod spec.
func HasPrefixedLabel ¶
HasPrefixedLabel checks if any label on an Object starts with any of the provided prefixes
func MultiParentLabel ¶
MultiParentLabel returns a label name identifying the namespaced name of the package resource that co-owns another resource
The label returned is based on the MultiParentLabelPrefix, which may include a truncation suffix, and is then potentially truncated again to fit in the complete label length restrictions.
Example: MultiParentLabel(resource.SetNamespace("foo").SetName("bar").) ->
"parent.packages.crossplane.io/foo-bar"
A namespace name over 32 characters will be truncated in the returned label prefix, if the namespace and name, combined exceed 63 characters an additional truncation will be included.
func MultiParentLabelPrefix ¶
MultiParentLabelPrefix returns the NS specific prefix of a multi-parent label for resources co-owned by a set of Packages.
This prefix is suitable for identifying resources labeled within a given namespace. The prefix may include a predictable truncation suffix if the namespace exceeds 32 characters. This truncation length permits another 32 characters for a (potentially truncated) resource name to be appended to the label.
Example: MultiParentLabelPrefix(resource.SetNamespace("foo")) ->
"parent.packages.crossplane.io/foo"
A namespace name over 32 characters will be truncated in the returned label prefix.
func ParentLabels ¶
func ParentLabels(i KindlyIdentifier) map[string]string
ParentLabels returns a map of labels referring to the given resource
func PersonaRoleName ¶
PersonaRoleName is a helper to ensure the persona role formatting parameters are provided consistently
func Unpack ¶
func Unpack(rw walker.ResourceWalker, out io.StringWriter, baseDir, permissionScope string, tsControllerImage string, log logging.Logger) error
Unpack writes to `out` using custom Step functions against a ResourceWalker The custom Steps process Package resource files and the output is multiple YAML documents. CRDs container within the package will be annotated based on the other Package resource files contained within the Package.
baseDir is expected to be an absolute path, i.e. have a root to the path, at the very least "/".
Types ¶
type ExecutorInfo ¶
type ExecutorInfo struct { Image string ImagePullPolicy corev1.PullPolicy }
ExecutorInfo stores information about an executing container
type ExecutorInfoDiscoverer ¶
type ExecutorInfoDiscoverer interface {
Discover(context.Context) (*ExecutorInfo, error)
}
ExecutorInfoDiscoverer implementations can Discover an Image
type KindlyIdentifier ¶
type KindlyIdentifier interface { GetName() string GetNamespace() string GetUID() types.UID GroupVersionKind() schema.GroupVersionKind }
KindlyIdentifier implementations provide the means to access the Name, Namespace, GVK, and UID of a resource
type KubeExecutorInfoDiscoverer ¶
type KubeExecutorInfoDiscoverer struct { ExecutorInfo Client client.Client // contains filtered or unexported fields }
KubeExecutorInfoDiscoverer discovers container information about an executing Kubernetes pod
func (*KubeExecutorInfoDiscoverer) Discover ¶
func (eif *KubeExecutorInfoDiscoverer) Discover(ctx context.Context) (*ExecutorInfo, error)
Discover the container image from the predefined Package Manager pod. ExecutorInfo is not expected to change at runtime, so lookups will be cached. Clear the cache by reseting Image before running Discover.
type PackageGroup ¶
type PackageGroup struct { Title string `json:"title"` OverviewShort string `json:"overviewShort,omitempty"` Overview string `json:"overview,omitempty"` Readme string `json:"readme,omitempty"` Category string `json:"category"` }
PackageGroup provides the Package metadata for a resource group. This is the format for group.yaml files.
type PackagePackage ¶
type PackagePackage struct { // Package is the Kubernetes API Package representation Package v1alpha1.Package // StackDefinition is the Kubernetes API StackDefintion representation StackDefinition v1alpha1.StackDefinition // CRDs map CRD files contained within a Package by their GVK CRDs map[string]apiextensions.CustomResourceDefinition // CRDPaths map CRDs to the path they were found in // Package resources will be paired based on their path and the CRD path. CRDPaths map[string]string Groups map[string]PackageGroup Icons map[string]*v1alpha1.IconSpec Resources map[string]PackageResource UISchemas map[string]string // contains filtered or unexported fields }
PackagePackage defines the artifact structure of Packages A fully processed Package can be thought of as a Package CR and a collection of managed CRDs. The Package CR includes its controller install and RBAC definitions. The managed CRDS are annotated by their Package resource, icon, group, and UI descriptors.
func NewPackagePackage ¶
func NewPackagePackage(baseDir, tmplCtrlImage string, log logging.Logger) *PackagePackage
NewPackagePackage returns a PackagePackage with maps created
func (*PackagePackage) AddCRD ¶
func (sp *PackagePackage) AddCRD(path string, crd *apiextensions.CustomResourceDefinition)
AddCRD appends a CRD to the CRDs of this PackagePackage The CRD will be annotated before being added and the Package will track ownership of this CRD.
func (*PackagePackage) AddGroup ¶
func (sp *PackagePackage) AddGroup(path string, sg PackageGroup)
AddGroup adds a group to the PackagePackage
func (*PackagePackage) AddIcon ¶
func (sp *PackagePackage) AddIcon(path string, icon v1alpha1.IconSpec)
AddIcon adds an icon to the PackagePackage
func (*PackagePackage) AddResource ¶
func (sp *PackagePackage) AddResource(filepath string, sr PackageResource)
AddResource adds a resource to the PackagePackage
func (*PackagePackage) AddUI ¶
func (sp *PackagePackage) AddUI(filepath string, ui string)
AddUI adds a resource to the PackagePackage
func (*PackagePackage) GetDefaultTmplCtrlImage ¶
func (sp *PackagePackage) GetDefaultTmplCtrlImage() string
GetDefaultTmplCtrlImage returns the default templating controller image path.
func (*PackagePackage) GotApp ¶
func (sp *PackagePackage) GotApp() bool
GotApp reveals if the AppMetadataSpec has been set
func (*PackagePackage) GotBehavior ¶
func (sp *PackagePackage) GotBehavior() bool
GotBehavior reveals if the BehaviorSpec has been set
func (*PackagePackage) IsNamespaced ¶
func (sp *PackagePackage) IsNamespaced() bool
IsNamespaced reports if the PackagePackage is Namespaced (not Cluster Scoped)
func (*PackagePackage) SetApp ¶
func (sp *PackagePackage) SetApp(app v1alpha1.AppMetadataSpec)
SetApp sets the Package's App metadata
func (*PackagePackage) SetBehavior ¶
func (sp *PackagePackage) SetBehavior(sd v1alpha1.Behavior)
SetBehavior sets the Package's Behavior This is primarily for defining Template Package behaviors
func (*PackagePackage) SetInstall ¶
func (sp *PackagePackage) SetInstall(install unstructured.Unstructured) error
SetInstall sets the Package controller's install method from a Deployment or Job
func (*PackagePackage) SetRBAC ¶
func (sp *PackagePackage) SetRBAC(rbac v1alpha1.PermissionsSpec)
SetRBAC sets the PackagePackage Package's permissions with using the supplied PermissionsSpec
func (*PackagePackage) Yaml ¶
func (sp *PackagePackage) Yaml() (string, error)
Yaml returns a multiple document YAML representation of the Package Package This YAML includes the Package itself and and all CRDs managed by that Package.
type PackagePackager ¶
type PackagePackager interface { SetApp(v1alpha1.AppMetadataSpec) SetBehavior(v1alpha1.Behavior) SetInstall(unstructured.Unstructured) error SetRBAC(v1alpha1.PermissionsSpec) GotApp() bool IsNamespaced() bool GetDefaultTmplCtrlImage() string AddGroup(string, PackageGroup) AddResource(string, PackageResource) AddIcon(string, v1alpha1.IconSpec) AddUI(string, string) AddCRD(string, *apiextensions.CustomResourceDefinition) Yaml() (string, error) }
PackagePackager implentations can build a package from Package resources and emit the Yaml artifact
type PackageResource ¶
type PackageResource struct { // ID refers to the CRD Kind ID string `json:"id"` Title string `json:"title"` TitlePlural string `json:"titlePlural"` OverviewShort string `json:"overviewShort,omitempty"` Overview string `json:"overview,omitempty"` Readme string `json:"readme,omitempty"` Category string `json:"category"` }
PackageResource provides the Package metadata for a CRD. This is the format for resource.yaml files.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package truncate provides functions for truncating Kubernetes values in a predictable way offering mildly collision safe values usable in deterministic field searches.
|
Package truncate provides functions for truncating Kubernetes values in a predictable way offering mildly collision safe values usable in deterministic field searches. |