objsort

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package objsort allows sorting of K8s objects in the order in which they should be applied to the cluster.

Index

Constants

View Source
const (
	GenericClusterObjectOrder = 30  // any cluster-level object that does not have an assigned order
	GenericNamespacedOrder    = 80  // any namespaced object that does not have an assigned order
	GenericPodOrder           = 100 // any object that results in pod creation
	GenericLast               = 120 // any object for which server metadata was not found
)

ordering for specific classes of objects

Variables

View Source
var SpecifiedOrdering = map[schema.GroupKind]int{
	schema.GroupKind{Group: "extensions", Kind: "PodSecurityPolicy"}:                                10,
	schema.GroupKind{Group: "extensions", Kind: "ThirdPartyResource"}:                               20,
	schema.GroupKind{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition"}:               20,
	schema.GroupKind{Group: "", Kind: "Namespace"}:                                                  GenericNamespacedOrder - 30,
	schema.GroupKind{Group: "", Kind: "LimitRange"}:                                                 GenericNamespacedOrder - 20,
	schema.GroupKind{Group: "", Kind: "ServiceAccount"}:                                             GenericNamespacedOrder - 20,
	schema.GroupKind{Group: "", Kind: "ConfigMap"}:                                                  GenericNamespacedOrder - 10,
	schema.GroupKind{Group: "", Kind: "Secret"}:                                                     GenericNamespacedOrder - 10,
	schema.GroupKind{Group: "extensions", Kind: "DaemonSet"}:                                        GenericPodOrder,
	schema.GroupKind{Group: "extensions", Kind: "Deployment"}:                                       GenericPodOrder,
	schema.GroupKind{Group: "extensions", Kind: "ReplicaSet"}:                                       GenericPodOrder,
	schema.GroupKind{Group: "extensions", Kind: "StatefulSet"}:                                      GenericPodOrder,
	schema.GroupKind{Group: "apps", Kind: "DaemonSet"}:                                              GenericPodOrder,
	schema.GroupKind{Group: "apps", Kind: "Deployment"}:                                             GenericPodOrder,
	schema.GroupKind{Group: "apps", Kind: "ReplicaSet"}:                                             GenericPodOrder,
	schema.GroupKind{Group: "apps", Kind: "StatefulSet"}:                                            GenericPodOrder,
	schema.GroupKind{Group: "batch", Kind: "Job"}:                                                   GenericPodOrder,
	schema.GroupKind{Group: "batch", Kind: "CronJob"}:                                               GenericPodOrder,
	schema.GroupKind{Group: "", Kind: "Service"}:                                                    GenericPodOrder + 10,
	schema.GroupKind{Group: "admissionregistration.k8s.io", Kind: "ValidatingWebhookConfiguration"}: GenericPodOrder + 20,
	schema.GroupKind{Group: "admissionregistration.k8s.io", Kind: "MutatingWebhookConfiguration"}:   GenericPodOrder + 20,
}

SpecifiedOrdering defines ordering for a set of known kubernetes objects.

Functions

func Sort

func Sort(inputs []model.K8sLocalObject, config Config) []model.K8sLocalObject

Sort sorts the supplied local objects based on the supplied configuration.

func SortMeta

func SortMeta(inputs []model.K8sQbecMeta, config Config) []model.K8sQbecMeta

SortMeta sorts the supplied meta objects based on the config.

Types

type Config

type Config struct {
	OrderingProvider    OrderingProvider // custom ordering provider
	NamespacedIndicator Namespaced       // indicator to determine if resource sis namespaced
}

Config is the sort configuration. The ordering provider may be nil if no custom ordering is required.

type Namespaced

type Namespaced func(gvk schema.GroupVersionKind) (namespaced bool, err error)

Namespaced returns true if the supplied gvk is a namespaced resource.

type OrderingProvider

type OrderingProvider func(item model.K8sQbecMeta) int

OrderingProvider provides a positive order for the supplied item if it wants to influence its apply order or 0 if it does not care.

Jump to

Keyboard shortcuts

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