scorecard

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: Apache-2.0 Imports: 26 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"
)

Variables

This section is empty.

Functions

func ConfigDocLink() string

func GetKubeClient added in v1.0.0

func GetKubeClient(kubeconfig string) (client kubernetes.Interface, 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 added in v1.0.0

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

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

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

untar a file into a location

func WritePathsToTar added in v1.0.0

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

WritePathsToTar walks paths to create tar file tarName

func WriteToTar added in v1.0.0

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

Types

type FakeTestRunner added in v1.0.0

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

func (FakeTestRunner) Cleanup added in v1.0.0

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

func (FakeTestRunner) Initialize added in v1.0.0

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

func (FakeTestRunner) RunTest added in v1.0.0

func (r FakeTestRunner) RunTest(ctx context.Context, test v1alpha3.TestConfiguration) (result *v1alpha3.TestStatus, err error)

RunTest executes a single test

type PodTestRunner added in v1.0.0

type PodTestRunner struct {
	Namespace      string
	ServiceAccount string
	BundlePath     string
	BundleMetadata registryutil.Labels
	Client         kubernetes.Interface
	// contains filtered or unexported fields
}

func (PodTestRunner) Cleanup added in v1.0.0

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

Cleanup deletes pods and configmap resources from this test run

func (PodTestRunner) CreateConfigMap added in v1.0.0

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

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

Initialize sets up the bundle configmap for tests

func (PodTestRunner) RunTest added in v1.0.0

RunTest executes a single test

type Scorecard added in v1.0.0

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

func (Scorecard) List added in v1.0.0

func (o Scorecard) List() v1alpha3.TestList

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

func (Scorecard) Run added in v1.0.0

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

Run executes the scorecard tests as configured

type TestRunner added in v1.0.0

type TestRunner interface {
	Initialize(context.Context) error
	RunTest(context.Context, v1alpha3.TestConfiguration) (*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