steps

package
v0.0.0-...-d1f8b28 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 62 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RPMRepoName    = "rpm-repo"
	AppLabel       = "app"
	TTLIgnoreLabel = "ci.openshift.io/ttl.ignore"
)
View Source
const (
	CiAnnotationPrefix = "ci.openshift.io"
	CreatesLabel       = "creates"
	CreatedByCILabel   = "created-by-ci"

	ProwJobIdLabel = "prow.k8s.io/id"

	OauthSecretKey = "oauth-token"
)
View Source
const (
	LabelMetadataOrg     = "ci.openshift.io/metadata.org"
	LabelMetadataRepo    = "ci.openshift.io/metadata.repo"
	LabelMetadataBranch  = "ci.openshift.io/metadata.branch"
	LabelMetadataVariant = "ci.openshift.io/metadata.variant"
	LabelMetadataTarget  = "ci.openshift.io/metadata.target"
	LabelMetadataStep    = "ci.openshift.io/metadata.step"
	LabelJobID           = "ci.openshift.io/jobid"
	LabelJobType         = "ci.openshift.io/jobtype"
	LabelJobName         = "ci.openshift.io/jobname"
)
View Source
const (
	RefsOrgLabel            = "ci.openshift.io/refs.org"
	RefsRepoLabel           = "ci.openshift.io/refs.repo"
	RefsBranchLabel         = "ci.openshift.io/refs.branch"
	RefsVariantLabel        = "ci.openshift.io/refs.variant"
	JobNameLabel            = "ci.openshift.io/job"
	MultiStageStepNameLabel = "ci.openshift.io/step"

	TestContainerName = "test"
)
View Source
const (

	// A boolean value which indicates that the logs from all containers in the
	// pod must be copied to the artifact directory (default is "false").
	AnnotationSaveContainerLogs = "ci-operator.openshift.io/save-container-logs"
)
View Source
const IndexDataDirectory = "/index-data"
View Source
const IndexDockerfileName = "index.Dockerfile"
View Source
const UnusedIpCount = "UNUSED_IP_COUNT"

Variables

View Source
var CleanupCtx = context.Background()

CleanupCtx is used by steps when the primary context is cancelled. When we're cleaning up, we need a context to use for client calls, but we cannot use the normal context we have in steps, as that may be cancelled (and that would be why we're cleaning up in the first place). This is intended only for internal usage of this package and its sub-packages.

View Source
var (
	JobSpecAnnotation = fmt.Sprintf("%s/%s", CiAnnotationPrefix, "job-spec")
)
View Source
var NoHiveClientErr = errors.New("step claims a cluster without providing a Hive client")
View Source
var NoLeaseClientErr = errors.New("step needs a lease but no lease client provided")
View Source
var NoLeaseClientForIPErr = errors.New("step needs access to an IP pool, but no lease client provided")

Functions

func BundleSourceStep

func BundleSourceStep(
	config api.BundleSourceStepConfiguration,
	releaseBuildConfig *api.ReleaseBuildConfiguration,
	resources api.ResourceConfiguration,
	client BuildClient,
	podClient kubernetes.PodClient,
	jobSpec *api.JobSpec,
	pullSecret *coreapi.Secret,
) api.Step

func ClusterClaimStep

func ClusterClaimStep(as string, clusterClaim *api.ClusterClaim, hiveClient ctrlruntimeclient.WithWatch, client loggingclient.LoggingClient, jobSpec *api.JobSpec, wrapped api.Step, censor *secrets.DynamicCensor) api.Step

func GenerateBasePod

func GenerateBasePod(
	jobSpec *api.JobSpec,
	baseLabels map[string]string,
	name string,
	nodeName string,
	containerName string,
	command []string,
	image string,
	containerResources coreapi.ResourceRequirements,
	artifactDir string,
	decorationConfig *v1.DecorationConfig,
	rawJobSpec string,
	secretsToCensor []coreapi.VolumeMount,
	generatePodOptions *GeneratePodOptions,
) (*coreapi.Pod, error)

func GitSourceStep

func GitSourceStep(
	config api.ProjectDirectoryImageBuildInputs,
	resources api.ResourceConfiguration,
	buildClient BuildClient,
	podClient kubernetes.PodClient,
	jobSpec *api.JobSpec,
	cloneAuthConfig *CloneAuthConfig,
	pullSecret *coreapi.Secret,
) api.Step

GitSourceStep returns gitSourceStep that holds all the required information to create a build from a git source.

func IPPoolStep

func IPPoolStep(client *lease.Client, secretClient SecretClient, lease api.StepLease, wrapped api.Step, params api.Parameters, namespace func() string) api.Step

func ImagesReadyStep

func ImagesReadyStep(links []api.StepLink) api.Step

func IndexGeneratorStep

func IndexGeneratorStep(
	config api.IndexGeneratorStepConfiguration,
	releaseBuildConfig *api.ReleaseBuildConfiguration,
	resources api.ResourceConfiguration,
	buildClient BuildClient,
	podClient kubernetes.PodClient,
	jobSpec *api.JobSpec,
	pullSecret *coreapi.Secret,
) api.Step

func InputEnvironmentStep

func InputEnvironmentStep(name string, values map[string]string, links []api.StepLink) api.Step

InputEnvironmentStep acts as a shim for a given step, taking a precalculated set of inputs and returning those when executed. May be used to substitute a step that does work with another that simply reports output.

func InputImageTagStep

func InputImageTagStep(
	config *api.InputImageTagStepConfiguration,
	client loggingclient.LoggingClient,
	jobSpec *api.JobSpec) api.Step

func LabelsFor

func LabelsFor(spec *api.JobSpec, base map[string]string, ref string) map[string]string

func LeaseStep

func LeaseStep(client *lease.Client, leases []api.StepLease, wrapped api.Step, namespace func() string) api.Step

func NamePerTest

func NamePerTest(name, testName string) string

func OutputImageTagStep

func OutputImageTagStep(config api.OutputImageTagStepConfiguration, client loggingclient.LoggingClient, jobSpec *api.JobSpec) api.Step

func PipelineImageCacheStep

func PipelineImageCacheStep(
	config api.PipelineImageCacheStepConfiguration,
	resources api.ResourceConfiguration,
	client BuildClient,
	podClient kubernetes.PodClient,
	jobSpec *api.JobSpec,
	pullSecret *coreapi.Secret,
) api.Step

func PodStep

func PodStep(name string, config PodStepConfiguration, resources api.ResourceConfiguration, client kubernetes.PodClient, jobSpec *api.JobSpec, clusterClaim *api.ClusterClaim) api.Step

func ProjectDirectoryImageBuildStep

func ProjectDirectoryImageBuildStep(
	config api.ProjectDirectoryImageBuildStepConfiguration,
	releaseBuildConfig *api.ReleaseBuildConfiguration,
	resources api.ResourceConfiguration,
	buildClient BuildClient,
	podClient kubernetes.PodClient,
	jobSpec *api.JobSpec,
	pullSecret *coreapi.Secret,
) api.Step

func RPMImageInjectionStep

func RPMImageInjectionStep(
	config api.RPMImageInjectionStepConfiguration,
	resources api.ResourceConfiguration,
	buildClient BuildClient,
	podClient kubernetes.PodClient,
	jobSpec *api.JobSpec,
	pullSecret *coreapi.Secret,
) api.Step

func RPMServerStep

func RPMServerStep(
	config api.RPMServeStepConfiguration,
	client loggingclient.LoggingClient,
	jobSpec *api.JobSpec) api.Step

func RunPod

func RunPod(ctx context.Context, podClient kubernetes.PodClient, pod *coreapi.Pod) (*coreapi.Pod, error)

RunPod may be used to run a pod to completion. Provides a simpler interface than PodStep and is intended for other steps that may need to run transient actions. This pod will not be able to gather artifacts, nor will it report log messages unless it fails.

func SourceStep

func SourceStep(
	config api.SourceStepConfiguration,
	resources api.ResourceConfiguration,
	buildClient BuildClient,
	podClient kubernetes.PodClient,
	jobSpec *api.JobSpec,
	cloneAuthConfig *CloneAuthConfig,
	pullSecret *corev1.Secret,
) api.Step

func TemplateExecutionStep

func TemplateExecutionStep(template *templateapi.Template, params api.Parameters, podClient kubernetes.PodClient, templateClient TemplateClient, jobSpec *api.JobSpec, resources api.ResourceConfiguration) api.Step

func TestStep

func TestStep(config api.TestStepConfiguration, resources api.ResourceConfiguration, client kubernetes.PodClient, jobSpec *api.JobSpec, nodeName string) api.Step

func WriteParametersStep

func WriteParametersStep(params *api.DeferredParameters, paramFile string) api.Step

Types

type ArtifactWorker

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

ArtifactWorker tracks pods that have completed and have an 'artifacts' container in them and will extract files from the container to a local directory. It also gathers container logs on all pods.

This worker is thread safe and may be invoked in parallel.

func NewArtifactWorker

func NewArtifactWorker(podClient kubernetes.PodClient, artifactDir, namespace string) *ArtifactWorker

func (*ArtifactWorker) CollectFromPod

func (w *ArtifactWorker) CollectFromPod(podName string, hasArtifacts []string, waitForContainers []string)

func (*ArtifactWorker) Complete

func (w *ArtifactWorker) Complete(podName string)

func (*ArtifactWorker) Done

func (w *ArtifactWorker) Done(podName string) <-chan struct{}

func (*ArtifactWorker) Notify

func (w *ArtifactWorker) Notify(pod *coreapi.Pod, containerName string)

type BuildClient

type BuildClient interface {
	loggingclient.LoggingClient
	Logs(namespace, name string, options *buildapi.BuildLogOptions) (io.ReadCloser, error)
	NodeArchitectures() []string
	ManifestToolDockerCfg() string
	LocalRegistryDNS() string
}

func NewBuildClient

func NewBuildClient(client loggingclient.LoggingClient, restClient rest.Interface, nodeArchitectures []string, manifestToolDockerCfg, localRegistryDNS string) BuildClient

type CloneAuthConfig

type CloneAuthConfig struct {
	Secret *corev1.Secret
	Type   CloneAuthType
}

type CloneAuthType

type CloneAuthType string
var (
	CloneAuthTypeSSH   CloneAuthType = "SSH"
	CloneAuthTypeOAuth CloneAuthType = "OAuth"
)

type GeneratePodOptions

type GeneratePodOptions struct {
	Clone             bool
	PropagateExitCode bool
	NodeArchitecture  string
}

type ImageBuildOptions

type ImageBuildOptions struct {
	Architectures []string
}

type PodStepConfiguration

type PodStepConfiguration struct {
	WaitFlags          util.WaitForPodFlag
	As                 string
	From               api.ImageStreamTagReference
	Commands           string
	Labels             map[string]string
	NodeName           string
	ServiceAccountName string
	Secrets            []*api.Secret
	MemoryBackedVolume *api.MemoryBackedVolume
	Clone              bool
	NodeArchitecture   api.NodeArchitecture
}

PodStepConfiguration allows other steps to reuse the pod launching and monitoring behavior without reimplementing function. It also enforces conventions like naming, directory structure, and input image format. More sophisticated reuse of launching pods should use RunPod which is more limited.

type SecretClient

type SecretClient interface {
	Get(ctx context.Context, key ctrlruntimeclient.ObjectKey, obj ctrlruntimeclient.Object, opts ...ctrlruntimeclient.GetOption) error
}

type SubStepReporter

type SubStepReporter interface {
	SubSteps() []api.CIOperatorStepDetailInfo
}

SubStepReporter allows steps to report substeps. TODO: Should this be merged with the SubtestReporter?

type SubtestReporter

type SubtestReporter interface {
	SubTests() []*junit.TestCase
}

SubtestReporter may be implemented by steps that can return an optional set of additional JUnit tests to report to the cluster.

type TemplateClient

type TemplateClient interface {
	loggingclient.LoggingClient
	Process(namespace string, template *templateapi.Template) (*templateapi.Template, error)
}

func NewTemplateClient

func NewTemplateClient(client loggingclient.LoggingClient, restClient rest.Interface) TemplateClient

type TestCaseNotifier

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

TestCaseNotifier allows a caller to generate per container JUnit test reports that provide better granularity for debugging problems when running tests in multi-container pods. It intercepts notifications and remembers the last pod retrieved which SubTests() will read.

TestCaseNotifier must be called from a single thread.

func NewTestCaseNotifier

func NewTestCaseNotifier(nested util.ContainerNotifier) *TestCaseNotifier

NewTestCaseNotifier wraps the provided ContainerNotifier and will create JUnit TestCase records for each container in the most recent pod to have completed.

func (*TestCaseNotifier) Complete

func (n *TestCaseNotifier) Complete(podName string)

func (*TestCaseNotifier) Done

func (n *TestCaseNotifier) Done(podName string) <-chan struct{}

func (*TestCaseNotifier) Notify

func (n *TestCaseNotifier) Notify(pod *coreapi.Pod, containerName string)

func (*TestCaseNotifier) SubTests

func (n *TestCaseNotifier) SubTests(prefix string) []*junit.TestCase

SubTests returns one junit test for each terminated container with a name in the annotation 'ci-operator.openshift.io/container-sub-tests' in the pod. Invoking SubTests clears the last pod, so subsequent calls will return no tests unless Notify() has been called in the meantime.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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