kor

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppLabels = map[string]string{}
View Source
var NamespacedFlagUsed bool
View Source
var ResourceKindList map[string]ResourceKind
View Source
var UnusedLabels = map[string]string{"kor/used": "false"}
View Source
var UsedLabels = map[string]string{"kor/used": "true"}

Functions

func CalculateResourceDifference added in v0.1.9

func CalculateResourceDifference(usedResourceNames []string, allResourceNames []string) []string

TODO create formatter by resource "#", "Resource Name", "Namespace" TODO Functions that use this object are accompanied by repeated data acquisition operations and can be optimized.

func CheckFinalizers added in v0.3.3

func CheckFinalizers(finalizers []string, deletionTimestamp *metav1.Time) bool

func CreateEphemeralVolumeDefinition added in v0.5.9

func CreateEphemeralVolumeDefinition(name, size string) *corev1.Volume

func CreatePersistentVolumeClaimVolumeSource added in v0.2.3

func CreatePersistentVolumeClaimVolumeSource(name string) *corev1.PersistentVolumeClaimVolumeSource

func CreateTestCSIDriver added in v0.6.0

func CreateTestCSIDriver(name string) *storagev1.CSIDriver

func CreateTestClusterRole added in v0.3.5

func CreateTestClusterRole(name string, labels map[string]string, matchLabels ...v1.LabelSelector) *rbacv1.ClusterRole

func CreateTestClusterRoleBinding added in v0.2.3

func CreateTestClusterRoleBinding(namespace, name, serviceAccountName string) *rbacv1.ClusterRoleBinding

func CreateTestClusterRoleBindingRoleRef added in v0.3.5

func CreateTestClusterRoleBindingRoleRef(namespace, name, serviceAccountName string, roleRefName *rbacv1.RoleRef) *rbacv1.ClusterRoleBinding

func CreateTestConfigmap added in v0.2.3

func CreateTestConfigmap(namespace, name string, labels map[string]string) *corev1.ConfigMap

func CreateTestDaemonSet added in v0.3.5

func CreateTestDaemonSet(namespace, name string, labels map[string]string, status *appsv1.DaemonSetStatus) *appsv1.DaemonSet

func CreateTestDeployment added in v0.2.3

func CreateTestDeployment(namespace, name string, replicas int32, labels map[string]string) *appsv1.Deployment

func CreateTestEndpoint added in v0.2.3

func CreateTestEndpoint(namespace, name string, endpointCount int, labels map[string]string) *discoveryv1.EndpointSlice

func CreateTestHpa added in v0.2.3

func CreateTestHpa(namespace, name, deploymentName string, minReplicas, maxReplicas int32, labels map[string]string) *autoscalingv2.HorizontalPodAutoscaler

func CreateTestIngress added in v0.2.3

func CreateTestIngress(namespace, name, ServiceName, secretName string, labels map[string]string) *networkingv1.Ingress

func CreateTestJob added in v0.3.2

func CreateTestJob(namespace, name string, status *batchv1.JobStatus, labels map[string]string) *batchv1.Job

func CreateTestNetworkPolicy added in v0.5.0

func CreateTestNetworkPolicy(name, namespace string, labels map[string]string, podSelector v1.LabelSelector, ingress []networkingv1.NetworkPolicyIngressRule, egress []networkingv1.NetworkPolicyEgressRule) *networkingv1.NetworkPolicy

func CreateTestNode added in v0.6.0

func CreateTestNode(name string) *corev1.Node

func CreateTestPdb added in v0.2.3

func CreateTestPdb(namespace, name string, matchLabels, pdbLabels map[string]string) *policyv1.PodDisruptionBudget

func CreateTestPod added in v0.2.3

func CreateTestPod(namespace, name, serviceAccountName string, volumes []corev1.Volume, labels map[string]string) *corev1.Pod

func CreateTestPv added in v0.3.1

func CreateTestPv(name, phase string, labels map[string]string, storageClass string) *corev1.PersistentVolume

func CreateTestPvc added in v0.2.3

func CreateTestPvc(namespace, name string, labels map[string]string, storageClass string) *corev1.PersistentVolumeClaim

func CreateTestRbacSubject added in v0.2.3

func CreateTestRbacSubject(namespace, serviceAccountName string) *rbacv1.Subject

func CreateTestReplicaSet added in v0.3.3

func CreateTestReplicaSet(namespace, name string, specReplicas *int32, status *appsv1.ReplicaSetStatus) *appsv1.ReplicaSet

func CreateTestRole added in v0.2.3

func CreateTestRole(namespace, name string, labels map[string]string) *rbacv1.Role

func CreateTestRoleBinding added in v0.2.3

func CreateTestRoleBinding(namespace, name, serviceAccountName string, roleRefName *rbacv1.RoleRef) *rbacv1.RoleBinding

func CreateTestRoleRef added in v0.2.3

func CreateTestRoleRef(roleName string) *rbacv1.RoleRef

func CreateTestRoleRefForClusterRole added in v0.3.5

func CreateTestRoleRefForClusterRole(roleName string) *rbacv1.RoleRef

func CreateTestSecret added in v0.2.3

func CreateTestSecret(namespace, name string, labels map[string]string) *corev1.Secret

func CreateTestService added in v0.2.3

func CreateTestService(namespace, name string) *corev1.Service

func CreateTestServiceAccount added in v0.2.3

func CreateTestServiceAccount(namespace, name string, labels map[string]string) *corev1.ServiceAccount

func CreateTestStatefulSet added in v0.2.3

func CreateTestStatefulSet(namespace, name string, replicas int32, labels map[string]string) *appsv1.StatefulSet

func CreateTestStorageClass added in v0.3.7

func CreateTestStorageClass(name, provisioner string) *storagev1.StorageClass

func CreateTestUnstructered added in v0.3.6

func CreateTestUnstructered(kind, apiVersion, namespace, name string) *unstructured.Unstructured

func CreateTestVolume added in v0.2.3

func CreateTestVolume(name, pvcName string) *corev1.Volume

func CreateTestVolumeAttachment added in v0.6.0

func CreateTestVolumeAttachment(name, attacher, nodeName, pvName string) *storagev1.VolumeAttachment

func DeleteResourceCmd added in v0.2.7

func DeleteResourceCmd() map[string]func(clientset kubernetes.Interface, namespace, name string) error

func Exporter added in v0.2.4

func Exporter(filterOptions *filters.Options, clientset kubernetes.Interface, apiExtClient apiextensionsclientset.Interface, dynamicClient dynamic.Interface, outputFormat string, opts common.Opts, resourceList []string)

TODO: add option to change port / url !?

func FlagDynamicResource added in v0.3.3

func FlagDynamicResource(dynamicClient dynamic.Interface, namespace string, gvr schema.GroupVersionResource, resourceName string) error

func FlagResource added in v0.3.0

func FlagResource(clientset kubernetes.Interface, namespace, resourceType, resourceName string) error

func FormatOutput

func FormatOutput(resources map[string]map[string][]ResourceInfo, opts common.Opts) bytes.Buffer

func FormatOutputAll

func FormatOutputAll(namespace string, allDiffs []ResourceDiff, opts common.Opts) string

func GetAPIExtensionsClient added in v0.2.8

func GetAPIExtensionsClient(kubeconfig string) *apiextensionsclientset.Clientset

func GetConfig added in v0.2.8

func GetConfig(kubeconfig string) (*rest.Config, error)

func GetDynamicClient added in v0.2.8

func GetDynamicClient(kubeconfig string) *dynamic.DynamicClient

func GetKubeClient

func GetKubeClient(kubeconfig string) *kubernetes.Clientset

func GetKubeConfigPath

func GetKubeConfigPath() string

func GetResourceKinds added in v0.6.2

func GetResourceKinds(clientset kubernetes.Interface) (map[string]ResourceKind, error)

func GetUnusedAll

func GetUnusedAll(filterOpts *filters.Options, clientset kubernetes.Interface, apiExtClient apiextensionsclientset.Interface, dynamicClient dynamic.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedAllNamespaced added in v0.3.7

func GetUnusedAllNamespaced(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedAllNonNamespaced added in v0.3.7

func GetUnusedAllNonNamespaced(filterOpts *filters.Options, clientset kubernetes.Interface, apiExtClient apiextensionsclientset.Interface, dynamicClient dynamic.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedClusterRoles added in v0.3.5

func GetUnusedClusterRoles(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedConfigmaps

func GetUnusedConfigmaps(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedCrds added in v0.2.8

func GetUnusedCrds(_ *filters.Options, apiExtClient apiextensionsclientset.Interface, dynamicClient dynamic.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedDaemonSets added in v0.3.5

func GetUnusedDaemonSets(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedDeployments added in v0.1.8

func GetUnusedDeployments(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedHpas added in v0.1.8

func GetUnusedHpas(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedIngresses added in v0.1.9

func GetUnusedIngresses(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedJobs added in v0.3.2

func GetUnusedJobs(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedMulti added in v0.2.1

func GetUnusedMulti(resourceNames string, filterOpts *filters.Options, clientset kubernetes.Interface, apiExtClient apiextensionsclientset.Interface, dynamicClient dynamic.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedNetworkPolicies added in v0.5.0

func GetUnusedNetworkPolicies(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedPdbs added in v0.2.0

func GetUnusedPdbs(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedPods added in v0.3.2

func GetUnusedPods(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedPvcs added in v0.1.9

func GetUnusedPvcs(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedPvs added in v0.3.1

func GetUnusedPvs(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedReplicaSets added in v0.3.3

func GetUnusedReplicaSets(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedRoleBindings added in v0.5.6

func GetUnusedRoleBindings(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedRoles added in v0.1.8

func GetUnusedRoles(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedSecrets

func GetUnusedSecrets(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedServiceAccounts

func GetUnusedServiceAccounts(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedServices

func GetUnusedServices(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedStatefulSets added in v0.2.3

func GetUnusedStatefulSets(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedStorageClasses added in v0.3.7

func GetUnusedStorageClasses(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedVolumeAttachments added in v0.6.0

func GetUnusedVolumeAttachments(filterOpts *filters.Options, clientset kubernetes.Interface, outputFormat string, opts common.Opts) (string, error)

func GetUnusedfinalizers added in v0.3.3

func GetUnusedfinalizers(filterOpts *filters.Options, clientset kubernetes.Interface, dynamicClient *dynamic.DynamicClient, outputFormat string, opts common.Opts) (string, error)

func RemoveDuplicatesAndSort

func RemoveDuplicatesAndSort(slice []string) []string

func SetNamespacedFlagState added in v0.6.0

func SetNamespacedFlagState(isFlagUsed bool)

Types

type Config added in v0.4.0

type Config struct {
	ExceptionClusterRoles    []ExceptionResource `json:"exceptionClusterRoles"`
	ExceptionConfigMaps      []ExceptionResource `json:"exceptionConfigMaps"`
	ExceptionCrds            []ExceptionResource `json:"exceptionCrds"`
	ExceptionDaemonSets      []ExceptionResource `json:"exceptionDaemonSets"`
	ExceptionRoles           []ExceptionResource `json:"exceptionRoles"`
	ExceptionSecrets         []ExceptionResource `json:"exceptionSecrets"`
	ExceptionServiceAccounts []ExceptionResource `json:"exceptionServiceAccounts"`
	ExceptionServices        []ExceptionResource `json:"exceptionServices"`
	ExceptionStorageClasses  []ExceptionResource `json:"exceptionStorageClasses"`
	ExceptionJobs            []ExceptionResource `json:"exceptionJobs"`
	ExceptionPdbs            []ExceptionResource `json:"exceptionPdbs"`
	ExceptionRoleBindings    []ExceptionResource `json:"exceptionRoleBindings"`
}

type ExceptionResource

type ExceptionResource struct {
	Namespace    string
	ResourceName string
	MatchRegex   bool
}

type GetUnusedResourceJSONResponse added in v0.1.8

type GetUnusedResourceJSONResponse struct {
	ResourceType string              `json:"resourceType"`
	Namespaces   map[string][]string `json:"namespaces"`
}

type IncludeExcludeLists added in v0.2.0

type IncludeExcludeLists struct {
	IncludeListStr string
	ExcludeListStr string
}

type ResourceDiff

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

type ResourceInfo added in v0.5.0

type ResourceInfo struct {
	Name   string `json:"name"`
	Reason string `json:"reason,omitempty"`
}

func DeleteResource added in v0.2.7

func DeleteResource(diff []ResourceInfo, clientset kubernetes.Interface, namespace, resourceType string, noInteractive bool) ([]ResourceInfo, error)

func DeleteResourceWithFinalizer added in v0.3.3

func DeleteResourceWithFinalizer(resources []ResourceInfo, dynamicClient dynamic.Interface, namespace string, gvr schema.GroupVersionResource, noInteractive bool) ([]ResourceInfo, error)

type ResourceKind added in v0.6.2

type ResourceKind struct {
	Plural     string
	ShortNames []string
}

Jump to

Keyboard shortcuts

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