Documentation ¶
Index ¶
- Constants
- Variables
- func GetContainerImage(pod *v1.Pod, name string) (string, error)
- func GetMatchingContainer(containers []v1.Container, name string) (v1.Container, error)
- func GetRunningPod(ctx context.Context, kube client.Client) (*v1.Pod, error)
- func GetSpecContainerImage(spec v1.PodSpec, name string, initContainer bool) (string, error)
- func ParentLabels(i KindlyIdentifier) map[string]string
- func PersonaRoleName(stack *v1alpha1.Stack, persona string) string
- func Unpack(rw walker.ResourceWalker, out io.StringWriter, baseDir, permissionScope string, ...) error
- type ExecutorInfo
- type ExecutorInfoDiscoverer
- type KindlyIdentifier
- type KubeExecutorInfoDiscoverer
- type StackGroup
- type StackPackage
- func (sp *StackPackage) AddCRD(path string, crd *apiextensions.CustomResourceDefinition)
- func (sp *StackPackage) AddGroup(path string, sg StackGroup)
- func (sp *StackPackage) AddIcon(path string, icon v1alpha1.IconSpec)
- func (sp *StackPackage) AddResource(filepath string, sr StackResource)
- func (sp *StackPackage) AddUI(filepath string, ui string)
- func (sp *StackPackage) GotApp() bool
- func (sp *StackPackage) GotBehavior() bool
- func (sp *StackPackage) IsNamespaced() bool
- func (sp *StackPackage) SetApp(app v1alpha1.AppMetadataSpec)
- func (sp *StackPackage) SetBehavior(sd v1alpha1.Behavior)
- func (sp *StackPackage) SetInstall(install unstructured.Unstructured) error
- func (sp *StackPackage) SetRBAC(rbac v1alpha1.PermissionsSpec)
- func (sp *StackPackage) Yaml() (string, error)
- type StackPackager
- type StackResource
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} LabelNamespaceFmt = "namespace.crossplane.io/%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" LabelParentUID = "core.crossplane.io/parent-uid" )
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" )
Variables ¶
var ( // PodImageNameEnvVar is the env variable for setting the image name used for the stack 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 stack manager process, since there is no Pod to detect. PodImageNameEnvVar = "STACK_MANAGER_IMAGE" )
Functions ¶
func GetContainerImage ¶ added in v0.8.0
GetContainerImage will get the container image for the container with the given name in the given pod.
func GetMatchingContainer ¶ added in v0.8.0
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 ¶ added in v0.8.0
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 GetSpecContainerImage ¶ added in v0.8.0
GetSpecContainerImage will get the container image for the container with the given name in the given pod spec.
func ParentLabels ¶ added in v0.6.0
func ParentLabels(i KindlyIdentifier) map[string]string
ParentLabels returns a map of labels referring to the given resource
func PersonaRoleName ¶ added in v0.6.0
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) error
Unpack writes to `out` using custom Step functions against a ResourceWalker The custom Steps process Stack resource files and the output is multiple YAML documents. CRDs container within the stack will be annotated based on the other Stack resource files contained within the Stack.
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
}
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 ¶ added in v0.6.0
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 Stack Manager pod
type StackGroup ¶
type StackGroup struct { Title string `json:"title"` OverviewShort string `json:"overviewShort,omitempty"` Overview string `json:"overview,omitempty"` Readme string `json:"readme,omitempty"` Category string `json:"category"` }
StackGroup provides the Stack metadata for a resource group. This is the format for group.yaml files.
type StackPackage ¶
type StackPackage struct { // Stack is the Kubernetes API Stack representation Stack v1alpha1.Stack // StackDefinition is the Kubernetes API Stack representation StackDefinition v1alpha1.StackDefinition // CRDs map CRD files contained within a Stack by their GVK CRDs map[string]apiextensions.CustomResourceDefinition // CRDPaths map CRDs to the path they were found in // Stack resources will be paired based on their path and the CRD path. CRDPaths map[string]string Groups map[string]StackGroup Icons map[string]*v1alpha1.IconSpec Resources map[string]StackResource UISchemas map[string]string // contains filtered or unexported fields }
StackPackage defines the artifact structure of Stacks A fully processed Stack can be thought of as a Stack CR and a collection of managed CRDs. The Stack CR includes its controller install and RBAC definitions. The managed CRDS are annotated by their Stack resource, icon, group, and UI descriptors.
func NewStackPackage ¶
func NewStackPackage(baseDir, tmplCtrlImage string) *StackPackage
NewStackPackage returns a StackPackage with maps created
func (*StackPackage) AddCRD ¶
func (sp *StackPackage) AddCRD(path string, crd *apiextensions.CustomResourceDefinition)
AddCRD appends a CRD to the CRDs of this StackPackage The CRD will be annotated before being added and the Stack will track ownership of this CRD.
func (*StackPackage) AddGroup ¶
func (sp *StackPackage) AddGroup(path string, sg StackGroup)
AddGroup adds a group to the StackPackage
func (*StackPackage) AddIcon ¶
func (sp *StackPackage) AddIcon(path string, icon v1alpha1.IconSpec)
AddIcon adds an icon to the StackPackage
func (*StackPackage) AddResource ¶
func (sp *StackPackage) AddResource(filepath string, sr StackResource)
AddResource adds a resource to the StackPackage
func (*StackPackage) AddUI ¶
func (sp *StackPackage) AddUI(filepath string, ui string)
AddUI adds a resource to the StackPackage
func (*StackPackage) GotApp ¶
func (sp *StackPackage) GotApp() bool
GotApp reveals if the AppMetadataSpec has been set
func (*StackPackage) GotBehavior ¶ added in v0.8.0
func (sp *StackPackage) GotBehavior() bool
GotBehavior reveals if the BehaviorSpec has been set
func (*StackPackage) IsNamespaced ¶ added in v0.4.0
func (sp *StackPackage) IsNamespaced() bool
IsNamespaced reports if the StackPackage is Namespaced (not Cluster Scoped)
func (*StackPackage) SetApp ¶
func (sp *StackPackage) SetApp(app v1alpha1.AppMetadataSpec)
SetApp sets the Stack's App metadata
func (*StackPackage) SetBehavior ¶ added in v0.7.0
func (sp *StackPackage) SetBehavior(sd v1alpha1.Behavior)
SetBehavior sets the Stack's Behavior This is primarily for defining Template Stack behaviors
func (*StackPackage) SetInstall ¶
func (sp *StackPackage) SetInstall(install unstructured.Unstructured) error
SetInstall sets the Stack controller's install method from a Deployment or Job
func (*StackPackage) SetRBAC ¶
func (sp *StackPackage) SetRBAC(rbac v1alpha1.PermissionsSpec)
SetRBAC sets the StackPackage Stack's permissions with using the supplied PermissionsSpec
func (*StackPackage) Yaml ¶
func (sp *StackPackage) Yaml() (string, error)
Yaml returns a multiple document YAML representation of the Stack Package This YAML includes the Stack itself and and all CRDs managed by that Stack.
type StackPackager ¶
type StackPackager interface { SetApp(v1alpha1.AppMetadataSpec) SetBehavior(v1alpha1.Behavior) SetInstall(unstructured.Unstructured) error SetRBAC(v1alpha1.PermissionsSpec) GotApp() bool IsNamespaced() bool AddGroup(string, StackGroup) AddResource(string, StackResource) AddIcon(string, v1alpha1.IconSpec) AddUI(string, string) AddCRD(string, *apiextensions.CustomResourceDefinition) Yaml() (string, error) }
StackPackager implentations can build a stack from Stack resources and emit the Yaml artifact
type StackResource ¶
type StackResource 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"` }
StackResource provides the Stack metadata for a CRD. This is the format for resource.yaml files.