kube

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultKubeConfigPath contains default path to kubernetes config
	DefaultKubeConfigPath = "/etc/kubernetes/kubeconfig.yaml"
)

Variables

View Source
var (
	Namespaced = ResourceFilterFunc(func(group string, res metav1.APIResource) bool {
		return res.Namespaced
	})

	IgnoreResourceList = []string{
		"events",
		"authcodes.dex.coreos.com",
		"offlinesessionses.dex.coreos.com",
		"authrequests.dex.coreos.com",
		"refreshtokens.dex.coreos.com",
		"passwords.dex.coreos.com",
	}

	DefaultServiceAccounts = ObjectFilterFunc(func(u *unstructured.Unstructured) bool {
		return u.GetAPIVersion() == "v1" && u.GetKind() == "ServiceAccount" && u.GetName() == "default"
	})

	ServiceAccountTokens = SecretType("kubernetes.io/service-account-token")

	HelmReleases = Any(
		SecretType("helm.sh/release.v1"),
		ObjectFilterFunc(func(u *unstructured.Unstructured) bool {
			return (strings.HasPrefix(u.GetAPIVersion(), "marketplace.criticalstack.com/") && u.GetKind() == "Release")
		}),
	)

	HasController = ObjectFilterFunc(func(u *unstructured.Unstructured) bool {
		return metav1.GetControllerOf(u) != nil
	})
)

Functions

func ListResources

func ListResources(cli client.Client, opts ListOptions) (*unstructured.UnstructuredList, error)

func LoadConfig

func LoadConfig(path string) (*rest.Config, error)

func PreferredResources

func PreferredResources(lists []*metav1.APIResourceList) []*metav1.APIResourceList

TODO(ktravis): make this a resource filter? but that would require us to run through all of the resources up front

func SplitFilter

func SplitFilter(objs []unstructured.Unstructured, ff ...ObjectFilter) (match, rest []unstructured.Unstructured)

Types

type ListOptions

type ListOptions struct {
	Resources       []*metav1.APIResourceList
	ClientOptions   *client.ListOptions
	ResourceFilters ResourceFilters
	ObjectFilters   ObjectFilters
}

type ObjectFilter

type ObjectFilter interface {
	Match(*unstructured.Unstructured) bool
}

func Any

func Any(ff ...ObjectFilter) ObjectFilter

func ControlledBy

func ControlledBy(apiVersion, kind string) ObjectFilter

func HasAnnotation

func HasAnnotation(key string) ObjectFilter

func HasAnnotationValue

func HasAnnotationValue(key, val string) ObjectFilter

func HasLabel

func HasLabel(key string) ObjectFilter

func HasLabelValue

func HasLabelValue(key, val string) ObjectFilter

func Negate

func Negate(ff ...ObjectFilter) ObjectFilter

func ObjectIsType

func ObjectIsType(apiVersion, kind string) ObjectFilter

func SecretType

func SecretType(t string) ObjectFilter

type ObjectFilterFunc

type ObjectFilterFunc func(*unstructured.Unstructured) bool

ObjectFilterFunc returns true if an item passes the filter, or false if it should be skipped

func (ObjectFilterFunc) Match

type ObjectFilters

type ObjectFilters []ObjectFilter

func (ObjectFilters) Match

type ResourceFilter

type ResourceFilter interface {
	Match(string, metav1.APIResource) bool
}

func DefaultIgnoreResources

func DefaultIgnoreResources() ResourceFilter

func Ignore

func Ignore(ignore ...string) ResourceFilter

func IgnoreGroups

func IgnoreGroups(ignore ...string) ResourceFilter

func WithVerbs

func WithVerbs(vv ...string) ResourceFilter

type ResourceFilterFunc

type ResourceFilterFunc func(string, metav1.APIResource) bool

ResourceFilterFunc returns true if a resource passes the filter, or false if it should be skipped

func (ResourceFilterFunc) Match

func (f ResourceFilterFunc) Match(group string, res metav1.APIResource) bool

type ResourceFilters

type ResourceFilters []ResourceFilter

func (ResourceFilters) Match

func (l ResourceFilters) Match(group string, res metav1.APIResource) bool

Jump to

Keyboard shortcuts

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