flux: github.com/weaveworks/flux/pkg/manifests Index | Files

package manifests

import "github.com/weaveworks/flux/pkg/manifests"

Index

Package Files

configaware.go configfile.go manifests.go rawfiles.go store.go

Constants

const (
    ConfigFilename = ".flux.yaml"
    CommandTimeout = time.Minute
)

Variables

var ConfigSchema = mustCompileConfigSchema()

func ErrResourceNotFound Uses

func ErrResourceNotFound(name string) error

func NewConfigAware Uses

func NewConfigAware(baseDir string, targetPaths []string, manifests Manifests) (*configAware, error)

NewConfigAware constructs a `Store` that processes in-repo config files (`.flux.yaml`) where present, and otherwise looks for "raw" YAML files.

func NewRawFiles Uses

func NewRawFiles(baseDir string, paths []string, manifests Manifests) *rawFiles

NewRawFiles constructs a `Store` that assumes the provided directories contain plain YAML files

func ParseConfigFile Uses

func ParseConfigFile(fileBytes []byte, result *ConfigFile) error

type CommandUpdated Uses

type CommandUpdated struct {
    Generators []Generator `json:"generators"`
    Updaters   []Updater   `json:"updaters,omitempty"`
}

CommandUpdated represents a config in which updates are done by execing commands as given.

type ConfigFile Uses

type ConfigFile struct {
    Version int `json:"version"`

    // Only one of the following should be set simultaneously
    CommandUpdated *CommandUpdated `json:"commandUpdated,omitempty"`
    PatchUpdated   *PatchUpdated   `json:"patchUpdated,omitempty"`
    ScanForFiles   *ScanForFiles   `json:"scanForFiles,omitempty"`
    // contains filtered or unexported fields
}

ConfigFile holds the values necessary for generating and updating manifests according to a `.flux.yaml` file. It does double duty as the format for the file (to deserialise into), and the state necessary for running commands.

func NewConfigFile Uses

func NewConfigFile(gitPath, configPath, workingDir string) (*ConfigFile, error)

NewConfigFile constructs a ConfigFile for the relative gitPath, from the config file at the absolute path configPath, with the absolute workingDir.

func (*ConfigFile) ConfigRelativeToWorkingDir Uses

func (cf *ConfigFile) ConfigRelativeToWorkingDir() string

ConfigRelativeToWorkingDir shows the path to the config file taking the working dir as a starting point; e.g., `staging/../.flux.yaml`

func (*ConfigFile) GenerateManifests Uses

func (cf *ConfigFile) GenerateManifests(ctx context.Context, manifests Manifests) ([]byte, error)

GenerateManifests returns the manifests generated (and patched, if necessary) according to the config file.

func (*ConfigFile) IsScanForFiles Uses

func (cf *ConfigFile) IsScanForFiles() bool

IsScanForFiles returns true if the config file indicates that the directory should be treated as containing YAML files (i.e., should act as though there was no config file in operation). This can be used to reset the directive given by a .flux.yaml higher in the directory structure.

func (*ConfigFile) SetWorkloadContainerImage Uses

func (cf *ConfigFile) SetWorkloadContainerImage(ctx context.Context, manifests Manifests, r resource.Resource, container string, newImageID image.Ref) error

func (*ConfigFile) UpdateWorkloadPolicies Uses

func (cf *ConfigFile) UpdateWorkloadPolicies(ctx context.Context, manifests Manifests, r resource.Resource, update resource.PolicyUpdate) (bool, error)

UpdateWorkloadPolicies updates policies for a workload, using commands or patching according to the config file.

type ConfigFileCombinedExecResult Uses

type ConfigFileCombinedExecResult struct {
    Error  error
    Output []byte
}

type ConfigFileExecResult Uses

type ConfigFileExecResult struct {
    Error  error
    Stderr []byte
    Stdout []byte
}

type ContainerImageUpdater Uses

type ContainerImageUpdater struct {
    Command string `json:"command,omitempty"`
}

ContainerImageUpdater is a command for updating the image used by a container, in a manifest.

type Generator Uses

type Generator struct {
    Command string `json:"command,omitempty"`
}

Generator is an individual command for generating manifests.

type Manifests Uses

type Manifests interface {
    // Load all the resource manifests under the paths
    // given. `baseDir` is used to relativise the paths, which are
    // supplied as absolute paths to directories or files; at least
    // one path should be supplied, even if it is the same as `baseDir`.
    LoadManifests(baseDir string, paths []string) (map[string]resource.Resource, error)
    // ParseManifest parses the content of a collection of manifests, into resources
    ParseManifest(def []byte, source string) (map[string]resource.Resource, error)
    // Set the image of a container in a manifest's bytes to that given
    SetWorkloadContainerImage(def []byte, resourceID resource.ID, container string, newImageID image.Ref) ([]byte, error)
    // UpdateWorkloadPolicies modifies a manifest to apply the policy update specified
    UpdateWorkloadPolicies(def []byte, id resource.ID, update resource.PolicyUpdate) ([]byte, error)
    // CreateManifestPatch obtains a patch between the original and modified manifests
    CreateManifestPatch(originalManifests, modifiedManifests []byte, originalSource, modifiedSource string) ([]byte, error)
    // ApplyManifestPatch applies a manifest patch (obtained with CreateManifestPatch) returning the patched manifests
    ApplyManifestPatch(originalManifests, patchManifests []byte, originalSource, patchSource string) ([]byte, error)
    // AppendManifestToBuffer concatenates manifest bytes to a
    // (possibly empty) buffer of manifest bytes; the resulting bytes
    // should be parsable by `ParseManifest`.
    // TODO(michael) should really be an interface rather than `*bytes.Buffer`.
    AppendManifestToBuffer(manifest []byte, buffer *bytes.Buffer) error
}

Manifests represents a format for files or chunks of bytes containing definitions of resources, e.g., in Kubernetes, YAML files defining Kubernetes resources.

type PatchUpdated Uses

type PatchUpdated struct {
    Generators []Generator `json:"generators"`
    PatchFile  string      `json:"patchFile,omitempty"`
    // contains filtered or unexported fields
}

PatchUpdated represents a config in which updates are done by maintaining a patch, which is calculating from, and applied to, the generated manifests.

type PolicyUpdater Uses

type PolicyUpdater struct {
    Command string `json:"command,omitempty"`
}

PolicyUpdater is a command for updating a policy for a manifest.

type ScanForFiles Uses

type ScanForFiles struct {
}

ScanForFiles represents a config in which the directory should be treated as containing YAML files -- in other words, the normal mode which looks for YAML files, and records changes by writing them back to the original file.

This can be used as a reset switch for a `--git-path`, if there's a .flux.yaml higher in the directory structure.

type Store Uses

type Store interface {
    // Set the container image of a resource in the store
    SetWorkloadContainerImage(ctx context.Context, resourceID resource.ID, container string, newImageID image.Ref) error
    // UpdateWorkloadPolicies modifies a resource in the store to apply the policy-update specified.
    // It returns whether a change in the resource was actually made as a result of the change
    UpdateWorkloadPolicies(ctx context.Context, resourceID resource.ID, update resource.PolicyUpdate) (bool, error)
    // Load all the resources in the store. The returned map is indexed by the resource IDs
    GetAllResourcesByID(ctx context.Context) (map[string]resource.Resource, error)
}

Store manages all the cluster resources defined in a checked out repository, explicitly declared in a file or not e.g., generated and updated by a .flux.yaml file, explicit Kubernetes .yaml manifests files ...

type StoreError Uses

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

type Updater Uses

type Updater struct {
    ContainerImage ContainerImageUpdater `json:"containerImage,omitempty"`
    Policy         PolicyUpdater         `json:"policy,omitempty"`
}

Updater gives a means for updating image refs and a means for updating policy in a manifest.

Package manifests imports 16 packages (graph). Updated 2020-08-15. Refresh now. Tools for package owners.