kube

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KindOrder []string = []string{
	"Namespace",
	"NetworkPolicy",
	"ResourceQuota",
	"LimitRange",
	"PodSecurityPolicy",
	"PodDisruptionBudget",
	"Secret",
	"ConfigMap",
	"ConfigMapList",
	"StorageClass",
	"PersistentVolume",
	"PersistentVolumeClaim",
	"ServiceAccount",
	"CustomResourceDefinition",
	"ClusterRole",
	"ClusterRoleList",
	"ClusterRoleBinding",
	"ClusterRoleBindingList",
	"Role",
	"RoleList",
	"RoleBinding",
	"RoleBindingList",
	"Service",
	"DaemonSet",
	"Pod",
	"ReplicationController",
	"ReplicaSet",
	"Deployment",
	"HorizontalPodAutoscaler",
	"StatefulSet",
	"Job",
	"CronJob",
	"Ingress",
	"APIService",
}

KindOrder specifies the order in which Kubernetes resource types should be applied. Adapted from the list in https://github.com/helm/helm/blob/master/pkg/releaseutil/kind_sorter.go.

View Source
var KindithoutMetadata []string = []string{
	"ConfigMapList",
	"RoleBindingList",
	"RoleList",
}

KindithoutMetadata lists out Kubernetes manifest types that don't have metadata.

Functions

func SortManifests

func SortManifests(manifests []Manifest)

SortManifests sorts the provided manifest slice using the KindOrder above. Ties within the same type are broken by (namespace, name).

Types

type Manifest

type Manifest struct {
	Path     string
	Head     SimpleHeader
	Contents string
	Hash     string
	ID       string
}

Manifest is a wrapper around a Kubernetes resource manifest on local disk.

func GetManifests

func GetManifests(paths []string) ([]Manifest, error)

GetManifests recursively parses all of the manifests in the argument path.

type OrderedClient

type OrderedClient struct {
	// contains filtered or unexported fields
}

OrderedClient is a kubectl-wrapped client that tries to be clever about the order in which resources are created or destroyed.

func NewOrderedClient

func NewOrderedClient(
	kubeConfigPath string,
	keepConfigs bool,
	extraEnv []string,
	debug bool,
	serverSide bool,
) *OrderedClient

NewOrderedClient returns a new OrderedClient instance.

func (*OrderedClient) Apply

func (k *OrderedClient) Apply(
	ctx context.Context,
	applyPaths []string,
	output bool,
	format string,
	dryRun bool,
) ([]byte, error)

Apply runs kubectl apply on the manifests in the argument path. The apply is done in the optimal order based on resource type.

func (*OrderedClient) Delete

func (k *OrderedClient) Delete(
	ctx context.Context,
	ids []string,
) ([]byte, error)

Delete runs kubectl delete for the configs at the argument path for manifests that match the provided ids.

func (*OrderedClient) Diff

func (k *OrderedClient) Diff(
	ctx context.Context,
	configPaths []string,
	structured bool,
) ([]byte, error)

Diff runs kubectl diff for the configs at the argument path.

type SimpleHeader

type SimpleHeader struct {
	Version  string `json:"apiVersion"`
	Kind     string `json:"kind,omitempty"`
	Metadata *struct {
		Name        string            `json:"name"`
		Namespace   string            `json:"namespace"`
		Annotations map[string]string `json:"annotations"`
	} `json:"metadata,omitempty"`
}

SimpleHeader is a simplified header used to getting basic metadata from Kubernetes YAML files. Adapted from same struct in Helm repo.

Jump to

Keyboard shortcuts

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