builder

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package builder implements functions used to build the JSON output

Index

Constants

View Source
const (
	// JenkinsTrigger is the name of the type in the spinnaker json for pipeline config for jenkins job triggers
	JenkinsTrigger = "jenkins"
	// WebhookTrigger is the name of the type in the spinnaker json for pipeline config for webhooks
	WebhookTrigger = "webhook"
	// LoadBalancerFormat creates the label selectors to attach pipeline.yml labels to deployment selectors
	LoadBalancerFormat = "load-balancer-%s"
	// HourInMS provides 1 hour in milliseconds
	HourInMS int64 = 3600000
)

Variables

View Source
var (
	// ErrNoContainers is returned when a manifest has defined containers in it
	ErrNoContainers = errors.New("builder: no containers were found in given manifest file")
	// ErrNoDeployGroups is returned when a stage in the pipeline.yml does not have any deploy groups on it.
	ErrNoDeployGroups = errors.New("builder: no deploy groups were defined in given pipeline.yml")
	// ErrOverrideContention is returned when a manifest defines multiple containers and overrides were provided
	ErrOverrideContention = errors.New("builder: overrides were provided to a group that has multiple containers defined")
	// ErrDeploymentJob is returned when a manifest uses a deployment for a one shot job
	ErrDeploymentJob = errors.New("builder: a deployment manifest was provided for a run job pod")
	// ErrKubernetesAPI defines whether the manifest we've provided falls within the scope
	ErrKubernetesAPI = errors.New("builder: could not marshal this type of kubernetes manifest")
	// ErrNoManifestFiles is returned when a manifest stage does not
	ErrNoManifestFiles = errors.New("builder: no manifest files defined")
	// ErrNoNamespace is returned when a manifest does not have a namespace
	ErrNoNamespace = errors.New("builder: manifest does not have a namespace defined")
	// ErrNoKubernetesMetadata is returned when a manifest does not have kubernetes metadata
	ErrNoKubernetesMetadata = errors.New("builder: manifest does not have kubernetes metadata attached")

	// Stages helps to translate from spinnaker account to configurator stages
	Stages = map[string]string{
		"int":            "int",
		"int-k8s":        "int",
		"staging":        "stage",
		"staging-k8s":    "stage",
		"production":     "production",
		"production-k8s": "production",
		"ops":            "ops",
		"ops-k8s":        "ops",
	}
)
View Source
var (
	// ErrUnsupportedManifest is returned when a given kubernetes manifest file
	// is not supported
	ErrUnsupportedManifest = errors.New("builder: manifest type is not supported")
)

Functions

This section is empty.

Types

type Builder

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

Builder constructs a spinnaker pipeline JSON from a pipeliner config

func New

func New(p *config.Pipeline, opts ...OptFunc) *Builder

New initializes a new builder for a pipeline config

func (*Builder) MarshalJSON

func (b *Builder) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller

func (*Builder) Pipeline

func (b *Builder) Pipeline() (*types.SpinnakerPipeline, error)

Pipeline returns a filled out spinnaker pipeline from the given config

type ManifestGroup

type ManifestGroup struct {
	Namespace      string
	Annotations    map[string]string
	PodAnnotations map[string]string
	Containers     []*types.Container
	InitContainers []*types.Container
	VolumeSources  []*types.VolumeSource
}

ManifestGroup keeps a collection of containers from a deployment and metadata associated with them

type ManifestParser added in v0.0.8

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

ManifestParser handles generating Spinnaker builder types from a kubernetes manifest file (deployments)

func NewManfifestParser added in v0.0.8

func NewManfifestParser(config *config.Pipeline, basePath ...string) *ManifestParser

NewManfifestParser initializes and returns a manifest parser for a given pipeline config. If a basePath is passed it is used as the path when loading relative file paths for manifest definitions

func (*ManifestParser) ContainersFromScaffold added in v0.0.8

func (mp *ManifestParser) ContainersFromScaffold(scaffold config.ContainerScaffold) (*ManifestGroup, error)

ContainersFromScaffold loads a kubernetes manifest file and generates spinnaker pipeline containers config from it.

func (*ManifestParser) InjectContainerImageDescription added in v0.0.22

func (mp *ManifestParser) InjectContainerImageDescription(container corev1.Container, scaffold config.ContainerScaffold) corev1.Container

InjectContainerImageDescription takes a kubernetes container and inserts the corresponding image description from a trigger

func (*ManifestParser) InjectDeploymentOverrides added in v0.0.22

func (mp *ManifestParser) InjectDeploymentOverrides(manifest *v1beta1.Deployment, scaffold config.ContainerScaffold) (*v1beta1.Deployment, error)

InjectDeploymentOverrides takes the manifest -> injects them into the marshalled manifest

func (*ManifestParser) InjectPodOverrides added in v0.0.22

func (mp *ManifestParser) InjectPodOverrides(manifest *corev1.Pod, scaffold config.ContainerScaffold) (*corev1.Pod, error)

InjectPodOverrides takes the Pod object and injects the scaffolded overrides

func (*ManifestParser) ManifestFromFile added in v0.0.23

func (mp *ManifestParser) ManifestFromFile(path string) (runtime.Object, error)

ManifestFromFile creates a dynamic kubernetes objects for a given pipeline config

func (*ManifestParser) ManifestFromScaffold added in v0.0.22

func (mp *ManifestParser) ManifestFromScaffold(scaffold config.ContainerScaffold) (runtime.Object, error)

ManifestFromScaffold creates a dynamic kubernetes object for a given pipeline config

func (*ManifestParser) ManifestsFromFile added in v0.0.24

func (mp *ManifestParser) ManifestsFromFile(path string) ([]runtime.Object, error)

ManifestsFromFile creates an array of dynamic kubernetes objects for a given pipeline config

type OptFunc

type OptFunc func(b *Builder)

OptFunc is used to assign configuration values to a pipeline builder

func WithAccountOverride added in v0.0.27

func WithAccountOverride(accounts map[string]string) OptFunc

WithAccountOverride lets you override an account with a different account

func WithBasePath added in v0.0.13

func WithBasePath(basePath string) OptFunc

WithBasePath assigns the base path for the builder to use when given relatively pathed files for manifests

func WithLinear

func WithLinear(l bool) OptFunc

WithLinear makes the builder assign references automatically for every stage within a pipeline config

func WithTimeoutOverride added in v0.0.26

func WithTimeoutOverride(hours int) OptFunc

WithTimeoutOverride overrides every stage's default 72 hour timeout

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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