Documentation ¶
Index ¶
- func GetKubeClient(ctx context.Context, kubeContext string) (dynamic.Interface, meta.RESTMapper, kubernetes.Interface, string, error)
- func GetPodSpec(yaml map[string]interface{}) interface{}
- func GetPodTemplate(yaml map[string]interface{}) (podTemplate interface{}, err error)
- func SerializeContainer(container *corev1.Container) (map[string]interface{}, error)
- func SerializePod(pod *corev1.Pod) (map[string]interface{}, error)
- func SerializePodSpec(pod *corev1.PodSpec) (map[string]interface{}, error)
- type GenericResource
- func NewGenericResourceFromBytes(contentBytes []byte) (GenericResource, error)
- func NewGenericResourceFromPod(podResource kubeAPICoreV1.Pod, originalObject interface{}) (GenericResource, error)
- func NewGenericResourceFromUnstructured(unst unstructured.Unstructured, podSpecMap interface{}) (GenericResource, error)
- func ResolveControllerFromPod(ctx context.Context, podResource kubeAPICoreV1.Pod, ...) (GenericResource, error)
- type ResourceProvider
- func CreateResourceProvider(ctx context.Context, directory, workload string, c conf.Configuration) (*ResourceProvider, error)
- func CreateResourceProviderFromAPI(ctx context.Context, kube kubernetes.Interface, clusterName string, ...) (*ResourceProvider, error)
- func CreateResourceProviderFromCluster(ctx context.Context, c conf.Configuration) (*ResourceProvider, error)
- func CreateResourceProviderFromPath(directory string) (*ResourceProvider, error)
- func CreateResourceProviderFromResource(ctx context.Context, workload string) (*ResourceProvider, error)
- func CreateResourceProviderFromYaml(yamlContent string) (*ResourceProvider, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetKubeClient ¶
func GetPodSpec ¶
func GetPodSpec(yaml map[string]interface{}) interface{}
GetPodSpec looks inside arbitrary YAML for a PodSpec
func GetPodTemplate ¶
GetPodTemplate looks inside arbitrary YAML for a Pod template, containing fields `spec.containers`. For example, it returns the `spec.template` level of a Kubernetes Deployment yaml.
func SerializeContainer ¶
SerializeContainer converts a typed Container into a map[string]interface{}
func SerializePod ¶
SerializePod converts a typed Pod into a map[string]interface{}
Types ¶
type GenericResource ¶
type GenericResource struct { Kind string ObjectMeta kubeAPIMetaV1.Object Resource unstructured.Unstructured PodSpec *kubeAPICoreV1.PodSpec PodTemplate interface{} OriginalObjectJSON []byte OriginalObjectYAML []byte }
GenericResource is a base implementation with some free methods for inherited structs
func NewGenericResourceFromBytes ¶
func NewGenericResourceFromBytes(contentBytes []byte) (GenericResource, error)
NewGenericResourceFromBytes parses a generic kubernetes resource
func NewGenericResourceFromPod ¶
func NewGenericResourceFromPod(podResource kubeAPICoreV1.Pod, originalObject interface{}) (GenericResource, error)
NewGenericResourceFromPod builds a new workload for a given Pod without looking at parents
func NewGenericResourceFromUnstructured ¶
func NewGenericResourceFromUnstructured(unst unstructured.Unstructured, podSpecMap interface{}) (GenericResource, error)
NewGenericResourceFromUnstructured creates a workload from an unstructured.Unstructured
func ResolveControllerFromPod ¶
func ResolveControllerFromPod(ctx context.Context, podResource kubeAPICoreV1.Pod, dynamicClient dynamic.Interface, restMapper meta.RESTMapper, objectCache map[string]unstructured.Unstructured) (GenericResource, error)
ResolveControllerFromPod builds a new workload for a given Pod
type ResourceProvider ¶
type ResourceProvider struct { ServerVersion string CreationTime time.Time SourceName string SourceType string Nodes []corev1.Node Namespaces []corev1.Namespace Resources resourceKindMap }
ResourceProvider contains k8s resources to be audited
func CreateResourceProvider ¶
func CreateResourceProvider(ctx context.Context, directory, workload string, c conf.Configuration) (*ResourceProvider, error)
CreateResourceProvider returns a new ResourceProvider object to interact with k8s resources
func CreateResourceProviderFromAPI ¶
func CreateResourceProviderFromAPI(ctx context.Context, kube kubernetes.Interface, clusterName string, dynamic dynamic.Interface, c conf.Configuration) (*ResourceProvider, error)
CreateResourceProviderFromAPI creates a new ResourceProvider from an existing k8s interface
func CreateResourceProviderFromCluster ¶
func CreateResourceProviderFromCluster(ctx context.Context, c conf.Configuration) (*ResourceProvider, error)
CreateResourceProviderFromCluster creates a new ResourceProvider using live data from a cluster
func CreateResourceProviderFromPath ¶
func CreateResourceProviderFromPath(directory string) (*ResourceProvider, error)
CreateResourceProviderFromPath returns a new ResourceProvider using the YAML files in a directory
func CreateResourceProviderFromResource ¶
func CreateResourceProviderFromResource(ctx context.Context, workload string) (*ResourceProvider, error)
CreateResourceProviderFromResource creates a new ResourceProvider that just contains one workload
func CreateResourceProviderFromYaml ¶
func CreateResourceProviderFromYaml(yamlContent string) (*ResourceProvider, error)
CreateResourceProviderFromYaml returns a new ResourceProvider using the yaml