Documentation ¶
Index ¶
- Constants
- Variables
- func FilterObjects(objs []unstructured.Unstructured, ff ...ObjectFilter) []unstructured.Unstructured
- func ListResources(cli client.Client, opts ListOptions) (*unstructured.UnstructuredList, error)
- func LoadConfig(path string) (*rest.Config, error)
- func PreferredResources(lists []*metav1.APIResourceList) []*metav1.APIResourceList
- func SplitFilter(objs []unstructured.Unstructured, ff ...ObjectFilter) (match, rest []unstructured.Unstructured)
- type ListOptions
- type ObjectFilter
- func Any(ff ...ObjectFilter) ObjectFilter
- func ControlledBy(apiVersion, kind string) ObjectFilter
- func HasAnnotation(key string) ObjectFilter
- func HasAnnotationValue(key, val string) ObjectFilter
- func HasLabel(key string) ObjectFilter
- func HasLabelValue(key, val string) ObjectFilter
- func Negate(ff ...ObjectFilter) ObjectFilter
- func ObjectIsType(apiVersion, kind string) ObjectFilter
- func SecretType(t string) ObjectFilter
- type ObjectFilterFunc
- type ObjectFilters
- type ResourceFilter
- type ResourceFilterFunc
- type ResourceFilters
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 FilterObjects ¶
func FilterObjects(objs []unstructured.Unstructured, ff ...ObjectFilter) []unstructured.Unstructured
func ListResources ¶
func ListResources(cli client.Client, opts ListOptions) (*unstructured.UnstructuredList, 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 ¶
func (f ObjectFilterFunc) Match(u *unstructured.Unstructured) bool
type ObjectFilters ¶
type ObjectFilters []ObjectFilter
func (ObjectFilters) Match ¶
func (l ObjectFilters) Match(u *unstructured.Unstructured) bool
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
Click to show internal directories.
Click to hide internal directories.