Documentation ¶
Index ¶
- Constants
- Variables
- func CheckIsACRImage(imageTag string) bool
- func CheckIsECRImage(imageTag string) bool
- func CheckIsGCRImage(imageTag string) bool
- func ConvertUnstructuredSliceToMap(unstructuredSlice []unstructured.Unstructured) []map[string]interface{}
- func FilterOutOwneredResources(result []unstructured.Unstructured) []unstructured.Unstructured
- func GetCloudVendorRegistryCredentials(imageTag string) (map[string]types.AuthConfig, error)
- func GetGroupVersionResource(resource string) (schema.GroupVersionResource, error)
- func GetK8sConfig() *restclient.Config
- func GetLoginDetailsForAzurCR(imageTag string) (string, string, error)
- func GetLoginDetailsForECR(imageTag string) (string, string, error)
- func GetLoginDetailsForGCR(imageTag string) (string, string, error)
- func GetResourceTriplets(group, version, resource string) []string
- func InspectWorkload(workload interface{}, scopes ...string) (val interface{}, k bool)
- func IsAgentCompatibleAnnotation(annotations map[string]string) *bool
- func IsAgentCompatibleLabel(labels map[string]string) *bool
- func IsAttached(labels map[string]string) *bool
- func IsLabel(labels map[string]string, key string) *bool
- func IsNamespaceScope(apiGroup, resource string) bool
- func IsStringInSlice(slice []string, val string) bool
- func JoinResourceTriplets(group, version, resource string) string
- func LoadK8sConfig() error
- func PodMetadata(kind string) []string
- func PodSpec(kind string) []string
- func ResourceGroupToString(group, version, resource string) []string
- func SelectorToString(ls labels.Set) string
- func SetAgentCompatibleAnnotation(annotations map[string]string, val bool)
- func SetAgentCompatibleLabel(labels map[string]string, val bool)
- func SetLabel(labels map[string]string, key string, val bool)
- func StringInSlice(strSlice []string, str string) int
- func StringToResourceGroup(str string) (string, string, string)
- func V1AllClusterWithCompromisedRegistriesMock() *unstructured.UnstructuredList
- func V1KubeSystemNamespaceMock() *unstructured.UnstructuredList
- type IBasicWorkload
- type IWorkload
- type KubernetesApi
- func (k8sAPI *KubernetesApi) CalculateWorkloadParentRecursive(workload *Workload) (string, string, error)
- func (k8sAPI *KubernetesApi) CreateWorkload(workload *Workload) (*Workload, error)
- func (k8sAPI *KubernetesApi) DeleteWorkloadByWlid(wlid string) error
- func (k8sAPI *KubernetesApi) GetNamespace(ns string) (*Workload, error)
- func (k8sAPI *KubernetesApi) GetWorkload(namespace, kind, name string) (*Workload, error)
- func (k8sAPI *KubernetesApi) GetWorkloadByWlid(wlid string) (*Workload, error)
- func (k8sAPI *KubernetesApi) ListAttachedPods(namespace string) ([]corev1.Pod, error)
- func (k8sAPI *KubernetesApi) ListPods(namespace string, podLabels map[string]string) ([]corev1.Pod, error)
- func (k8sAPI *KubernetesApi) ListWorkloads(groupVersionResource *schema.GroupVersionResource, namespace string, ...) ([]Workload, error)
- func (k8sAPI *KubernetesApi) ResourceInterface(resource *schema.GroupVersionResource, namespace string) dynamic.ResourceInterface
- func (k8sAPI *KubernetesApi) UpdateWorkload(workload *Workload) (*Workload, error)
- type Workload
- func (workload *Workload) DeepCopy(w map[string]interface{})
- func (w *Workload) GetAnnotation(annotation string) (string, bool)
- func (w *Workload) GetAnnotations() map[string]string
- func (w *Workload) GetApiVersion() string
- func (w *Workload) GetContainers() ([]corev1.Container, error)
- func (w *Workload) GetGenerateName() string
- func (w *Workload) GetGroup() string
- func (w *Workload) GetImagePullSecret() ([]corev1.LocalObjectReference, error)
- func (w *Workload) GetInitContainers() ([]corev1.Container, error)
- func (w *Workload) GetInnerAnnotation(annotation string) (string, bool)
- func (w *Workload) GetInnerAnnotations() map[string]string
- func (w *Workload) GetInnerLabels() map[string]string
- func (w *Workload) GetJobID() *apis.JobTracking
- func (w *Workload) GetKind() string
- func (w *Workload) GetLabel(label string) (string, bool)
- func (w *Workload) GetLabels() map[string]string
- func (w *Workload) GetName() string
- func (w *Workload) GetNamespace() string
- func (w *Workload) GetOwnerReferences() ([]metav1.OwnerReference, error)
- func (w *Workload) GetPodAnnotation(annotation string) (string, bool)
- func (w *Workload) GetPodAnnotations() map[string]string
- func (w *Workload) GetPodLabel(label string) (string, bool)
- func (w *Workload) GetPodLabels() map[string]string
- func (w *Workload) GetPodSpec() (*corev1.PodSpec, error)
- func (w *Workload) GetReplicas() int
- func (w *Workload) GetResourceVersion() string
- func (w *Workload) GetSelector() (*metav1.LabelSelector, error)
- func (w *Workload) GetServiceAccountName() string
- func (w *Workload) GetUID() string
- func (w *Workload) GetVersion() string
- func (w *Workload) GetVolumes() ([]corev1.Volume, error)
- func (w *Workload) GetWlid() string
- func (w *Workload) GetWorkload() map[string]interface{}
- func (w *Workload) IsAttached() bool
- func (w *Workload) IsCompatible() bool
- func (w *Workload) IsIgnore() bool
- func (w *Workload) IsIncompatible() bool
- func (w *Workload) IsInject() bool
- func (w *Workload) IsReplaceheaders() bool
- func (w *Workload) Json() string
- func (w *Workload) RemoveAnnotation(key string)
- func (w *Workload) RemoveArmoAnnotations()
- func (w *Workload) RemoveArmoLabels()
- func (w *Workload) RemoveArmoMetadata()
- func (w *Workload) RemoveCompatible()
- func (w *Workload) RemoveIgnore()
- func (w *Workload) RemoveInject()
- func (w *Workload) RemoveJobID()
- func (w *Workload) RemoveLabel(key string)
- func (w *Workload) RemoveMetadata(scope []string, metadata, key string)
- func (w *Workload) RemovePodAnnotation(key string)
- func (w *Workload) RemovePodLabel(key string)
- func (w *Workload) RemovePodStatus()
- func (w *Workload) RemoveResourceVersion()
- func (w *Workload) RemoveSecretData()
- func (w *Workload) RemoveUpdateTime()
- func (w *Workload) RemoveWlid()
- func (w *Workload) SetAnnotation(key, value string)
- func (w *Workload) SetCompatible()
- func (w *Workload) SetIgnore()
- func (w *Workload) SetIncompatible()
- func (w *Workload) SetInject()
- func (w *Workload) SetJobID(jobTracking apis.JobTracking)
- func (w *Workload) SetKind(kind string)
- func (w *Workload) SetLabel(key, value string)
- func (w *Workload) SetMetadata(scope []string, key string, val interface{})
- func (w *Workload) SetName(name string)
- func (w *Workload) SetNamespace(namespace string)
- func (w *Workload) SetPodAnnotation(key, value string)
- func (w *Workload) SetPodLabel(key, value string)
- func (w *Workload) SetReplaceheaders()
- func (w *Workload) SetUpdateTime()
- func (w *Workload) SetWlid(wlid string)
- func (w *Workload) SetWorkload(workload map[string]interface{})
- func (w *Workload) ToString() string
- func (w *Workload) ToUnstructured() (*unstructured.Unstructured, error)
Constants ¶
const ValueNotFound = -1
Variables ¶
var GroupsClusterScope = []string{}
var K8SConfig *restclient.Config
K8SConfig pointer to k8s config
var ResourceClusterScope = []string{"nodes", "namespaces", "clusterroles", "clusterrolebindings"}
var ResourceGroupMapping = map[string]string{
"services": "/v1",
"pods": "/v1",
"replicationcontrollers": "/v1",
"podtemplates": "/v1",
"namespaces": "/v1",
"nodes": "/v1",
"configmaps": "/v1",
"secrets": "/v1",
"serviceaccounts": "/v1",
"persistentvolumeclaims": "/v1",
"limitranges": "/v1",
"resourcequotas": "/v1",
"daemonsets": "apps/v1",
"deployments": "apps/v1",
"replicasets": "apps/v1",
"statefulsets": "apps/v1",
"controllerrevisions": "apps/v1",
"jobs": "batch/v1",
"cronjobs": "batch/v1beta1",
"horizontalpodautoscalers": "autoscaling/v1",
"ingresses": "extensions/v1beta1",
"networkpolicies": "networking.k8s.io/v1",
"clusterroles": "rbac.authorization.k8s.io/v1",
"clusterrolebindings": "rbac.authorization.k8s.io/v1",
"roles": "rbac.authorization.k8s.io/v1",
"rolebindings": "rbac.authorization.k8s.io/v1",
"mutatingwebhookconfigurations": "admissionregistration.k8s.io/v1",
"validatingwebhookconfigurations": "admissionregistration.k8s.io/v1",
}
https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#-strong-api-groups-strong-
var RunningIncluster bool
RunningIncluster whether running in cluster
Functions ¶
func CheckIsACRImage ¶
func CheckIsECRImage ¶
CheckIsECRImage check if this image is suspected as ECR hosted image
func CheckIsGCRImage ¶
func ConvertUnstructuredSliceToMap ¶
func ConvertUnstructuredSliceToMap(unstructuredSlice []unstructured.Unstructured) []map[string]interface{}
func FilterOutOwneredResources ¶
func FilterOutOwneredResources(result []unstructured.Unstructured) []unstructured.Unstructured
func GetCloudVendorRegistryCredentials ¶
func GetCloudVendorRegistryCredentials(imageTag string) (map[string]types.AuthConfig, error)
func GetGroupVersionResource ¶
func GetGroupVersionResource(resource string) (schema.GroupVersionResource, error)
func GetK8sConfig ¶
func GetK8sConfig() *restclient.Config
GetK8sConfig get config. load if not loaded yer
func GetLoginDetailsForAzurCR ¶
GetLoginDetailsForAzurCR return user name + password to use
func GetLoginDetailsForECR ¶
GetLoginDetailsForECR return user name + password using the default iam-role OR ~/.aws/config of the machine
func GetLoginDetailsForGCR ¶
GetLoginDetailsForGCR return user name + password to use
func GetResourceTriplets ¶
func InspectWorkload ¶
InspectWorkload -
func IsAgentCompatibleLabel ¶
func IsAttached ¶
func IsNamespaceScope ¶
func IsStringInSlice ¶
func JoinResourceTriplets ¶
func LoadK8sConfig ¶
func LoadK8sConfig() error
LoadK8sConfig load config from local file or from cluster
func PodMetadata ¶
func ResourceGroupToString ¶
func SelectorToString ¶
String returns all labels listed as a human readable string. Conveniently, exactly the format that ParseSelector takes.
func SetAgentCompatibleLabel ¶
func StringInSlice ¶
func V1AllClusterWithCompromisedRegistriesMock ¶
func V1AllClusterWithCompromisedRegistriesMock() *unstructured.UnstructuredList
func V1KubeSystemNamespaceMock ¶
func V1KubeSystemNamespaceMock() *unstructured.UnstructuredList
Types ¶
type IBasicWorkload ¶
type IBasicWorkload interface { // Set SetKind(string) SetWorkload(map[string]interface{}) SetLabel(key, value string) SetAnnotation(key, value string) SetNamespace(string) SetName(string) // Get GetNamespace() string GetName() string GetGenerateName() string GetApiVersion() string GetKind() string GetInnerAnnotation(string) (string, bool) GetPodAnnotation(string) (string, bool) GetAnnotation(string) (string, bool) GetLabel(string) (string, bool) GetAnnotations() map[string]string GetInnerAnnotations() map[string]string GetPodAnnotations() map[string]string GetLabels() map[string]string GetInnerLabels() map[string]string GetPodLabels() map[string]string GetVolumes() ([]corev1.Volume, error) GetReplicas() int GetContainers() ([]corev1.Container, error) GetInitContainers() ([]corev1.Container, error) GetOwnerReferences() ([]metav1.OwnerReference, error) GetImagePullSecret() ([]corev1.LocalObjectReference, error) GetServiceAccountName() string GetSelector() (*metav1.LabelSelector, error) GetResourceVersion() string GetUID() string GetPodSpec() (*corev1.PodSpec, error) GetWorkload() map[string]interface{} // REMOVE RemoveLabel(string) RemoveAnnotation(string) RemovePodStatus() RemoveResourceVersion() }
type IWorkload ¶
type IWorkload interface { IBasicWorkload // Convert ToUnstructured() (*unstructured.Unstructured, error) ToString() string Json() string // DEPRECATED // GET GetWlid() string GetJobID() *apis.JobTracking GetVersion() string GetGroup() string // SET SetWlid(string) SetInject() SetIgnore() SetUpdateTime() SetJobID(apis.JobTracking) SetCompatible() SetIncompatible() SetReplaceheaders() // EXIST IsIgnore() bool IsInject() bool IsAttached() bool IsCompatible() bool IsIncompatible() bool // REMOVE RemoveWlid() RemoveSecretData() RemoveInject() RemoveIgnore() RemoveUpdateTime() RemoveJobID() RemoveCompatible() RemoveArmoMetadata() RemoveArmoLabels() RemoveArmoAnnotations() }
type KubernetesApi ¶
type KubernetesApi struct { KubernetesClient kubernetes.Interface DynamicClient dynamic.Interface Context context.Context }
KubernetesApi -
func (*KubernetesApi) CalculateWorkloadParentRecursive ¶
func (k8sAPI *KubernetesApi) CalculateWorkloadParentRecursive(workload *Workload) (string, string, error)
func (*KubernetesApi) CreateWorkload ¶
func (k8sAPI *KubernetesApi) CreateWorkload(workload *Workload) (*Workload, error)
func (*KubernetesApi) DeleteWorkloadByWlid ¶
func (k8sAPI *KubernetesApi) DeleteWorkloadByWlid(wlid string) error
func (*KubernetesApi) GetNamespace ¶
func (k8sAPI *KubernetesApi) GetNamespace(ns string) (*Workload, error)
func (*KubernetesApi) GetWorkload ¶
func (k8sAPI *KubernetesApi) GetWorkload(namespace, kind, name string) (*Workload, error)
func (*KubernetesApi) GetWorkloadByWlid ¶
func (k8sAPI *KubernetesApi) GetWorkloadByWlid(wlid string) (*Workload, error)
func (*KubernetesApi) ListAttachedPods ¶
func (k8sAPI *KubernetesApi) ListAttachedPods(namespace string) ([]corev1.Pod, error)
func (*KubernetesApi) ListWorkloads ¶
func (k8sAPI *KubernetesApi) ListWorkloads(groupVersionResource *schema.GroupVersionResource, namespace string, podLabels, fieldSelector map[string]string) ([]Workload, error)
func (*KubernetesApi) ResourceInterface ¶
func (k8sAPI *KubernetesApi) ResourceInterface(resource *schema.GroupVersionResource, namespace string) dynamic.ResourceInterface
func (*KubernetesApi) UpdateWorkload ¶
func (k8sAPI *KubernetesApi) UpdateWorkload(workload *Workload) (*Workload, error)
type Workload ¶
type Workload struct {
// contains filtered or unexported fields
}
func NewWorkload ¶
func NewWorkloadObj ¶
func (*Workload) GetAnnotations ¶
func (*Workload) GetApiVersion ¶
func (*Workload) GetContainers ¶
GetContainers -
func (*Workload) GetGenerateName ¶
func (*Workload) GetImagePullSecret ¶
func (w *Workload) GetImagePullSecret() ([]corev1.LocalObjectReference, error)
func (*Workload) GetInitContainers ¶
GetInitContainers -
func (*Workload) GetInnerAnnotation ¶
GetInnerAnnotation DEPRECATED
func (*Workload) GetInnerAnnotations ¶
GetInnerAnnotations - DEPRECATED
func (*Workload) GetInnerLabels ¶
GetInnerLabels - DEPRECATED
func (*Workload) GetJobID ¶
func (w *Workload) GetJobID() *apis.JobTracking
func (*Workload) GetNamespace ¶
func (*Workload) GetOwnerReferences ¶
func (w *Workload) GetOwnerReferences() ([]metav1.OwnerReference, error)
GetOwnerReferences -
func (*Workload) GetPodAnnotation ¶
func (*Workload) GetPodAnnotations ¶
GetPodAnnotations
func (*Workload) GetPodLabels ¶
func (*Workload) GetReplicas ¶
func (*Workload) GetResourceVersion ¶
func (*Workload) GetSelector ¶
func (w *Workload) GetSelector() (*metav1.LabelSelector, error)
func (*Workload) GetServiceAccountName ¶
func (*Workload) GetVersion ¶
func (*Workload) GetWorkload ¶
========================================= GET =========================================
func (*Workload) IsAttached ¶
func (*Workload) IsCompatible ¶
func (*Workload) IsIncompatible ¶
func (*Workload) IsReplaceheaders ¶
func (*Workload) RemoveAnnotation ¶
func (*Workload) RemoveArmoAnnotations ¶
func (w *Workload) RemoveArmoAnnotations()
func (*Workload) RemoveArmoLabels ¶
func (w *Workload) RemoveArmoLabels()
func (*Workload) RemoveArmoMetadata ¶
func (w *Workload) RemoveArmoMetadata()
func (*Workload) RemoveCompatible ¶
func (w *Workload) RemoveCompatible()
func (*Workload) RemoveIgnore ¶
func (w *Workload) RemoveIgnore()
func (*Workload) RemoveInject ¶
func (w *Workload) RemoveInject()
func (*Workload) RemoveJobID ¶
func (w *Workload) RemoveJobID()
func (*Workload) RemoveLabel ¶
func (*Workload) RemoveMetadata ¶
func (*Workload) RemovePodAnnotation ¶
func (*Workload) RemovePodLabel ¶
func (*Workload) RemovePodStatus ¶
func (w *Workload) RemovePodStatus()
func (*Workload) RemoveResourceVersion ¶
func (w *Workload) RemoveResourceVersion()
func (*Workload) RemoveSecretData ¶
func (w *Workload) RemoveSecretData()
func (*Workload) RemoveUpdateTime ¶
func (w *Workload) RemoveUpdateTime()
func (*Workload) RemoveWlid ¶
func (w *Workload) RemoveWlid()
func (*Workload) SetAnnotation ¶
func (*Workload) SetCompatible ¶
func (w *Workload) SetCompatible()
func (*Workload) SetIncompatible ¶
func (w *Workload) SetIncompatible()
func (*Workload) SetJobID ¶
func (w *Workload) SetJobID(jobTracking apis.JobTracking)
func (*Workload) SetMetadata ¶
func (*Workload) SetNamespace ¶
func (*Workload) SetPodAnnotation ¶
func (*Workload) SetPodLabel ¶
func (*Workload) SetReplaceheaders ¶
func (w *Workload) SetReplaceheaders()
func (*Workload) SetUpdateTime ¶
func (w *Workload) SetUpdateTime()
func (*Workload) SetWorkload ¶
func (*Workload) ToUnstructured ¶
func (w *Workload) ToUnstructured() (*unstructured.Unstructured, error)