cluster-api: sigs.k8s.io/cluster-api/controllers/external Index | Files

package external

import "sigs.k8s.io/cluster-api/controllers/external"

Index

Package Files

testing.go tracker.go types.go util.go

Constants

const (
    // TemplateSuffix is the object kind suffix used by infrastructure references associated
    // with MachineSet or MachineDeployments.
    TemplateSuffix = "Template"
)

Variables

var (
    TestGenericBootstrapCRD = &apiextensionsv1.CustomResourceDefinition{
        TypeMeta: metav1.TypeMeta{
            APIVersion: apiextensionsv1.SchemeGroupVersion.String(),
            Kind:       "CustomResourceDefinition",
        },
        ObjectMeta: metav1.ObjectMeta{
            Name: "bootstrapmachines.bootstrap.cluster.x-k8s.io",
            Labels: map[string]string{
                clusterv1.GroupVersion.String(): "v1alpha4",
            },
        },
        Spec: apiextensionsv1.CustomResourceDefinitionSpec{
            Group: "bootstrap.cluster.x-k8s.io",
            Scope: apiextensionsv1.NamespaceScoped,
            Names: apiextensionsv1.CustomResourceDefinitionNames{
                Kind:   "BootstrapMachine",
                Plural: "bootstrapmachines",
            },
            Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
                {
                    Name:    "v1alpha4",
                    Served:  true,
                    Storage: true,
                    Subresources: &apiextensionsv1.CustomResourceSubresources{
                        Status: &apiextensionsv1.CustomResourceSubresourceStatus{},
                    },
                    Schema: &apiextensionsv1.CustomResourceValidation{
                        OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
                            Type: "object",
                            Properties: map[string]apiextensionsv1.JSONSchemaProps{
                                "spec": {
                                    Type:                   "object",
                                    XPreserveUnknownFields: pointer.BoolPtr(true),
                                },
                                "status": {
                                    Type:                   "object",
                                    XPreserveUnknownFields: pointer.BoolPtr(true),
                                },
                            },
                        },
                    },
                },
            },
        },
    }

    TestGenericBootstrapTemplateCRD = &apiextensionsv1.CustomResourceDefinition{
        TypeMeta: metav1.TypeMeta{
            APIVersion: apiextensionsv1.SchemeGroupVersion.String(),
            Kind:       "CustomResourceDefinition",
        },
        ObjectMeta: metav1.ObjectMeta{
            Name: "bootstrapmachinetemplates.bootstrap.cluster.x-k8s.io",
            Labels: map[string]string{
                clusterv1.GroupVersion.String(): "v1alpha4",
            },
        },
        Spec: apiextensionsv1.CustomResourceDefinitionSpec{
            Group: "bootstrap.cluster.x-k8s.io",
            Scope: apiextensionsv1.NamespaceScoped,
            Names: apiextensionsv1.CustomResourceDefinitionNames{
                Kind:   "BootstrapMachineTemplate",
                Plural: "bootstrapmachinetemplates",
            },
            Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
                {
                    Name:    "v1alpha4",
                    Served:  true,
                    Storage: true,
                    Subresources: &apiextensionsv1.CustomResourceSubresources{
                        Status: &apiextensionsv1.CustomResourceSubresourceStatus{},
                    },
                    Schema: &apiextensionsv1.CustomResourceValidation{
                        OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
                            Type: "object",
                            Properties: map[string]apiextensionsv1.JSONSchemaProps{
                                "spec": {
                                    Type:                   "object",
                                    XPreserveUnknownFields: pointer.BoolPtr(true),
                                },
                                "status": {
                                    Type:                   "object",
                                    XPreserveUnknownFields: pointer.BoolPtr(true),
                                },
                            },
                        },
                    },
                },
            },
        },
    }

    TestGenericInfrastructureCRD = &apiextensionsv1.CustomResourceDefinition{
        TypeMeta: metav1.TypeMeta{
            APIVersion: apiextensionsv1.SchemeGroupVersion.String(),
            Kind:       "CustomResourceDefinition",
        },
        ObjectMeta: metav1.ObjectMeta{
            Name: "infrastructuremachines.infrastructure.cluster.x-k8s.io",
            Labels: map[string]string{
                clusterv1.GroupVersion.String(): "v1alpha4",
            },
        },
        Spec: apiextensionsv1.CustomResourceDefinitionSpec{
            Group: "infrastructure.cluster.x-k8s.io",
            Scope: apiextensionsv1.NamespaceScoped,
            Names: apiextensionsv1.CustomResourceDefinitionNames{
                Kind:   "InfrastructureMachine",
                Plural: "infrastructuremachines",
            },
            Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
                {
                    Name:    "v1alpha4",
                    Served:  true,
                    Storage: true,
                    Subresources: &apiextensionsv1.CustomResourceSubresources{
                        Status: &apiextensionsv1.CustomResourceSubresourceStatus{},
                    },
                    Schema: &apiextensionsv1.CustomResourceValidation{
                        OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
                            Type: "object",
                            Properties: map[string]apiextensionsv1.JSONSchemaProps{
                                "spec": {
                                    Type:                   "object",
                                    XPreserveUnknownFields: pointer.BoolPtr(true),
                                },
                                "status": {
                                    Type:                   "object",
                                    XPreserveUnknownFields: pointer.BoolPtr(true),
                                },
                            },
                        },
                    },
                },
            },
        },
    }

    TestGenericInfrastructureTemplateCRD = &apiextensionsv1.CustomResourceDefinition{
        TypeMeta: metav1.TypeMeta{
            APIVersion: apiextensionsv1.SchemeGroupVersion.String(),
            Kind:       "CustomResourceDefinition",
        },
        ObjectMeta: metav1.ObjectMeta{
            Name: "infrastructuremachinetemplates.infrastructure.cluster.x-k8s.io",
            Labels: map[string]string{
                clusterv1.GroupVersion.String(): "v1alpha4",
            },
        },
        Spec: apiextensionsv1.CustomResourceDefinitionSpec{
            Group: "infrastructure.cluster.x-k8s.io",
            Scope: apiextensionsv1.NamespaceScoped,
            Names: apiextensionsv1.CustomResourceDefinitionNames{
                Kind:   "InfrastructureMachineTemplate",
                Plural: "infrastructuremachinetemplates",
            },
            Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
                {
                    Name:    "v1alpha4",
                    Served:  true,
                    Storage: true,
                    Subresources: &apiextensionsv1.CustomResourceSubresources{
                        Status: &apiextensionsv1.CustomResourceSubresourceStatus{},
                    },
                    Schema: &apiextensionsv1.CustomResourceValidation{
                        OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
                            Type: "object",
                            Properties: map[string]apiextensionsv1.JSONSchemaProps{
                                "spec": {
                                    Type:                   "object",
                                    XPreserveUnknownFields: pointer.BoolPtr(true),
                                },
                                "status": {
                                    Type:                   "object",
                                    XPreserveUnknownFields: pointer.BoolPtr(true),
                                },
                            },
                        },
                    },
                },
            },
        },
    }
)

func CloneTemplate Uses

func CloneTemplate(ctx context.Context, in *CloneTemplateInput) (*corev1.ObjectReference, error)

CloneTemplate uses the client and the reference to create a new object from the template.

func FailuresFrom Uses

func FailuresFrom(obj *unstructured.Unstructured) (string, string, error)

FailuresFrom returns the FailureReason and FailureMessage fields from the external object status.

func GenerateTemplate Uses

func GenerateTemplate(in *GenerateTemplateInput) (*unstructured.Unstructured, error)

func Get Uses

func Get(ctx context.Context, c client.Client, ref *corev1.ObjectReference, namespace string) (*unstructured.Unstructured, error)

Get uses the client and reference to get an external, unstructured object.

func GetObjectReference Uses

func GetObjectReference(obj *unstructured.Unstructured) *corev1.ObjectReference

GetObjectReference converts an unstructured into object reference.

func IsInitialized Uses

func IsInitialized(obj *unstructured.Unstructured) (bool, error)

IsInitialized returns true if the Status.Initialized field on an external object is true.

func IsReady Uses

func IsReady(obj *unstructured.Unstructured) (bool, error)

IsReady returns true if the Status.Ready field on an external object is true.

type CloneTemplateInput Uses

type CloneTemplateInput struct {
    // Client is the controller runtime client.
    // +required
    Client client.Client

    // TemplateRef is a reference to the template that needs to be cloned.
    // +required
    TemplateRef *corev1.ObjectReference

    // Namespace is the Kubernetes namespace the cloned object should be created into.
    // +required
    Namespace string

    // ClusterName is the cluster this object is linked to.
    // +required
    ClusterName string

    // OwnerRef is an optional OwnerReference to attach to the cloned object.
    // +optional
    OwnerRef *metav1.OwnerReference

    // Labels is an optional map of labels to be added to the object.
    // +optional
    Labels map[string]string
}

type GenerateTemplateInput Uses

type GenerateTemplateInput struct {
    // Template is the TemplateRef turned into an unstructured.
    // +required
    Template *unstructured.Unstructured

    // TemplateRef is a reference to the template that needs to be cloned.
    // +required
    TemplateRef *corev1.ObjectReference

    // Namespace is the Kubernetes namespace the cloned object should be created into.
    // +required
    Namespace string

    // ClusterName is the cluster this object is linked to.
    // +required
    ClusterName string

    // OwnerRef is an optional OwnerReference to attach to the cloned object.
    // +optional
    OwnerRef *metav1.OwnerReference

    // Labels is an optional map of labels to be added to the object.
    // +optional
    Labels map[string]string
}

GenerateTemplate input is everything needed to generate a new template.

type ObjectTracker Uses

type ObjectTracker struct {
    Controller controller.Controller
    // contains filtered or unexported fields
}

ObjectTracker is a helper struct to deal when watching external unstructured objects.

func (*ObjectTracker) Watch Uses

func (o *ObjectTracker) Watch(log logr.Logger, obj runtime.Object, handler handler.EventHandler) error

Watch uses the controller to issue a Watch only if the object hasn't been seen before.

type ReconcileOutput Uses

type ReconcileOutput struct {
    // RequeueAfter if greater than 0, tells the Controller to requeue the reconcile key after the Duration.
    // Implies that Requeue is true, there is no need to set Requeue to true at the same time as RequeueAfter.
    //
    // TODO(vincepri): Remove this field here and try to return a better struct that embeds ctrl.Result,
    // we can't do that today because the field would conflict with the current `Result` field,
    // which should probably be renamed to `Object` or something similar.
    RequeueAfter time.Duration
    // Details of the referenced external object.
    // +optional
    Result *unstructured.Unstructured
    // Indicates if the external object is paused.
    // +optional
    Paused bool
}

ReconcileOutput is a return type of the external reconciliation of referenced objects

Package external imports 19 packages (graph) and is imported by 10 packages. Updated 2020-10-29. Refresh now. Tools for package owners.