manifests

package
v0.0.0-...-5272525 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: Apache-2.0 Imports: 16 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)

func NewRawFiles

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

Types

type CommandUpdated

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

type ConfigFile

type ConfigFile struct {
	Path       string
	WorkingDir string
	Version    int
	// Only one of the following should be set simultaneously
	CommandUpdated *CommandUpdated `yaml:"commandUpdated"`
	PatchUpdated   *PatchUpdated   `yaml:"patchUpdated"`
}

func NewConfigFile

func NewConfigFile(path, workingDir string) (*ConfigFile, error)

func (*ConfigFile) ExecContainerImageUpdaters

func (cf *ConfigFile) ExecContainerImageUpdaters(ctx context.Context,
	workload resource.ID, container string, image, imageTag string) []ConfigFileCombinedExecResult

ExecContainerImageUpdaters executes all the image updates in the configuration file. It will stop at the first error, in which case the returned error will be non-nil

func (*ConfigFile) ExecGenerators

func (cf *ConfigFile) ExecGenerators(ctx context.Context, generators []Generator) []ConfigFileExecResult

func (*ConfigFile) ExecPolicyUpdaters

func (cf *ConfigFile) ExecPolicyUpdaters(ctx context.Context,
	workload resource.ID, policyName, policyValue string) []ConfigFileCombinedExecResult

ExecPolicyUpdaters executes all the policy update commands given in the configuration file. An empty policyValue means remove the policy. It will stop at the first error, in which case the returned error will be non-nil

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
}

type Generator

type Generator struct {
	Command string
}

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 CreateManifestDiff) returned 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"`
}

type PolicyUpdater

type PolicyUpdater struct {
	Command string
}

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
}

Jump to

Keyboard shortcuts

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