Documentation
¶
Index ¶
- Constants
- Variables
- func BuildResource(tmpl *apix.JSON, inputSet map[string]any) (*unstructured.Unstructured, error)
- func BuildResourceSet(yamlTemplate string, templates []*apix.JSON, combinedInputs inputs.Combined) ([]*unstructured.Unstructured, error)
- func BuildResourcesFromYAML(yamlTemplate string, inputSet map[string]any) ([]*unstructured.Unstructured, error)
- func CheckMinimumVersion(fluxVersion, minimumVersion string) error
- func ExtractVersionDigest(input string) (string, string, error)
- func FlattenSteps(steps []StepBuildResult) []*unstructured.Unstructured
- func GetArtifactDigest(ctx context.Context, ociURL string, keyChain authn.Keychain) (string, error)
- func GetProfileClusterSize(size string) string
- func GetProfileClusterType(clusterType string) string
- func GetProfileMultitenant(defaultSA string) string
- func GetProfileMultitenantWorkloadIdentity(cluster fluxcdv1.Cluster) string
- func GetProfileObjectLevelWorkloadIdentity(controllers []string, enabled bool) string
- func IsCompatibleVersion(fromVer, toVer string) error
- func IsMinorUpgrade(fromVer, toVer string) (bool, error)
- func MatchVersion(dataDir, semverRange string) (string, error)
- func MatchVersionWithEmbedded(dataDir, embeddedDataDir, semverRange string) (string, error)
- func MkdirTempAbs(dir, pattern string) (string, error)
- func PullArtifact(ctx context.Context, ociURL, dstDir string, keyChain authn.Keychain) (string, error)
- func ValidateResourceSetSpec(spec fluxcdv1.ResourceSetSpec) error
- type ArtifactStorage
- type ComponentImage
- func ExtractComponentImages(srcDir string, opts Options) ([]ComponentImage, error)
- func ExtractComponentImagesFromObjects(objects []*unstructured.Unstructured, opts Options) ([]ComponentImage, error)
- func ExtractComponentImagesWithDigest(srcDir string, opts Options) (images []ComponentImage, err error)
- type Options
- type Result
- type StepBuildResult
- type Sync
- type VersionInfo
Constants ¶
const ( UpstreamAlpine string = "upstream-alpine" EnterpriseAlpine string = "enterprise-alpine" EnterpriseDistroless string = "enterprise-distroless" EnterpriseDistrolessFIPS string = "enterprise-distroless-fips" )
Variables ¶
var AllComponents = append(DefaultComponents,
"image-reflector-controller",
"image-automation-controller",
"source-watcher",
)
AllComponents defines all available Flux 2.7+ controllers.
var DefaultComponents = []string{
"source-controller",
"kustomize-controller",
"helm-controller",
"notification-controller",
}
DefaultComponents defines the default set of Flux controllers.
Functions ¶
func BuildResource ¶ added in v0.14.0
func BuildResource(tmpl *apix.JSON, inputSet map[string]any) (*unstructured.Unstructured, error)
BuildResource builds a Kubernetes resource from a JSON template using the provided inputs. Template functions are provided by the slim-sprig library https://go-task.github.io/slim-sprig/. In addition, the slugify function is available to generate slugs from strings using https://github.com/gosimple/slug/. And for readability, a toYaml function is available to encode an input value into a YAML string.
func BuildResourceSet ¶ added in v0.14.0
func BuildResourceSet(yamlTemplate string, templates []*apix.JSON, combinedInputs inputs.Combined) ([]*unstructured.Unstructured, error)
BuildResourceSet builds a list of Kubernetes resources from a YAML template, a list of JSON templates and the given combined inputs. The resulting objects are deduplicated by apiVersion, kind, namespace and name, with the objects built from the JSON templates taking precedence over the ones built from the YAML template.
func BuildResourcesFromYAML ¶ added in v0.14.0
func BuildResourcesFromYAML(yamlTemplate string, inputSet map[string]any) ([]*unstructured.Unstructured, error)
BuildResourcesFromYAML builds a list of Kubernetes resources from a multi-doc YAML template using the same templating functions as BuildResource.
func CheckMinimumVersion ¶ added in v0.28.0
CheckMinimumVersion checks if the given Flux version is greater than or equal to the minimum required version.
func ExtractVersionDigest ¶ added in v0.28.0
ExtractVersionDigest extracts the version and digest from the given string. The input string is expected to be in one of the following formats: - "proto://host:port/org/app:vX.Y.Z@sha256:hex" - "host:port/org/app:vX.Y.Z@sha256:hex" - "host/org/app:vX.Y.Z" - "vX.Y.Z-RC.N@sha256:hex" - "vX.Y.Z" This function returns the version and optionally the digest as separate strings. An error is returned if the input string does not conform to the expected patterns.
func FlattenSteps ¶ added in v0.53.0
func FlattenSteps(steps []StepBuildResult) []*unstructured.Unstructured
FlattenSteps returns the objects of all the given steps as a single slice, preserving the step order. The flattened slice shares the object pointers with the step slices, so in-place metadata mutations performed on the flattened objects are visible per step.
func GetArtifactDigest ¶ added in v0.12.0
GetArtifactDigest looks up an artifact from an OCI repository and returns the digest of the artifact.
func GetProfileClusterSize ¶ added in v0.27.0
GetProfileClusterSize returns a patch that configures the Flux controllers for a specific cluster size.
func GetProfileClusterType ¶ added in v0.27.0
GetProfileClusterType returns a patch that configures the Flux controllers for a specific Kubernetes distribution.
func GetProfileMultitenant ¶ added in v0.27.0
GetProfileMultitenant returns a patch to enable multitenancy in the Flux controllers.
func GetProfileMultitenantWorkloadIdentity ¶ added in v0.29.0
GetProfileMultitenantWorkloadIdentity returns a patch to enable multitenant workload identity in the Flux controllers through the feature gate.
func GetProfileObjectLevelWorkloadIdentity ¶ added in v0.29.0
GetProfileObjectLevelWorkloadIdentity returns a patch to enable object level workload identity in the Flux controllers through the feature gate.
func IsCompatibleVersion ¶
IsCompatibleVersion checks if the version upgrade is compatible. It returns an error if a downgrade to a lower minor version is attempted.
func IsMinorUpgrade ¶ added in v0.31.0
IsMinorUpgrade checks if the version upgrade is a minor version upgrade. It returns true if the major version is the same and the minor version is greater.
func MatchVersion ¶
MatchVersion returns the latest version dir path that matches the given semver range.
func MatchVersionWithEmbedded ¶ added in v0.54.0
MatchVersionWithEmbedded returns the latest version dir that matches the given semver range and belongs to a Flux minor version present in the embedded version directory bundled with the running operator image.
func MkdirTempAbs ¶
MkdirTempAbs creates a tmp dir and returns the absolute path to the dir. This is required since certain OSes like MacOS create temporary files in e.g. `/private/var`, to which `/var` is a symlink.
func PullArtifact ¶ added in v0.5.0
func PullArtifact(ctx context.Context, ociURL, dstDir string, keyChain authn.Keychain) (string, error)
PullArtifact downloads an artifact from an OCI repository and extracts the content of the first tgz layer to the given destination directory. It returns the digest of the artifact.
func ValidateResourceSetSpec ¶ added in v0.53.0
func ValidateResourceSetSpec(spec fluxcdv1.ResourceSetSpec) error
ValidateResourceSetSpec validates that steps are not set together with resources or resourcesTemplate, and that each step sets at least one of resources or resourcesTemplate. The rules mirror the CRD CEL rules on api/v1 ResourceSetSpec and ResourceSetStep, enforcing them for offline builds (CLI) and for clusters running a CRD version without the rules. The validation is render-independent so that callers can reject an invalid spec even when no resources are built, e.g. when the input providers return no inputs.
Types ¶
type ArtifactStorage ¶ added in v0.2.0
ArtifactStorage represents the source-controller PVC.
type ComponentImage ¶ added in v0.1.0
ComponentImage represents a container image used by a component.
func ExtractComponentImages ¶ added in v0.1.0
func ExtractComponentImages(srcDir string, opts Options) ([]ComponentImage, error)
ExtractComponentImages reads the source directory and extracts the container images from the components manifests.
func ExtractComponentImagesFromObjects ¶ added in v0.28.0
func ExtractComponentImagesFromObjects(objects []*unstructured.Unstructured, opts Options) ([]ComponentImage, error)
ExtractComponentImagesFromObjects extracts the container images from the Deployment objects in the provided slice of unstructured objects. It returns a slice of ComponentImage containing the component name, repository, tag and digest (if available).
func ExtractComponentImagesWithDigest ¶ added in v0.5.0
func ExtractComponentImagesWithDigest(srcDir string, opts Options) (images []ComponentImage, err error)
ExtractComponentImagesWithDigest reads the source directory and extracts the container images with digest from the kustomize images patches.
type Options ¶
type Options struct {
Version string
VersionInfo *VersionInfo
Namespace string
Components []string
ComponentImages []ComponentImage
EventsAddr string
Registry string
Variant string
ImagePullSecret string
WatchAllNamespaces bool
NetworkPolicy bool
LogLevel string
ClusterDomain string
TolerationKeys []string
Patches string
ArtifactStorage *ArtifactStorage
Sync *Sync
ShardingKey string
ShardingStorage bool
Shards []string
ShardName string
SourceAPIVersion string
RemovePermissionForCreatingServiceAccountTokens bool
}
Options defines the builder configuration.
func MakeDefaultOptions ¶
func MakeDefaultOptions() Options
MakeDefaultOptions returns the default builder configuration.
func (*Options) HasNotificationController ¶ added in v0.19.0
HasNotificationController returns true if the notification-controller is included in the selected components.
func (*Options) HasSourceWatcher ¶ added in v0.30.0
HasSourceWatcher returns true if the source-watcher is included in the selected components.
func (*Options) ValidateAndApplyWorkloadIdentityConfig ¶ added in v0.29.0
ValidateAndApplyWorkloadIdentityConfig validates and applies the workload identity options based on the provided cluster configuration and Flux version in the Options struct.
func (*Options) ValidateAndPatchComponents ¶ added in v0.30.0
ValidateAndPatchComponents verifies that the selected components are valid and compatible with the specified Flux version. It also appends a patch to include the Flux Operator CRDs in the notification-controller configuration.
func (*Options) ValidateSync ¶ added in v0.49.0
ValidateSync validates the sync options against the Flux version in the Options struct, returning an error when the configuration is not supported.
type Result ¶
type Result struct {
Version string
Digest string
Revision string
Objects []*unstructured.Unstructured
ComponentImages []ComponentImage
}
Result holds the build result.
type StepBuildResult ¶ added in v0.53.0
type StepBuildResult struct {
// Name is the name of the step.
Name string
// Timeout is the health check timeout of the step, nil when
// the step does not override the ResourceSet timeout.
Timeout *metav1.Duration
// Objects contains the Kubernetes resources built for the step.
Objects []*unstructured.Unstructured
}
StepBuildResult holds the objects built for a single ResourceSet step.
func BuildResourceSetFromSpec ¶ added in v0.53.0
func BuildResourceSetFromSpec(spec fluxcdv1.ResourceSetSpec, combinedInputs inputs.Combined) ([]StepBuildResult, error)
BuildResourceSetFromSpec validates the given ResourceSet spec with ValidateResourceSetSpec and builds its resources using the combined inputs. When steps are set, the resources are built per step with BuildResourceSetSteps, otherwise the spec resources are built with BuildResourceSet and wrapped as a single anonymous step.
func BuildResourceSetSteps ¶ added in v0.53.0
func BuildResourceSetSteps(steps []fluxcdv1.ResourceSetStep, combinedInputs inputs.Combined) ([]StepBuildResult, error)
BuildResourceSetSteps builds the Kubernetes resources of each step using BuildResourceSet and the given combined inputs. The results preserve the order of the steps, including steps that build zero objects. A resource defined in multiple steps results in an error, while duplicates within a step follow the BuildResourceSet semantics. The step fields are expected to have been validated upfront with ValidateResourceSetSpec.
func (StepBuildResult) IsAnonymous ¶ added in v0.53.0
func (s StepBuildResult) IsAnonymous() bool
IsAnonymous returns true when the result is the single unnamed step wrapping the resources of a steps-less ResourceSet, in which case the step must not surface in user-facing messages to keep the steps-less behavior identical to the pre-steps releases.