manifests

package
v1.25.4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFilename = ".flux.yaml"
)

Variables

View Source
var ConfigSchema = mustCompileConfigSchema()

Functions

func ErrResourceNotFound

func ErrResourceNotFound(name string) error

func NewConfigAware

func NewConfigAware(baseDir string, targetPaths []string, manifests Manifests, syncTimeout time.Duration) (*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

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

func ParseConfigFile added in v1.18.0

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

Types

type Command added in v1.21.1

type Command struct {
	Command string           `json:"command,omitempty"`
	Timeout *metav1.Duration `json:"timeout,omitempty"`
}

Command is an individual command and timeout for generating manifests.

type CommandUpdated

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

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

type ConfigFile

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

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, defaultTimeout time.Duration) ([]byte, error)

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

func (*ConfigFile) IsScanForFiles added in v1.18.0

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

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

func (*ConfigFile) UpdateWorkloadPolicies added in v1.16.0

func (cf *ConfigFile) UpdateWorkloadPolicies(ctx context.Context, manifests Manifests, r resource.Resource, update resource.PolicyUpdate, defaultTimeout time.Duration) (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 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 []Command `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 ScanForFiles added in v1.18.0

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

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 Command `json:"containerImage,omitempty"`
	Policy         Command `json:"policy,omitempty"`
}

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