scorecard

package
v0.0.0-...-e53d1d7 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigFileName is the scorecard's hard-coded config file name.
	ConfigFileName = "config.yaml"
	// DefaultConfigDir is the default scorecard path within a bundle.
	DefaultConfigDir = "tests/scorecard/"
)
View Source
const (
	// PodBundleRoot is the directory containing all bundle data within a test pod.
	PodBundleRoot = "/bundle"
)
View Source
const (
	StorageSidecarContainer = "scorecard-gather"
)

Variables

This section is empty.

Functions

func ConfigDocLink() string

func GetKubeClient

func GetKubeClient(kubeconfig string) (client kubernetes.Interface, config *rest.Config, err error)

GetKubeClient will get a kubernetes client from the following sources:

  • a path to the kubeconfig file passed on the command line (--kubeconfig)
  • an environment variable that specifies the path (export KUBECONFIG)
  • the user's $HOME/.kube/config file
  • in-cluster connection for when the sdk is run within a cluster instead of the command line

TODO(joelanford): migrate scorecard use `internal/operator.Configuration`

func GetKubeNamespace

func GetKubeNamespace(kubeconfigPath, namespace string) string

GetKubeNamespace returns the kubernetes namespace to use for scorecard pod creation the order of how the namespace is determined is as follows: - a namespace command line argument - a namespace determined from the kubeconfig file - the kubeconfig file is determined in the following order:

  • from the kubeconfig flag if set
  • from the KUBECONFIG env var if set
  • from the $HOME/.kube/config path if exists
  • returns 'default' as the namespace if not set in the kubeconfig

TODO(joelanford): migrate scorecard to use `internal/operator.Configuration`

func LoadConfig

func LoadConfig(configFilePath string) (v1alpha3.Configuration, error)

LoadConfig will find and return the scorecard config, the config file is found from a bundle location (TODO bundle image) scorecard config.yaml is expected to be in the bundle at the following location: tests/scorecard/config.yaml the user can override this location using the --config CLI flag TODO: version this.

func UntarFile

func UntarFile(tarName, target string) (err error)

untar a file into a location

func WritePathsToTar

func WritePathsToTar(tw *tar.Writer, paths []string) (err error)

WritePathsToTar walks paths to create tar file tarName

func WriteToTar

func WriteToTar(tw *tar.Writer, r io.Reader, hdr *tar.Header) error

Types

type FakeTestRunner

type FakeTestRunner struct {
	Sleep      time.Duration
	TestStatus *v1alpha3.TestStatus
	Error      error
}

func (FakeTestRunner) Cleanup

func (r FakeTestRunner) Cleanup(ctx context.Context) error

func (FakeTestRunner) Initialize

func (r FakeTestRunner) Initialize(ctx context.Context) error

func (FakeTestRunner) RunTest

RunTest executes a single test

type PodTestRunner

type PodTestRunner struct {
	Namespace      string
	ServiceAccount string
	BundlePath     string
	TestOutput     string
	BundleMetadata registryutil.LabelsMap
	Client         kubernetes.Interface
	RESTConfig     *rest.Config
	StorageImage   string
	UntarImage     string

	PodSecurity bool
	// contains filtered or unexported fields
}

func (PodTestRunner) Cleanup

func (r PodTestRunner) Cleanup(ctx context.Context) (err error)

Cleanup deletes pods and configmap resources from this test run

func (PodTestRunner) CreateConfigMap

func (r PodTestRunner) CreateConfigMap(ctx context.Context, bundleData []byte) (configMapName string, err error)

CreateConfigMap creates a ConfigMap that will hold the bundle contents to be mounted into the test Pods

func (*PodTestRunner) Initialize

func (r *PodTestRunner) Initialize(ctx context.Context) error

Initialize sets up the bundle configmap for tests

func (PodTestRunner) RunTest

RunTest executes a single test

type Scorecard

type Scorecard struct {
	Config      v1alpha3.Configuration
	Selector    labels.Selector
	TestRunner  TestRunner
	SkipCleanup bool
	PodSecurity bool
}

func (Scorecard) List

func (o Scorecard) List() v1alpha3.TestList

List lists the scorecard tests as configured that would be run based on user selection

func (Scorecard) Run

func (o Scorecard) Run(ctx context.Context) (testOutput v1alpha3.TestList, err error)

Run executes the scorecard tests as configured

type TestRunner

type TestRunner interface {
	Initialize(context.Context) error
	RunTest(context.Context, v1alpha3.TestConfiguration, bool) (*v1alpha3.TestStatus, error)
	Cleanup(context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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