flux: github.com/fluxcd/flux/pkg/resource Index | Files

package resource

import "github.com/fluxcd/flux/pkg/resource"


Package Files

id.go policy.go resource.go


var (
    ErrInvalidServiceID = errors.New("invalid service ID")

    LegacyServiceIDRegexp = regexp.MustCompile("^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$")
    // The namespace and name components are (apparently
    // non-normatively) defined in
    // https://github.com/kubernetes/community/blob/master/contributors/design-proposals/architecture/identifiers.md
    // In practice, more punctuation is used than allowed there;
    // specifically, people use underscores as well as dashes and dots, and in names, colons.
    IDRegexp            = regexp.MustCompile("^(<cluster>|[a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.:-]+)$")
    UnqualifiedIDRegexp = regexp.MustCompile("^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.:-]+)$")

func ChangesForPolicyUpdate Uses

func ChangesForPolicyUpdate(workload Workload, update PolicyUpdate) (map[string]string, error)

ChangeForPolicyUpdate evaluates a policy update with respect to a workload. The reason this exists at all is that an `Update` can include qualified policies, for example "tag all containers"; and to make actual changes, we need to examine the workload to which it's to be applied.

This also translates policy deletion to empty values (i.e., `""`), to make it easy to use as command-line arguments or environment variables. When represented in manifests, policies are expected to have a non-empty value when present, even if it's `"true"`; so an empty value can safely denote deletion.

type Container Uses

type Container struct {
    Name  string
    Image image.Ref

type ID Uses

type ID struct {
    // contains filtered or unexported fields

ID is an opaque type which uniquely identifies a resource in an orchestrator.

func MakeID Uses

func MakeID(namespace, kind, name string) ID

MakeID constructs a ID from constituent components.

func MustParseID Uses

func MustParseID(s string) ID

MustParseID constructs a ID from a string representation, panicing if the format is invalid.

func ParseID Uses

func ParseID(s string) (ID, error)

ParseID constructs a ID from a string representation if possible, returning an error value otherwise.

func ParseIDOptionalNamespace Uses

func ParseIDOptionalNamespace(namespace, s string) (ID, error)

ParseIDOptionalNamespace constructs a ID from either a fully qualified string representation, or an unqualified kind/name representation and the supplied namespace.

func (ID) Components Uses

func (id ID) Components() (namespace, kind, name string)

Components returns the constituent components of a ID

func (ID) MarshalJSON Uses

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON encodes a ID as a JSON string. This is done to maintain backwards compatibility with previous flux versions where the ID is a plain string.

func (ID) MarshalText Uses

func (id ID) MarshalText() (text []byte, err error)

MarshalText encodes a ID as a flat string; this is required because ResourceIDs are sometimes used as map keys.

func (*ID) UnmarshalJSON Uses

func (id *ID) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON decodes a ID from a JSON string. This is done to maintain backwards compatibility with previous flux versions where the ID is a plain string.

func (*ID) UnmarshalText Uses

func (id *ID) UnmarshalText(text []byte) error

MarshalText decodes a ID from a flat string; this is required because ResourceIDs are sometimes used as map keys.

type IDSet Uses

type IDSet map[ID]struct{}

func (IDSet) Add Uses

func (s IDSet) Add(ids []ID)

func (IDSet) Contains Uses

func (s IDSet) Contains(id ID) bool

func (IDSet) Intersection Uses

func (s IDSet) Intersection(others IDSet) IDSet

func (IDSet) String Uses

func (s IDSet) String() string

func (IDSet) ToSlice Uses

func (s IDSet) ToSlice() IDs

func (IDSet) Without Uses

func (s IDSet) Without(others IDSet) IDSet

type IDs Uses

type IDs []ID

func (IDs) Contains Uses

func (ids IDs) Contains(id ID) bool

func (IDs) Intersection Uses

func (ids IDs) Intersection(others IDSet) IDSet

func (IDs) Len Uses

func (p IDs) Len() int

func (IDs) Less Uses

func (p IDs) Less(i, j int) bool

func (IDs) Sort Uses

func (p IDs) Sort()

func (IDs) Swap Uses

func (p IDs) Swap(i, j int)

func (IDs) Without Uses

func (ids IDs) Without(others IDSet) (res IDs)

type PolicyUpdate Uses

type PolicyUpdate struct {
    Add    policy.Set `json:"add"`
    Remove policy.Set `json:"remove"`

type PolicyUpdates Uses

type PolicyUpdates map[ID]PolicyUpdate

type Resource Uses

type Resource interface {
    ResourceID() ID       // name, to correlate with what's in the cluster
    Policies() policy.Set // policy for this resource; e.g., whether it is locked, automated, ignored
    Source() string       // where did this come from (informational)
    Bytes() []byte        // the definition, for sending to cluster.Sync

For the minute we just care about

type Workload Uses

type Workload interface {
    Containers() []Container
    // SetContainerImage mutates this workload so that the container
    // named has the image given. This is not expected to have an
    // effect on any underlying file or cluster resource.
    SetContainerImage(container string, ref image.Ref) error

Package resource imports 8 packages (graph) and is imported by 36 packages. Updated 2019-09-29. Refresh now. Tools for package owners.