Documentation ¶
Index ¶
- Constants
- Variables
- func ErrResourceNotFound(name string) error
- func NewConfigAware(baseDir string, targetPaths []string, manifests Manifests) (*configAware, error)
- func NewRawFiles(baseDir string, paths []string, manifests Manifests) *rawFiles
- func ParseConfigFile(fileBytes []byte, result *ConfigFile) error
- type CommandUpdated
- type ConfigFile
- func (cf *ConfigFile) ConfigRelativeToWorkingDir() string
- func (cf *ConfigFile) GenerateManifests(ctx context.Context, manifests Manifests) ([]byte, error)
- func (cf *ConfigFile) IsScanForFiles() bool
- func (cf *ConfigFile) SetWorkloadContainerImage(ctx context.Context, manifests Manifests, r resource.Resource, ...) error
- func (cf *ConfigFile) UpdateWorkloadPolicies(ctx context.Context, manifests Manifests, r resource.Resource, ...) (bool, error)
- type ConfigFileCombinedExecResult
- type ConfigFileExecResult
- type ContainerImageUpdater
- type Generator
- type Manifests
- type PatchUpdated
- type PolicyUpdater
- type ScanForFiles
- type Store
- type StoreError
- type Updater
Constants ¶
const ( ConfigFilename = ".flux.yaml" CommandTimeout = time.Minute )
Variables ¶
var ConfigSchema = mustCompileConfigSchema()
Functions ¶
func ErrResourceNotFound ¶
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 ¶
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 CommandUpdated ¶
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 ¶
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
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 (*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 ConfigFileExecResult ¶
type ContainerImageUpdater ¶
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 ¶
type Generator struct {
Command string `json:"command,omitempty"`
}
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 `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 ¶
type PolicyUpdater struct {
Command string `json:"command,omitempty"`
}
PolicyUpdater is a command for updating a policy for a manifest.
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 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.