manifest

package
v2.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigConnectorResourceSelector = []GroupKindSelector{

	&WildcardGroupKind{Group: regexp.MustCompile(`([[:alpha:]]+\.)+cnrm\.cloud\.google\.com`)},
}

ConfigConnectorResourceSelector provides a resource selector for Google Cloud Config Connector resources See https://cloud.google.com/config-connector/docs/overview

View Source
var ManifestTmpDir = filepath.Join(os.TempDir(), manifestsStagingFolder)
View Source
var ManifestsFromGCS = "manifests_from_gcs"
View Source
var ManifestsFromURL = "manifests_from_url"
View Source
var TransformAllowlist = map[apimachinery.GroupKind]latest.ResourceFilter{
	{Group: "", Kind: "Pod"}: {
		GroupKind: "Pod",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "", Kind: "Service"}: {
		GroupKind: "Service",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "apps", Kind: "DaemonSet"}: {
		GroupKind: "DaemonSet.apps",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "apps", Kind: "Deployment"}: {
		GroupKind: "Deployment.apps",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "apps", Kind: "ReplicaSet"}: {
		GroupKind: "ReplicaSet.apps",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "apps", Kind: "StatefulSet"}: {
		GroupKind: "StatefulSet.apps",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "batch", Kind: "CronJob"}: {
		GroupKind: "CronJob.batch",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "batch", Kind: "Job"}: {
		GroupKind: "Job.batch",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "extensions", Kind: "DaemonSet"}: {
		GroupKind: "DaemonSet.extensions",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "extensions", Kind: "Deployment"}: {
		GroupKind: "Deployment.extensions",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},
	{Group: "extensions", Kind: "ReplicaSet"}: {
		GroupKind: "ReplicaSet.extensions",
		Image:     []string{".*"},
		Labels:    []string{".*"},
		PodSpec:   []string{".*"},
	},

	{Group: "serving.knative.dev", Kind: "Service"}: {
		GroupKind: "Service.serving.knative.dev",
		Image:     []string{".*"},
		Labels:    []string{".*"},
	},
	{Group: "agones.dev", Kind: "Fleet"}: {
		GroupKind: "Fleet.agones.dev",
		Image:     []string{".*"},
		Labels:    []string{".*"},
	},
	{Group: "agones.dev", Kind: "GameServer"}: {
		GroupKind: "GameServer.agones.dev",
		Image:     []string{".*"},
		Labels:    []string{".*"},
	},
	{Group: "argoproj.io", Kind: "Rollout"}: {
		GroupKind: "Rollout.argoproj.io",
		Image:     []string{".*"},
		Labels:    []string{".*"},
	},
	{Group: "argoproj.io", Kind: "Workflow"}: {
		GroupKind: "Workflow.argoproj.io",
		Image:     []string{".*"},
		Labels:    []string{".*"},
	},
	{Group: "argoproj.io", Kind: "CronWorkflow"}: {
		GroupKind: "CronWorkflow.argoproj.io",
		Image:     []string{".*"},
		Labels:    []string{".*"},
	},
	{Group: "argoproj.io", Kind: "WorkflowTemplate"}: {
		GroupKind: "WorkflowTemplate.argoproj.io",
		Image:     []string{".*"},
		Labels:    []string{".*"},
	},
	{Group: "argoproj.io", Kind: "ClusterWorkflowTemplate"}: {
		GroupKind: "ClusterWorkflowTemplate.argoproj.io",
		Image:     []string{".*"},
		Labels:    []string{".*"},
	},
	{Group: "platform.confluent.io", Kind: "Connect"}: {
		GroupKind: "Connect.platform.confluent.io",
		Image:     []string{".spec.image.application", ".spec.image.init"},
		Labels:    []string{".*"},
	},
	{Group: "platform.confluent.io", Kind: "ControlCenter"}: {
		GroupKind: "ControlCenter.platform.confluent.io",
		Image:     []string{".spec.image.application", ".spec.image.init"},
		Labels:    []string{".*"},
	},
	{Group: "platform.confluent.io", Kind: "Kafka"}: {
		GroupKind: "Kafka.platform.confluent.io",
		Image:     []string{".spec.image.application", ".spec.image.init"},
		Labels:    []string{".*"},
	},
	{Group: "platform.confluent.io", Kind: "KsqlDB"}: {
		GroupKind: "KsqlDB.platform.confluent.io",
		Image:     []string{".spec.image.application", ".spec.image.init"},
		Labels:    []string{".*"},
	},
	{Group: "platform.confluent.io", Kind: "SchemaRegistry"}: {
		GroupKind: "SchemaRegistry.platform.confluent.io",
		Image:     []string{".spec.image.application", ".spec.image.init"},
		Labels:    []string{".*"},
	},
	{Group: "platform.confluent.io", Kind: "Zookeeper"}: {
		GroupKind: "Zookeeper.platform.confluent.io",
		Image:     []string{".spec.image.application", ".spec.image.init"},
		Labels:    []string{".*"},
	},
	{Group: "run.googleapis.com", Kind: "Job"}: {
		GroupKind: "Job.run.googleapis.com",
		Image:     []string{".*"},
		Labels:    []string{".*"},
	},
	{Group: "kafka.strimzi.io", Kind: "KafkaConnect"}: {
		GroupKind: "KafkaConnect.kafka.strimzi.io",
		Image:     []string{".spec.image"},
		Labels:    []string{".*"},
	},
	{Group: "kafka.strimzi.io", Kind: "Kafka"}: {
		GroupKind: "Kafka.kafka.strimzi.io",
		Image:     []string{".spec.kafka.image", ".spec.zookeeper.image", ".spec.entityOperator.topicOperator.image", ".spec.entityOperator.userOperator.image", ".spec.kafkaExporter.image."},
		Labels:    []string{".*"},
	},
}

TransformAllowlist is the default allowlist of kinds that can be transformed by Skaffold.

View Source
var TransformDenylist = map[apimachinery.GroupKind]latest.ResourceFilter{
	{Group: "apps", Kind: "StatefulSet"}: {
		GroupKind: "StatefulSet.apps",
		Labels:    []string{".spec.volumeClaimTemplates.metadata.labels"},
	},
	{Group: "batch", Kind: "Job"}: {
		GroupKind: "Job.batch",
		Labels:    []string{".spec.template.metadata.labels"},
	},
}

TransformDenylist is the default denylist on the set of kinds that can be transformed by Skaffold.

Functions

func AddTransform

func AddTransform(newTransform Transform)

AddTransform adds a transform to be applied when deploying.

func DownloadFromGCS

func DownloadFromGCS(manifests []string) (string, error)

DownloadFromGCS downloads all provided manifests from a remote GCS bucket, and returns a relative path pointing to the GCS temp dir.

func DownloadFromURL

func DownloadFromURL(manifests []string) ([]string, error)

DownloadFromURL downloads the provided manifests from their URLs, and returns a slice containing downloaded file destinations.

func Write

func Write(manifests string, output string, manifestOut io.Writer) error

Write writes manifests to a file, a writer or a GCS bucket.

Types

type FieldVisitor

type FieldVisitor interface {
	// Visit is called for each transformable key contained in the object and may apply transformations/aggregations on it.
	// It should return true to allow recursive traversal or false when the entry was transformed.
	Visit(gk apimachinery.GroupKind, navpath string, object map[string]interface{}, key string, value interface{}, rs ResourceSelector) bool
}

FieldVisitor represents the aggregation/transformation that should be performed on each traversed field.

type GroupKindSelector

type GroupKindSelector interface {
	Matches(group, kind string) bool
}

type ManifestList

type ManifestList [][]byte

ManifestList is a list of yaml manifests.

func ApplyTransforms

func ApplyTransforms(manifests ManifestList, builds []graph.Artifact, insecureRegistries map[string]bool, debugHelpersRegistry string) (ManifestList, error)

ApplyTransforms applies all manifests transforms to the provided manifests.

func Load

func Load(in io.Reader) (ManifestList, error)

Load uses the Kubernetes `apimachinery` to split YAML content into a set of YAML documents.

func (*ManifestList) Append

func (l *ManifestList) Append(buf []byte)

Append appends the yaml manifests defined in the given buffer. `buf` can contain concatenated manifests without `---` separators because `kubectl create --dry-run -oyaml` produces such output.

func (*ManifestList) CollectNamespaces

func (l *ManifestList) CollectNamespaces() ([]string, error)

CollectNamespaces returns all the namespaces in the manifests.

func (*ManifestList) Diff

func (l *ManifestList) Diff(latest ManifestList) ManifestList

Diff computes the list of manifests that have changed.

func (*ManifestList) Filter

func (l *ManifestList) Filter(selectors ...GroupKindSelector) (ManifestList, error)

Filter returns the manifest list that match any of the given `GroupKindSelector` items

func (*ManifestList) GetImagePlatforms

func (l *ManifestList) GetImagePlatforms(ctx context.Context, rs ResourceSelector) (PodPlatforms, error)

func (*ManifestList) GetImages

func (l *ManifestList) GetImages(rs ResourceSelector) ([]graph.Artifact, error)

GetImages gathers a map of base image names to the image with its tag

func (*ManifestList) Reader

func (l *ManifestList) Reader() io.Reader

Reader returns a reader on the raw yaml descriptors.

func (*ManifestList) ReplaceImages

func (l *ManifestList) ReplaceImages(ctx context.Context, builds []graph.Artifact, rs ResourceSelector) (ManifestList, error)

ReplaceImages replaces image names in a list of manifests. It doesn't replace images that are referenced by digest.

func (*ManifestList) ReplaceRemoteManifestImages

func (l *ManifestList) ReplaceRemoteManifestImages(ctx context.Context, builds []graph.Artifact, rs ResourceSelector) (ManifestList, error)

ReplaceRemoteManifestImages replaces all image names in a list containing remote manifests. This will even override images referenced by digest or with a different repository

func (*ManifestList) SelectResources

func (l *ManifestList) SelectResources(selectors ...GroupKindSelector) ([]unstructured.Unstructured, error)

SelectResources returns the resources defined in the manifest list that match any of the given `GroupKindSelector` items

func (*ManifestList) SetGKEARMToleration

func (l *ManifestList) SetGKEARMToleration(ctx context.Context, rs ResourceSelector, platforms PodPlatforms) (ManifestList, error)

SetGKEARMToleration adds a toleration for GKE ARM node taint `kubernetes.io/arch="arm64":NoSchedule`.

func (*ManifestList) SetLabels

func (l *ManifestList) SetLabels(labels map[string]string, rs ResourceSelector) (ManifestList, error)

SetLabels add labels to a list of Kubernetes manifests.

func (*ManifestList) SetNamespace

func (l *ManifestList) SetNamespace(namespace string, rs ResourceSelector) (ManifestList, error)

SetNamespace sets labels to a list of Kubernetes manifests if they are not set. Returns error if any manifest in the list has namespace set.

func (*ManifestList) SetPlatformNodeAffinity

func (l *ManifestList) SetPlatformNodeAffinity(ctx context.Context, rs ResourceSelector, platforms PodPlatforms) (ManifestList, error)

SetPlatformNodeAffinity adds `nodeAffinity` definitions specific to the target platform (os/architecture) for each built image.

func (*ManifestList) String

func (l *ManifestList) String() string

func (*ManifestList) Visit

func (l *ManifestList) Visit(visitor FieldVisitor, rs ResourceSelector) (ManifestList, error)

Visit recursively visits all transformable object fields within the manifests and lets the visitor apply transformations/aggregations on them.

type ManifestListByConfig

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

func NewManifestListByConfig

func NewManifestListByConfig() ManifestListByConfig

func (*ManifestListByConfig) Add

func (ml *ManifestListByConfig) Add(configName string, manifest ManifestList)

func (ManifestListByConfig) ConfigNames

func (ml ManifestListByConfig) ConfigNames() []string

func (ManifestListByConfig) GetForConfig

func (ml ManifestListByConfig) GetForConfig(configName string) ManifestList

func (ManifestListByConfig) String

func (ml ManifestListByConfig) String() string

type PodPlatforms

type PodPlatforms map[string][]spec.Platform

PodPlatforms maps the pod spec json path to the list of common platforms for all containers in that pod.

type Registries

type Registries struct {
	InsecureRegistries   map[string]bool
	DebugHelpersRegistry string
}

type ResourceSelector

type ResourceSelector interface {
	// contains filtered or unexported methods
}

type ResourceSelectorImages

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

type ResourceSelectorLabels

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

type ResourceSelectorList added in v2.7.0

type ResourceSelectorList struct {
	Selectors []WildcardGroupKind `json:"selectors"`
}

type ResourceSelectorPodSpec

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

type Transform

type Transform func(l ManifestList, builds []graph.Artifact, registries Registries) (ManifestList, error)

func GetTransforms

func GetTransforms() []Transform

GetTransforms returns all manifest transforms.

type WildcardGroupKind added in v2.7.0

type WildcardGroupKind struct {
	Group *regexp.Regexp `json:"group"`
	Kind  *regexp.Regexp `json:"kind"`
}

func (*WildcardGroupKind) Matches added in v2.7.0

func (w *WildcardGroupKind) Matches(group, kind string) bool

func (*WildcardGroupKind) UnmarshalJSON added in v2.7.0

func (w *WildcardGroupKind) UnmarshalJSON(value []byte) error

Jump to

Keyboard shortcuts

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