Documentation ¶
Overview ¶
Package utils contains utilities common to all units of the Operator
The package includes:
- Common utilities
- Common test utilities, like constructors for test doubles etc
Index ¶
- Constants
- Variables
- func AddCommandToChannel(ctx context.Context, config config.IConfig, cmd *apis.Command, ...) error
- func ExtractContainersToImageIDsFromPod(pod *core1.Pod) map[string]string
- func ExtractImageID(imageID string) string
- func GetApplicationProfileForRelevancyScan(ctx context.Context, storageClient kssc.Interface, slug, namespace string) *v1beta1.ApplicationProfile
- func GetApplicationProfileScanCommand(appProfile *v1beta1.ApplicationProfile) *apis.Command
- func GetRequestHeaders(accessKey string) map[string]string
- func InitHttpClient(url string) httputils.IHttpClient
- func MapToString(m map[string]interface{}) []string
- func NewJobTracking(reporter systemreports.IReporter) *apis.JobTracking
- func NewK8sInterfaceFake(k8sClient k8s.Interface) *k8sinterface.KubernetesApi
- func SkipApplicationProfile(annotations map[string]string) (bool, error)
- type ClientMock
- type ContainerData
- type CredStruct
- type Job
- type SessionObj
Constants ¶
const ArgdContainerToImageIds = "containerToImageIDs"
const ArgsContainerData = "containerData"
const ArgsName = "name"
const ArgsNamespace = "namespace"
const ArgsPod = "pod"
const CommandScanApplicationProfile = "scanApplicationProfile"
const KubescapeRequestPathV1 = "v1/scan"
const KubescapeRequestStatusV1 = "v1/status"
const KubescapeScanV1 = "scanV1"
Variables ¶
var (
ReporterHttpClient httputils.IHttpClient
)
Functions ¶
func AddCommandToChannel ¶ added in v0.1.21
func ExtractContainersToImageIDsFromPod ¶ added in v0.1.21
func ExtractImageID ¶ added in v0.1.21
func GetApplicationProfileForRelevancyScan ¶ added in v0.2.59
func GetApplicationProfileForRelevancyScan(ctx context.Context, storageClient kssc.Interface, slug, namespace string) *v1beta1.ApplicationProfile
GetApplicationProfileForRelevancyScan retrieves an application profile from the storage client based on the provided slug and namespace If the application profile is found, and it should not be skipped (i.e. correct status, InstanceID and WLID annotations), it is returned, otherwise nil
func GetApplicationProfileScanCommand ¶ added in v0.2.59
func GetApplicationProfileScanCommand(appProfile *v1beta1.ApplicationProfile) *apis.Command
func GetRequestHeaders ¶ added in v0.1.70
func InitHttpClient ¶ added in v0.1.70
func InitHttpClient(url string) httputils.IHttpClient
func MapToString ¶
func NewJobTracking ¶
func NewJobTracking(reporter systemreports.IReporter) *apis.JobTracking
func NewK8sInterfaceFake ¶ added in v0.1.21
func NewK8sInterfaceFake(k8sClient k8s.Interface) *k8sinterface.KubernetesApi
NewK8sInterfaceFake returns a new K8sInterface with a fake Kubernetes Client attached
This function is a Dependency Injection-friendly version for the `KubernetesApi` constructor that allows to inject any Kubernetes Clients. For example, the official fake Kubernetes client, so unit tests would have a suitable test double instead of trying to talk to a real cluster
Types ¶
type ClientMock ¶
type ClientMock struct { }
type ContainerData ¶ added in v0.2.4
type ContainerData struct { ImageTag string // imageTag (from container.Image) ImageID string // imageID (from containerStatus.ImageID) InstanceID string // instanceID.GetStringFormatted() ContainerName string // containerName ContainerType string // containerType (init or regular) Slug string // represent the unique identifier of the container Wlid string // workloadID }
func PodToContainerData ¶ added in v0.2.4
func PodToContainerData(k8sAPI *k8sinterface.KubernetesApi, pod *core1.Pod, instanceID instanceidhandler.IInstanceID, clusterName string) (*ContainerData, error)
type CredStruct ¶
type CredStruct struct { User string `json:"user"` Password string `json:"password"` Customer string `json:"customer"` }
CredStruct holds the various credentials needed to do login into CA BE
type Job ¶ added in v0.1.39
type Job struct {
// contains filtered or unexported fields
}
func (*Job) Obj ¶ added in v0.1.39
func (j *Job) Obj() SessionObj
func (*Job) SetContext ¶ added in v0.1.39
func (*Job) SetObj ¶ added in v0.1.39
func (j *Job) SetObj(sessionObj SessionObj)
type SessionObj ¶
type SessionObj struct { Command apis.Command `json:"command"` Reporter beClientV1.IReportSender `json:"reporter"` }
Commands list of commands received from websocket