util

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT 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/azure/eraser/e2e-test/nginx:latest"
	NginxAliasOne = "ghcr.io/azure/eraser/e2e-test/nginx:one"
	NginxAliasTwo = "ghcr.io/azure/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")

	CollectorLabel       = "collector"
	ManualLabel          = "manual"
	ImageJobTypeLabelKey = "eraser.sh/type"
)

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")

	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")
	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")
	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 added in v0.5.0

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 added in v0.3.0

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 added in v0.5.0

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

func DeployEraserManifest added in v0.3.0

func DeployEraserManifest(namespace, fileName string) env.Func

func DeployOtelCollector added in v1.0.0

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 added in v0.5.0

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

func GetPodLogs added in v0.5.0

func GetPodLogs(t *testing.T) error

func Helm

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

func HelmDeployLatestEraserRelease added in v1.1.0

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 added in v1.1.0

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 KindLoadImage

func KindLoadImage(clusterName string, images ...string) (string, error)

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 added in v1.0.0

func KubectlBackground(args []string) error

func KubectlCurlPod added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.1.0

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

func MakeDeploy added in v0.5.0

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 added in v0.5.0

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

func UpgradeEraserHelm added in v1.1.0

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

Types

type HelmPath added in v0.5.0

type HelmPath string

func (HelmPath) Set added in v0.5.0

func (hp HelmPath) Set(val string) string

type HelmSet added in v1.0.0

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

func (*HelmSet) Set added in v1.0.0

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

func (*HelmSet) String added in v1.0.0

func (hs *HelmSet) String() string

type Images added in v0.5.0

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

type RepoTag added in v0.5.0

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