resource

package
v1.24.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReleaseContainerName is the name used when Flux interprets a
	// HelmRelease as having a container with an image, by virtue of
	// having a `values` stanza with an image field:
	//
	// spec:
	//   ...
	//   values:
	//     image: some/image:version
	//
	// The name refers to the source of the image value.
	ReleaseContainerName = "chart-image"

	// ImageBasePath is the default base path for image path mappings
	// in a HelmRelease resource.
	ImageBasePath = "spec.values."
	// ImageRegistryPrefix is the annotation key prefix for image
	// registry path mappings.
	ImageRegistryPrefix = "registry.fluxcd.io/"
	// ImageRepositoryPrefix is the annotation key prefix for image
	// repository path mappings.
	ImageRepositoryPrefix = "repository.fluxcd.io/"
	// ImageRepositoryPrefix is the annotation key prefix for image
	// tag path mappings.
	ImageTagPrefix = "tag.fluxcd.io/"
)
View Source
const (
	PolicyPrefix       = "fluxcd.io/"
	FilterPolicyPrefix = "filter.fluxcd.io/"
	// This is the previously-used prefix for annotations; many
	// manifests in the wild will still be using it, so it's included
	// here for backward-compatibility.
	AlternatePolicyPrefix = "flux.weave.works/"
	ClusterScope          = "<cluster>"
)

Variables

This section is empty.

Functions

func FindHelmReleaseContainers

func FindHelmReleaseContainers(annotations map[string]string, values map[string]interface{},
	visit func(string, image.Ref, ImageSetter) error)

FindHelmReleaseContainers examines the Values from a HelmRelease (manifest, or cluster resource, or otherwise) and calls visit with each container name and image it finds, as well as procedure for changing the image value.

func Load

func Load(base string, paths []string, sopsEnabled bool) (map[string]KubeManifest, error)

Load takes paths to directories or files, and creates an object set based on the file(s) therein. Resources are named according to the file content, rather than the file name of directory structure. if sopsEnabled is set to true, sops-encrypted files will be decrypted.

func ParseMultidoc

func ParseMultidoc(multidoc []byte, source string) (map[string]KubeManifest, error)

ParseMultidoc takes a dump of config (a multidoc YAML) and constructs an object set from the resources represented therein.

func PoliciesFromAnnotations

func PoliciesFromAnnotations(annotations map[string]string) policy.Set

Types

type Args

type Args []string

type ContainerImageMap

type ContainerImageMap struct {
	BasePath   string
	Registry   string
	Repository string
	Tag        string
}

ContainerImageMap holds the YAML dot notation paths to a container image.

func (ContainerImageMap) AllDefined

func (c ContainerImageMap) AllDefined() bool

AllDefined returns if all image elements are defined.

func (ContainerImageMap) GetRegistry

func (c ContainerImageMap) GetRegistry() string

GetRegistry returns the full registry path (with base path).

func (ContainerImageMap) GetRepository

func (c ContainerImageMap) GetRepository() string

GetRepository returns the full repository path (with base path).

func (ContainerImageMap) GetTag

func (c ContainerImageMap) GetTag() string

GetTag returns the full tag path (with base path).

func (ContainerImageMap) MapImageRef

func (c ContainerImageMap) MapImageRef(image image.Ref) (map[string]string, bool)

MapImageRef maps the given imageRef to the dot notation paths ContainerImageMap holds. It needs at least an Repository to be able to compose the map, and takes the absence of the registry and/or tag paths into account to ensure all image elements (registry, repository, tag) are present in the returned map.

func (ContainerImageMap) RegistryRepository

func (c ContainerImageMap) RegistryRepository() bool

RegistryRepository returns if the registry and repository are defined, but the tag is not.

func (ContainerImageMap) RepositoryOnly

func (c ContainerImageMap) RepositoryOnly() bool

RepositoryOnly returns if only the repository is defined.

func (ContainerImageMap) RepositoryTag

func (c ContainerImageMap) RepositoryTag() bool

RegistryRepository returns if the repository and tag are defined, but the registry is not.

type ContainerPort

type ContainerPort struct {
	ContainerPort int
	Name          string
}

type ContainerSpec

type ContainerSpec struct {
	Name  string
	Image string
	Args  Args
	Ports []ContainerPort
	Env   Env
}

type CronJob

type CronJob struct {
	Spec CronJobSpec
	// contains filtered or unexported fields
}

func (CronJob) Bytes

func (o CronJob) Bytes() []byte

func (CronJob) Containers

func (c CronJob) Containers() []resource.Container

func (CronJob) GetKind

func (o CronJob) GetKind() string

GetKind implements KubeManifest.GetKind

func (CronJob) GetName

func (o CronJob) GetName() string

GetName implements KubeManifest.GetName

func (CronJob) GetNamespace

func (o CronJob) GetNamespace() string

GetNamespace implements KubeManifest.GetNamespace, so things embedding baseObject are < KubeManifest

func (CronJob) GroupVersion

func (o CronJob) GroupVersion() string

GroupVersion implements KubeManifest.GroupVersion, so things with baseObject embedded are < KubeManifest

func (CronJob) Policies

func (o CronJob) Policies() policy.Set

func (CronJob) PolicyAnnotationKey

func (o CronJob) PolicyAnnotationKey(p string) (string, bool)

PolicyAnnotationKey returns the key used in this resource to indicate a particular policy; this is to aid in supporting more than one way of using annotations for policy. If the policy is not present, returns `"", false`.

func (CronJob) ResourceID

func (o CronJob) ResourceID() resource.ID

func (CronJob) SetContainerImage

func (c CronJob) SetContainerImage(container string, ref image.Ref) error

func (*CronJob) SetNamespace

func (o *CronJob) SetNamespace(ns string)

SetNamespace implements KubeManifest.SetNamespace, so things with *baseObject embedded are < KubeManifest. NB pointer receiver.

func (CronJob) Source

func (o CronJob) Source() string

type CronJobSpec

type CronJobSpec struct {
	JobTemplate struct {
		Spec struct {
			Template PodTemplate
		}
	} `yaml:"jobTemplate"`
}

type DaemonSet

type DaemonSet struct {
	Spec struct {
		Template PodTemplate
	}
	// contains filtered or unexported fields
}

func (DaemonSet) Bytes

func (o DaemonSet) Bytes() []byte

func (DaemonSet) Containers

func (ds DaemonSet) Containers() []resource.Container

func (DaemonSet) GetKind

func (o DaemonSet) GetKind() string

GetKind implements KubeManifest.GetKind

func (DaemonSet) GetName

func (o DaemonSet) GetName() string

GetName implements KubeManifest.GetName

func (DaemonSet) GetNamespace

func (o DaemonSet) GetNamespace() string

GetNamespace implements KubeManifest.GetNamespace, so things embedding baseObject are < KubeManifest

func (DaemonSet) GroupVersion

func (o DaemonSet) GroupVersion() string

GroupVersion implements KubeManifest.GroupVersion, so things with baseObject embedded are < KubeManifest

func (DaemonSet) Policies

func (o DaemonSet) Policies() policy.Set

func (DaemonSet) PolicyAnnotationKey

func (o DaemonSet) PolicyAnnotationKey(p string) (string, bool)

PolicyAnnotationKey returns the key used in this resource to indicate a particular policy; this is to aid in supporting more than one way of using annotations for policy. If the policy is not present, returns `"", false`.

func (DaemonSet) ResourceID

func (o DaemonSet) ResourceID() resource.ID

func (DaemonSet) SetContainerImage

func (ds DaemonSet) SetContainerImage(container string, ref image.Ref) error

func (*DaemonSet) SetNamespace

func (o *DaemonSet) SetNamespace(ns string)

SetNamespace implements KubeManifest.SetNamespace, so things with *baseObject embedded are < KubeManifest. NB pointer receiver.

func (DaemonSet) Source

func (o DaemonSet) Source() string

type Deployment

type Deployment struct {
	Spec DeploymentSpec
	// contains filtered or unexported fields
}

func (Deployment) Bytes

func (o Deployment) Bytes() []byte

func (Deployment) Containers

func (d Deployment) Containers() []resource.Container

func (Deployment) GetKind

func (o Deployment) GetKind() string

GetKind implements KubeManifest.GetKind

func (Deployment) GetName

func (o Deployment) GetName() string

GetName implements KubeManifest.GetName

func (Deployment) GetNamespace

func (o Deployment) GetNamespace() string

GetNamespace implements KubeManifest.GetNamespace, so things embedding baseObject are < KubeManifest

func (Deployment) GroupVersion

func (o Deployment) GroupVersion() string

GroupVersion implements KubeManifest.GroupVersion, so things with baseObject embedded are < KubeManifest

func (Deployment) Policies

func (o Deployment) Policies() policy.Set

func (Deployment) PolicyAnnotationKey

func (o Deployment) PolicyAnnotationKey(p string) (string, bool)

PolicyAnnotationKey returns the key used in this resource to indicate a particular policy; this is to aid in supporting more than one way of using annotations for policy. If the policy is not present, returns `"", false`.

func (Deployment) ResourceID

func (o Deployment) ResourceID() resource.ID

func (Deployment) SetContainerImage

func (d Deployment) SetContainerImage(container string, ref image.Ref) error

func (*Deployment) SetNamespace

func (o *Deployment) SetNamespace(ns string)

SetNamespace implements KubeManifest.SetNamespace, so things with *baseObject embedded are < KubeManifest. NB pointer receiver.

func (Deployment) Source

func (o Deployment) Source() string

type DeploymentSpec

type DeploymentSpec struct {
	Replicas int
	Template PodTemplate
}

type Env

type Env []EnvEntry

Env is a bag of Name, Value pairs that are treated somewhat like a map.

type EnvEntry

type EnvEntry struct {
	Name, Value string
}

type HelmRelease

type HelmRelease struct {
	Spec struct {
		Values map[string]interface{}
	}
	// contains filtered or unexported fields
}

HelmRelease echoes the generated type for the custom resource definition. It's here so we can 1. get `baseObject` in there, and 3. control the YAML serialisation of fields, which we can't do (easily?) with the generated type.

func (HelmRelease) Bytes

func (o HelmRelease) Bytes() []byte

func (HelmRelease) Containers

func (hr HelmRelease) Containers() []resource.Container

Containers returns the containers that are defined in the HelmRelease.

func (HelmRelease) GetContainerImageMap

func (hr HelmRelease) GetContainerImageMap(container string) (ContainerImageMap, error)

GetContainerImageMap returns the ContainerImageMap for a container, or an error if we were unable to interpret the mapping, or no mapping was found.

func (HelmRelease) GetKind

func (o HelmRelease) GetKind() string

GetKind implements KubeManifest.GetKind

func (HelmRelease) GetName

func (o HelmRelease) GetName() string

GetName implements KubeManifest.GetName

func (HelmRelease) GetNamespace

func (o HelmRelease) GetNamespace() string

GetNamespace implements KubeManifest.GetNamespace, so things embedding baseObject are < KubeManifest

func (HelmRelease) GroupVersion

func (o HelmRelease) GroupVersion() string

GroupVersion implements KubeManifest.GroupVersion, so things with baseObject embedded are < KubeManifest

func (HelmRelease) Policies

func (o HelmRelease) Policies() policy.Set

func (HelmRelease) PolicyAnnotationKey

func (o HelmRelease) PolicyAnnotationKey(p string) (string, bool)

PolicyAnnotationKey returns the key used in this resource to indicate a particular policy; this is to aid in supporting more than one way of using annotations for policy. If the policy is not present, returns `"", false`.

func (HelmRelease) ResourceID

func (o HelmRelease) ResourceID() resource.ID

func (HelmRelease) SetContainerImage

func (hr HelmRelease) SetContainerImage(container string, ref image.Ref) error

SetContainerImage mutates this resource by setting the `image` field of `values`, or a subvalue therein, per one of the interpretations in `FindHelmReleaseContainers` above. NB we can get away with a value-typed receiver because we set a map entry.

func (*HelmRelease) SetNamespace

func (o *HelmRelease) SetNamespace(ns string)

SetNamespace implements KubeManifest.SetNamespace, so things with *baseObject embedded are < KubeManifest. NB pointer receiver.

func (HelmRelease) Source

func (o HelmRelease) Source() string

type ImageSetter

type ImageSetter func(image.Ref)

type KubeManifest

type KubeManifest interface {
	resource.Resource
	GroupVersion() string
	GetKind() string
	GetName() string
	GetNamespace() string
	SetNamespace(string)

	PolicyAnnotationKey(string) (string, bool)
}

KubeManifest represents a manifest for a Kubernetes resource. For some Kubernetes-specific purposes we need more information that can be obtained from `resource.Resource`.

type List

type List struct {
	Items []KubeManifest
	// contains filtered or unexported fields
}

func (List) Bytes

func (o List) Bytes() []byte

func (List) GetKind

func (o List) GetKind() string

GetKind implements KubeManifest.GetKind

func (List) GetName

func (o List) GetName() string

GetName implements KubeManifest.GetName

func (List) GetNamespace

func (o List) GetNamespace() string

GetNamespace implements KubeManifest.GetNamespace, so things embedding baseObject are < KubeManifest

func (List) GroupVersion

func (o List) GroupVersion() string

GroupVersion implements KubeManifest.GroupVersion, so things with baseObject embedded are < KubeManifest

func (List) Policies

func (o List) Policies() policy.Set

func (List) PolicyAnnotationKey

func (o List) PolicyAnnotationKey(p string) (string, bool)

PolicyAnnotationKey returns the key used in this resource to indicate a particular policy; this is to aid in supporting more than one way of using annotations for policy. If the policy is not present, returns `"", false`.

func (List) ResourceID

func (o List) ResourceID() resource.ID

func (*List) SetNamespace

func (o *List) SetNamespace(ns string)

SetNamespace implements KubeManifest.SetNamespace, so things with *baseObject embedded are < KubeManifest. NB pointer receiver.

func (List) Source

func (o List) Source() string

type Namespace

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

func (Namespace) Bytes

func (o Namespace) Bytes() []byte

func (Namespace) GetKind

func (o Namespace) GetKind() string

GetKind implements KubeManifest.GetKind

func (Namespace) GetName

func (o Namespace) GetName() string

GetName implements KubeManifest.GetName

func (Namespace) GetNamespace

func (o Namespace) GetNamespace() string

GetNamespace implements KubeManifest.GetNamespace, so things embedding baseObject are < KubeManifest

func (Namespace) GroupVersion

func (o Namespace) GroupVersion() string

GroupVersion implements KubeManifest.GroupVersion, so things with baseObject embedded are < KubeManifest

func (Namespace) Policies

func (o Namespace) Policies() policy.Set

func (Namespace) PolicyAnnotationKey

func (o Namespace) PolicyAnnotationKey(p string) (string, bool)

PolicyAnnotationKey returns the key used in this resource to indicate a particular policy; this is to aid in supporting more than one way of using annotations for policy. If the policy is not present, returns `"", false`.

func (Namespace) ResourceID

func (o Namespace) ResourceID() resource.ID

func (*Namespace) SetNamespace

func (o *Namespace) SetNamespace(ns string)

SetNamespace implements KubeManifest.SetNamespace, so things with *baseObject embedded are < KubeManifest. NB pointer receiver.

func (Namespace) Source

func (o Namespace) Source() string

type ObjectMeta

type ObjectMeta struct {
	Labels      map[string]string
	Annotations map[string]string
}

type PodSpec

type PodSpec struct {
	ImagePullSecrets []struct{ Name string }
	Volumes          []Volume
	Containers       []ContainerSpec
	InitContainers   []ContainerSpec `yaml:"initContainers"`
}

type PodTemplate

type PodTemplate struct {
	Metadata ObjectMeta
	Spec     PodSpec
}

func (PodTemplate) Containers

func (t PodTemplate) Containers() []resource.Container

func (PodTemplate) SetContainerImage

func (t PodTemplate) SetContainerImage(container string, ref image.Ref) error

type StatefulSet

type StatefulSet struct {
	Spec StatefulSetSpec
	// contains filtered or unexported fields
}

func (StatefulSet) Bytes

func (o StatefulSet) Bytes() []byte

func (StatefulSet) Containers

func (ss StatefulSet) Containers() []resource.Container

func (StatefulSet) GetKind

func (o StatefulSet) GetKind() string

GetKind implements KubeManifest.GetKind

func (StatefulSet) GetName

func (o StatefulSet) GetName() string

GetName implements KubeManifest.GetName

func (StatefulSet) GetNamespace

func (o StatefulSet) GetNamespace() string

GetNamespace implements KubeManifest.GetNamespace, so things embedding baseObject are < KubeManifest

func (StatefulSet) GroupVersion

func (o StatefulSet) GroupVersion() string

GroupVersion implements KubeManifest.GroupVersion, so things with baseObject embedded are < KubeManifest

func (StatefulSet) Policies

func (o StatefulSet) Policies() policy.Set

func (StatefulSet) PolicyAnnotationKey

func (o StatefulSet) PolicyAnnotationKey(p string) (string, bool)

PolicyAnnotationKey returns the key used in this resource to indicate a particular policy; this is to aid in supporting more than one way of using annotations for policy. If the policy is not present, returns `"", false`.

func (StatefulSet) ResourceID

func (o StatefulSet) ResourceID() resource.ID

func (StatefulSet) SetContainerImage

func (ss StatefulSet) SetContainerImage(container string, ref image.Ref) error

func (*StatefulSet) SetNamespace

func (o *StatefulSet) SetNamespace(ns string)

SetNamespace implements KubeManifest.SetNamespace, so things with *baseObject embedded are < KubeManifest. NB pointer receiver.

func (StatefulSet) Source

func (o StatefulSet) Source() string

type StatefulSetSpec

type StatefulSetSpec struct {
	Replicas int
	Template PodTemplate
}

type Volume

type Volume struct {
	Name   string
	Secret struct {
		SecretName string
	}
}

type VolumeMount

type VolumeMount struct {
	Name      string
	MountPath string
	ReadOnly  bool
}

Jump to

Keyboard shortcuts

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