util

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

https://raw.githubusercontent.com/Azure/secrets-store-csi-driver-provider-azure/master/test/e2e/framework/exec/kubectl.go

Index

Constants

View Source
const (
	KindClusterName  = "eraser-e2e-test"
	ProviderResource = "eraser.yaml"

	Alpine        = "alpine"
	Nginx         = "nginx"
	NginxLatest   = "ghcr.io/eraser-dev/eraser/e2e-test/nginx:latest"
	NginxAliasOne = "ghcr.io/eraser-dev/eraser/e2e-test/nginx:one"
	NginxAliasTwo = "ghcr.io/eraser-dev/eraser/e2e-test/nginx:two"
	Redis         = "redis"
	Caddy         = "caddy"

	ImageCollectorShared = "imagecollector-shared"
	Prune                = "imagelist"
	ImagePullSecret      = "testsecret"
	FilterNodeName       = "eraser-e2e-test-worker"
	FilterNodeSelector   = "kubernetes.io/hostname=eraser-e2e-test-worker"
	FilterLabelKey       = "eraser.sh/cleanup.filter"
	FilterLabelValue     = "true"
)
View Source
const (
	CollectorEnable    = HelmPath("runtimeConfig.components.collector.enabled")
	CollectorImageRepo = HelmPath("runtimeConfig.components.collector.image.repo")
	CollectorImageTag  = HelmPath("runtimeConfig.components.collector.image.tag")

	ScannerConfig    = HelmPath("runtimeConfig.components.scanner.config")
	ScannerEnable    = HelmPath("runtimeConfig.components.scanner.enabled")
	ScannerImageRepo = HelmPath("runtimeConfig.components.scanner.image.repo")
	ScannerImageTag  = HelmPath("runtimeConfig.components.scanner.image.tag")

	RemoverImageRepo = HelmPath("runtimeConfig.components.remover.image.repo")
	RemoverImageTag  = HelmPath("runtimeConfig.components.remover.image.tag")

	ManagerImageRepo = HelmPath("deploy.image.repo")
	ManagerImageTag  = HelmPath("deploy.image.tag")

	ImagePullSecrets = HelmPath("runtimeConfig.manager.pullSecrets")
	OTLPEndpoint     = HelmPath("runtimeConfig.manager.otlpEndpoint")

	CleanupOnSuccessDelay = HelmPath("runtimeConfig.manager.imageJob.cleanup.delayOnSuccess")
	FilterNodesType       = HelmPath("runtimeConfig.manager.nodeFilter.type")
	ScheduleImmediate     = HelmPath("runtimeConfig.manager.scheduling.beginImmediately")

	CustomRuntimeAddress = HelmPath("runtimeConfig.manager.runtime.address")
	CustomRuntimeName    = HelmPath("runtimeConfig.manager.runtime.name")

	CollectorLabel       = "collector"
	ManualLabel          = "manual"
	ImageJobTypeLabelKey = "eraser.sh/type"
	ManagerLabelKey      = "control-plane"
	ManagerLabelValue    = "controller-manager"
)

Variables

View Source
var (
	Testenv             env.Environment
	RemoverImage        = os.Getenv("REMOVER_IMAGE")
	ManagerImage        = os.Getenv("MANAGER_IMAGE")
	CollectorImage      = os.Getenv("COLLECTOR_IMAGE")
	ScannerImage        = os.Getenv("SCANNER_IMAGE")
	VulnerableImage     = os.Getenv("VULNERABLE_IMAGE")
	NonVulnerableImage  = os.Getenv("NON_VULNERABLE_IMAGE")
	EOLImage            = os.Getenv("EOL_IMAGE")
	BusyboxImage        = os.Getenv("BUSYBOX_IMAGE")
	CollectorDummyImage = os.Getenv("COLLECTOR_IMAGE_DUMMY")

	RemoverTarballPath   = os.Getenv("REMOVER_TARBALL_PATH")
	ManagerTarballPath   = os.Getenv("MANAGER_TARBALL_PATH")
	CollectorTarballPath = os.Getenv("COLLECTOR_TARBALL_PATH")
	ScannerTarballPath   = os.Getenv("SCANNER_TARBALL_PATH")

	ProjectAbsDir                      = os.Getenv("PROJECT_ABSOLUTE_PATH")
	E2EPath                            = filepath.Join(ProjectAbsDir, "test", "e2e")
	TestDataPath                       = filepath.Join(E2EPath, "test-data")
	KindConfigPath                     = filepath.Join(E2EPath, "kind-config.yaml")
	KindConfigCustomRuntimePath        = filepath.Join(E2EPath, "kind-config-custom-runtime.yaml")
	HelmEmptyValuesPath                = filepath.Join(TestDataPath, "helm-empty-values.yaml")
	ChartPath                          = filepath.Join(ProjectAbsDir, providerResourceChartDir)
	DeployPath                         = filepath.Join(ProjectAbsDir, providerResourceDeployDir)
	OTELCollectorConfigPath            = filepath.Join(TestDataPath, "otelcollector.yaml")
	EraserV1Alpha1ImagelistUpdatedPath = filepath.Join(TestDataPath, "eraser_v1alpha1_imagelist_updated.yaml")
	EraserV1Alpha1ImagelistPath        = filepath.Join(TestDataPath, "eraser_v1alpha1_imagelist.yaml")
	EraserV1ImagelistPath              = filepath.Join(TestDataPath, "eraser_v1_imagelist.yaml")
	ImagelistAlpinePath                = filepath.Join(TestDataPath, "imagelist_alpine.yaml")

	NodeVersion       = os.Getenv("NODE_VERSION")
	ModifiedNodeImage = os.Getenv("MODIFIED_NODE_IMAGE")
	TestNamespace     = envconf.RandomName("test-ns", 16)
	EraserNamespace   = pkgUtil.GetNamespace()
	TestLogDir        = os.Getenv("TEST_LOGDIR")

	ParsedImages        *Images
	Timeout             = time.Minute * 5
	ImagePullSecretJSON = fmt.Sprintf(`["%s"]`, ImagePullSecret)

	ScannerConfigNoDeleteFailedJSON = `` /* 330-byte string literal not displayed */

	ManagerAdditionalArgs = HelmSet{
							// contains filtered or unexported fields
	}
)

Functions

func CheckDeploymentCleanedUp

func CheckDeploymentCleanedUp(ctx context.Context, t *testing.T, client klient.Client)

func CheckImageRemoved

func CheckImageRemoved(ctx context.Context, t *testing.T, nodes []string, images ...string)

func CheckImagesExist

func CheckImagesExist(t *testing.T, nodes []string, images ...string)

func ContainerNotPresentOnNode

func ContainerNotPresentOnNode(nodeName, containerName string) func() (bool, error)

func CreateExclusionList

func CreateExclusionList(namespace string, list string) env.Func

func DeleteImageListsAndJobs

func DeleteImageListsAndJobs(kubeConfig string) error

func DeleteStringFromSlice

func DeleteStringFromSlice(strings []string, s string) []string

func DeployEraserConfig

func DeployEraserConfig(kubeConfig, namespace, fileName string) error

deploy eraser config.

func DeployEraserHelm

func DeployEraserHelm(namespace string, args ...string) env.Func

func DeployEraserManifest

func DeployEraserManifest(namespace, fileName string) env.Func

func DeployOtelCollector

func DeployOtelCollector(namespace string) env.Func

func DockerPullImage

func DockerPullImage(image string) (string, error)

func DockerTagImage

func DockerTagImage(image, tag string) (string, error)

func GetClusterNodes

func GetClusterNodes(t *testing.T) []string

This lists nodes in the cluster, filtering out the control-plane.

func GetImageJob

func GetImageJob(ctx context.Context, cfg *envconf.Config) (eraserv1.ImageJob, error)

func GetPodLogs

func GetPodLogs(t *testing.T) error

func Helm

func Helm(args []string) (string, error)

func HelmDeployLatestEraserRelease

func HelmDeployLatestEraserRelease(namespace string, extraArgs ...string) env.Func

func HelmInstall

func HelmInstall(kubeconfigPath, namespace string, args []string) error

HelmInstall executes "helm install" given a list of arguments.

func HelmUninstall

func HelmUninstall(kubeconfigPath, namespace string, args []string) error

HelmUninstall executes "helm uninstall" given a list of arguments.

func HelmUpgrade

func HelmUpgrade(kubeconfigPath, namespace string, args []string) error

HelmUpgrade executes "helm upgrade" given a list of arguments.

func ImagejobNotInCluster

func ImagejobNotInCluster(kubeconfigPath string) func() (bool, error)

func IsNotFound

func IsNotFound(err error) bool

func Kubectl

func Kubectl(args []string) (string, error)

func KubectlApply

func KubectlApply(kubeconfigPath, namespace string, args []string) error

KubectlApply executes "kubectl apply" given a list of arguments.

func KubectlBackground

func KubectlBackground(args []string) error

func KubectlCurlPod

func KubectlCurlPod(kubeconfigPath, namespace string) (string, error)

KubectlDescribe executes "kubectl describe" given a list of arguments.

func KubectlDelete

func KubectlDelete(kubeconfigPath, namespace string, args []string) error

KubectlDelete executes "kubectl delete" given a list of arguments.

func KubectlDescribe

func KubectlDescribe(kubeconfigPath, podName, namespace string) (string, error)

KubectlDescribe executes "kubectl describe" given a list of arguments.

func KubectlExecCurl

func KubectlExecCurl(kubeconfigPath, podName string, endpoint, namespace string) (string, error)

func KubectlGet

func KubectlGet(kubeconfigPath string, otherArgs ...string) (string, error)

KubectlGet executes "kubectl get" given a list of arguments.

func KubectlLogs

func KubectlLogs(kubeconfigPath, podName, containerName, namespace string, extraArgs ...string) (string, error)

KubectlLogs executes "kubectl logs" given a list of arguments.

func KubectlWait

func KubectlWait(kubeconfigPath, podName, namespace string) (string, error)

func ListNodeContainers

func ListNodeContainers(nodeName string) (string, error)

func ListNodeImages

func ListNodeImages(nodeName string) (string, error)

func LoadImageToCluster

func LoadImageToCluster(clusterName, imageRef, tarballPath string) env.Func

func MakeDeploy

func MakeDeploy(env map[string]string) env.Func

func NewDeployment

func NewDeployment(namespace, name string, replicas int32, labels map[string]string, containers ...corev1.Container) *appsv1.Deployment

func NewPod

func NewPod(namespace, image, name, nodeName string) *corev1.Pod

func NumPodsPresentForLabel

func NumPodsPresentForLabel(ctx context.Context, client klient.Client, num int, label string) func() (bool, error)

func UpgradeEraserHelm

func UpgradeEraserHelm(namespace string, args ...string) env.Func

Types

type HelmPath

type HelmPath string

func (HelmPath) Set

func (hp HelmPath) Set(val string) string

type HelmSet

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

func (*HelmSet) Set

func (hs *HelmSet) Set(val ...string) *HelmSet

func (*HelmSet) String

func (hs *HelmSet) String() string

type Images

type Images struct {
	CollectorImage RepoTag
	RemoverImage   RepoTag
	ManagerImage   RepoTag
	ScannerImage   RepoTag
}

type RepoTag

type RepoTag struct {
	Repo string
	Tag  string
}

Jump to

Keyboard shortcuts

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