downwardapi

package
v0.0.0-...-8e8a5cf Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 32

Documentation

Overview

Package downwardapi declares the types used to expose job configuration to the jobs themselves

Index

Constants

View Source
const (
	// ci represents whether the current environment is a CI environment
	CI = "CI"

	// JobSpecEnv is the name that contains JobSpec marshaled into a string.
	JobSpecEnv = "JOB_SPEC"

	JobNameEnv   = "JOB_NAME"
	JobTypeEnv   = "JOB_TYPE"
	ProwJobIDEnv = "PROW_JOB_ID"

	BuildIDEnv     = "BUILD_ID"
	ProwBuildIDEnv = "BUILD_NUMBER" // Deprecated, will be removed in the future.

	RepoOwnerEnv   = "REPO_OWNER"
	RepoNameEnv    = "REPO_NAME"
	PullBaseRefEnv = "PULL_BASE_REF"
	PullBaseShaEnv = "PULL_BASE_SHA"
	PullRefsEnv    = "PULL_REFS"
	PullNumberEnv  = "PULL_NUMBER"
	PullPullShaEnv = "PULL_PULL_SHA"
	PullHeadRefEnv = "PULL_HEAD_REF"
	PullTitleEnv   = "PULL_TITLE"
)

Variables

This section is empty.

Functions

func EnvForSpec

func EnvForSpec(spec JobSpec) (map[string]string, error)

EnvForSpec returns a mapping of environment variables to their values that should be available for a job spec

func EnvForType

func EnvForType(jobType prowapi.ProwJobType) []string

EnvForType returns the slice of environment variables to export for jobType

func GetRevisionFromRefs

func GetRevisionFromRefs(refs *prowapi.Refs, extra []prowapi.Refs) string

func GetRevisionFromSpec

func GetRevisionFromSpec(jobSpec *JobSpec) string

GetRevisionFromSpec returns a main ref or sha from a spec object

func InCI

func InCI() bool

InCI returns true if the CI environment variable is not empty

func PjToStarted

func PjToStarted(pj *prowapi.ProwJob, cloneRecords []clone.Record) metadata.Started

func SpecToStarted

func SpecToStarted(spec *JobSpec, cloneRecords []clone.Record) metadata.Started

Types

type JobSpec

type JobSpec struct {
	Type      prowapi.ProwJobType `json:"type,omitempty"`
	Job       string              `json:"job,omitempty"`
	BuildID   string              `json:"buildid,omitempty"`
	ProwJobID string              `json:"prowjobid,omitempty"`

	// refs & extra_refs from the full spec
	Refs      *prowapi.Refs  `json:"refs,omitempty"`
	ExtraRefs []prowapi.Refs `json:"extra_refs,omitempty"`

	DecorationConfig *prowapi.DecorationConfig `json:"decoration_config,omitempty"`
	// contains filtered or unexported fields
}

JobSpec is the full downward API that we expose to jobs that realize a ProwJob. We will provide this data to jobs with environment variables in two ways:

  • the full spec, in serialized JSON in one variable
  • individual fields of the spec in their own variables

func NewJobSpec

func NewJobSpec(spec prowapi.ProwJobSpec, buildID, prowJobID string) JobSpec

NewJobSpec converts a prowapi.ProwJobSpec invocation into a JobSpec

func ResolveSpecFromEnv

func ResolveSpecFromEnv() (*JobSpec, error)

ResolveSpecFromEnv will determine the Refs being tested in by parsing Prow environment variable contents

Jump to

Keyboard shortcuts

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