manifests

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func ErrResourceNotFound

func ErrResourceNotFound(name string) error

func NewConfigAware

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

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

Types

type CommandUpdated

type CommandUpdated struct {
	Generators []Generator
	Updaters   []Updater
}

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

type ConfigFile

type ConfigFile struct {
	Version int
	// Only one of the following should be set simultaneously
	CommandUpdated *CommandUpdated `yaml:"commandUpdated"`
	PatchUpdated   *PatchUpdated   `yaml:"patchUpdated"`
	// 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

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 added in v1.16.0

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 added in v1.16.0

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) SetWorkloadContainerImage added in v1.16.0

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

func (*ConfigFile) UpdateWorkloadPolicies added in v1.16.0

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

type ConfigFileCombinedExecResult struct {
	Error  error
	Output []byte
}

type ConfigFileExecResult

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

type ContainerImageUpdater

type ContainerImageUpdater struct {
	Command string
}

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

type Generator

type Generator struct {
	Command string
}

Generator is an individual command for generating manifests.

type Manifests

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

type PatchUpdated struct {
	Generators []Generator
	PatchFile  string `yaml:"patchFile"`
}

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

type PolicyUpdater struct {
	Command string
}

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

type Store

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

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

type Updater

type Updater struct {
	ContainerImage ContainerImageUpdater `yaml:"containerImage"`
	Policy         PolicyUpdater
}

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

Jump to

Keyboard shortcuts

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