Documentation
¶
Index ¶
- Variables
- func BindRootAPI(ctx context.Context, kcpClient kcpclient.Interface, exportName string) error
- func BindRootAPIs(ctx context.Context, kcpClient kcpclient.Interface, exportNames ...string) error
- func Bootstrap(ctx context.Context, discoveryClient discovery.DiscoveryInterface, ...) error
- func CreateGroupedResources(ctx context.Context, client dynamic.Interface, mapper meta.RESTMapper, ...) error
- func CreateResourceFromFS(ctx context.Context, client dynamic.Interface, mapper meta.RESTMapper, ...) error
- func CreateResources(ctx context.Context, client dynamic.Interface, mapper meta.RESTMapper, ...) error
- func CreateResourcesFromFS(ctx context.Context, client dynamic.Interface, mapper meta.RESTMapper, ...) error
- func GroupObjectsByDefaultHierarchy(objects []*unstructured.Unstructured) [][]*unstructured.Unstructured
- func GroupObjectsByHierarchy(objects []*unstructured.Unstructured, weights []schema.GroupVersionKind) [][]*unstructured.Unstructured
- func ObjectWeight(obj *unstructured.Unstructured, weights []schema.GroupVersionKind) int
- func ParseYAML(data []byte) ([]*unstructured.Unstructured, error)
- func ReadRawFromFS(ctx context.Context, embedFS embed.FS, filename string, ...) ([]byte, error)
- func ReadResourceFromFS(ctx context.Context, embedFS embed.FS, filename string, ...) ([]*unstructured.Unstructured, error)
- func ReadResourcesFromFS(ctx context.Context, embedFS embed.FS, transformers []TransformFileFunc, ...) ([]*unstructured.Unstructured, error)
- func SortObjectsByDefaultHierarchy(objects []*unstructured.Unstructured)
- func SortObjectsByHierarchy(objects []*unstructured.Unstructured, weights []schema.GroupVersionKind)
- func Template(ctx context.Context, raw []byte, input *TemplateInput) ([]byte, error)
- type Option
- type TemplateInput
- type TransformFileFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultWeights = []schema.GroupVersionKind{
{Group: "apiextensions.k8s.io"},
{Group: "core.kcp.io"},
{Group: "tenancy.kcp.io", Kind: "WorkspaceAuthenticationConfiguration"},
{Group: "tenancy.kcp.io", Kind: "WorkspaceType"},
{Group: "tenancy.kcp.io"},
{Group: "topology.kcp.io"},
{Group: "apis.kcp.io", Kind: "APIResourceSchema"},
{Group: "apis.kcp.io", Kind: "APIExport"},
{Group: "apis.kcp.io", Kind: "APIBinding"},
{Group: "apis.kcp.io"},
{Kind: "Namespace"},
}
DefaultWeights is the default hierarchy for kcp related APIs to apply in order without errors or retrying.
Functions ¶
func BindRootAPI ¶ added in v0.31.0
func BindRootAPIs ¶ added in v0.6.0
func Bootstrap ¶
func Bootstrap(ctx context.Context, discoveryClient discovery.DiscoveryInterface, dynamicClient dynamic.Interface, batteriesIncluded sets.Set[string], efs embed.FS, opts ...Option) error
Bootstrap creates resources in a package's fs by continuously retrying the list. This is blocking, i.e. it only returns (with error) when the context is closed or with nil when the bootstrapping is successfully completed.
func CreateGroupedResources ¶ added in v0.31.0
func CreateGroupedResources(ctx context.Context, client dynamic.Interface, mapper meta.RESTMapper, groups [][]*unstructured.Unstructured) error
CreateGroupedResources sequentially runs CreateResources for each group of resources.
func CreateResourceFromFS ¶
func CreateResourceFromFS(ctx context.Context, client dynamic.Interface, mapper meta.RESTMapper, batteriesIncluded sets.Set[string], filename string, efs embed.FS, transformers ...TransformFileFunc) error
CreateResourceFromFS creates given resource file.
func CreateResources ¶ added in v0.31.0
func CreateResources(ctx context.Context, client dynamic.Interface, mapper meta.RESTMapper, resources []*unstructured.Unstructured) error
CreateResources creates all resources from a group of resources.
func CreateResourcesFromFS ¶
func CreateResourcesFromFS(ctx context.Context, client dynamic.Interface, mapper meta.RESTMapper, batteriesIncluded sets.Set[string], efs embed.FS, transformers ...TransformFileFunc) error
CreateResourcesFromFS creates all resources from a filesystem.
func GroupObjectsByDefaultHierarchy ¶ added in v0.31.0
func GroupObjectsByDefaultHierarchy(objects []*unstructured.Unstructured) [][]*unstructured.Unstructured
GroupObjectsByDefaultHierarchy returns the given objects grouped by their hierarchy using DefaultWeights.
func GroupObjectsByHierarchy ¶ added in v0.31.0
func GroupObjectsByHierarchy(objects []*unstructured.Unstructured, weights []schema.GroupVersionKind) [][]*unstructured.Unstructured
GroupObjectsByHierarchy returns the given objects grouped by their hierarchy as determined by weights.
func ObjectWeight ¶ added in v0.31.0
func ObjectWeight(obj *unstructured.Unstructured, weights []schema.GroupVersionKind) int
ObjectWeight returns the weight of the object based on the given weights.
func ParseYAML ¶ added in v0.31.0
func ParseYAML(data []byte) ([]*unstructured.Unstructured, error)
ParseYAML parses the given YAML data into unstructured.Unstructured objects.
Taken from init-agent: https://github.com/kcp-dev/init-agent/blob/1e747d414a1bd2417b77bef845f8c68487428890/internal/manifest/yaml.go#L29-L54
func ReadRawFromFS ¶ added in v0.31.0
func ReadRawFromFS( ctx context.Context, embedFS embed.FS, filename string, transformers []TransformFileFunc, ti *TemplateInput, ) ([]byte, error)
ReadRawFromFS reads a file from the filesystem, applies the transformers and templates it.
func ReadResourceFromFS ¶ added in v0.31.0
func ReadResourceFromFS( ctx context.Context, embedFS embed.FS, filename string, transformers []TransformFileFunc, batteries sets.Set[string], ) ([]*unstructured.Unstructured, error)
ReadResourceFromFS uses ReadRawFromFS to read a file and returns it based on the batteries input as a slice of unstructured.Unstructured.
func ReadResourcesFromFS ¶ added in v0.31.0
func ReadResourcesFromFS( ctx context.Context, embedFS embed.FS, transformers []TransformFileFunc, batteries sets.Set[string], ) ([]*unstructured.Unstructured, error)
ReadResourcesFromFS calls ReadResourceFromFS for each file in the filesystem and returns an aggregation of all resources.
func SortObjectsByDefaultHierarchy ¶ added in v0.31.0
func SortObjectsByDefaultHierarchy(objects []*unstructured.Unstructured)
SortObjectsByDefaultHierarchy sorts the given objects using DefaultWeights.
func SortObjectsByHierarchy ¶ added in v0.31.0
func SortObjectsByHierarchy(objects []*unstructured.Unstructured, weights []schema.GroupVersionKind)
SortObjectsByHierarchy ensures that objects are (hopefully) sorted in an order that guarantees that they apply without errors and retrying for kcp relevant APIs.
Taken from init-agent: https://github.com/kcp-dev/init-agent/blob/1e747d414a1bd2417b77bef845f8c68487428890/internal/manifest/sort.go#L27-L60
Types ¶
type Option ¶
type Option struct {
// TransformFileFunc is a function that transforms a resource file before being applied to the cluster.
TransformFile TransformFileFunc
}
Option allows to customize the bootstrap process.
func ReplaceOption ¶
ReplaceOption allows to customize the bootstrap process.
type TemplateInput ¶ added in v0.31.0
func NewTemplateInput ¶ added in v0.31.0
func NewTemplateInput(batteries sets.Set[string]) *TemplateInput
type TransformFileFunc ¶
TransformFileFunc transforms a resource file before being applied to the cluster.