Documentation
¶
Index ¶
- Constants
- func Clean(objects []ast.FileObject)
- func ComputeCommit(sourceDir cmpath.Absolute) (string, error)
- func DoneCommit(donePath string) string
- func ForEachCluster(ctx context.Context, parseOpts ParseOptions, validateOpts validate.Options, ...)
- func GenerateFileObjects(multiCluster bool, objects ...ast.FileObject) []ast.FileObject
- func HasKustomization(filename string) bool
- func PrintDirectoryOutput(output, extension string, fileObjects []ast.FileObject) error
- func PrintFile(file, extension string, objects []*unstructured.Unstructured) (err error)
- func PrintFlatOutput(output, extension string, fileObjects []ast.FileObject) error
- func SourceCommitAndDir(sourceType configsync.SourceType, sourceRevDir cmpath.Absolute, ...) (string, cmpath.Absolute, error)
- func SourceCommitAndDirWithRetry(backoff wait.Backoff, sourceType configsync.SourceType, ...) (commit string, sourceDir cmpath.Absolute, _ status.Error)
- func ValidateAndRunKustomize(sourcePath string) (cmpath.Absolute, error)
- func ValidateHydrateFlags(sourceFormat configsync.SourceFormat) (cmpath.Absolute, bool, error)
- func ValidateOptions(ctx context.Context, rootDir cmpath.Absolute, apiServerTimeout time.Duration) (validate.Options, error)
- type ActionableError
- type ClusterFilterFunc
- type HydrationError
- type HydrationErrorPayload
- type Hydrator
- type InternalError
- type ParseOptions
- type TransientError
Constants ¶
const ( // DoneFile is the file name that indicates the hydration is done. DoneFile = "done" // ErrorFile is the file name of the hydration errors. ErrorFile = "error.json" )
const ( // HelmVersion is the recommended version of Helm for hydration. HelmVersion = "v3.15.3-gke.2" // KustomizeVersion is the recommended version of Kustomize for hydration. KustomizeVersion = "v5.4.2-gke.0" // Helm is the binary name of the installed Helm. Helm = "helm" // Kustomize is the binary name of the installed Kustomize. Kustomize = "kustomize" )
Variables ¶
This section is empty.
Functions ¶
func Clean ¶
func Clean(objects []ast.FileObject)
Clean removes invalid fields from objects before writing them to a file.
func ComputeCommit ¶ added in v1.15.1
ComputeCommit returns the computed commit from given sourceDir, or error if the sourceDir fails symbolic link evaluation
func DoneCommit ¶
DoneCommit extracts the commit hash from the done file if exists. It returns the commit hash if exists, otherwise, returns an empty string. If it fails to extract the commit hash for various errors, we only log a warning, and wait for the next hydration loop to retry the hydration.
func ForEachCluster ¶
func ForEachCluster(ctx context.Context, parseOpts ParseOptions, validateOpts validate.Options, f ClusterFilterFunc)
ForEachCluster hydrates an AllConfigs for each declared cluster and executes the passed function on the result.
parser is the ConfigParser which returns a set of FileObjects and a possible MultiError when Parse is called.
getSyncedCRDs is the set of CRDs synced the the cluster used for APIServer checks. enableAPIServerChecks is whether to call Parse with APIServer checks enabled. apiResources is how to read cached API resources from the disk. filePaths is the list of absolute file paths to parse and the absolute and relative paths of the Nomos root.
f is a function with three arguments: - clusterName, the name of the Cluster the Parser was called with. - fileObjects, the FileObjects which Parser.Parse returned. - err, the MultiError which Parser.Parse returned, if there was one.
Per standard ForEach conventions, ForEachCluster has no return value.
func GenerateFileObjects ¶
func GenerateFileObjects(multiCluster bool, objects ...ast.FileObject) []ast.FileObject
GenerateFileObjects returns a set of file objects with unique file names and invalid fields removed from objects.
func HasKustomization ¶ added in v1.16.0
HasKustomization checks if the file is a Kustomize configuration file.
func PrintDirectoryOutput ¶
func PrintDirectoryOutput(output, extension string, fileObjects []ast.FileObject) error
PrintDirectoryOutput prints the hydrated output to multiple files in a directory.
func PrintFile ¶
func PrintFile(file, extension string, objects []*unstructured.Unstructured) (err error)
PrintFile prints the passed objects to file.
func PrintFlatOutput ¶
func PrintFlatOutput(output, extension string, fileObjects []ast.FileObject) error
PrintFlatOutput prints the hydrated output to a single file.
func SourceCommitAndDir ¶
func SourceCommitAndDir(sourceType configsync.SourceType, sourceRevDir cmpath.Absolute, syncDir cmpath.Relative, reconcilerName string) (string, cmpath.Absolute, error)
SourceCommitAndDir returns the source hash (a git commit hash or an OCI image digest or a helm chart version), the absolute path of the sync directory, and source errors.
func SourceCommitAndDirWithRetry ¶ added in v1.16.2
func SourceCommitAndDirWithRetry(backoff wait.Backoff, sourceType configsync.SourceType, sourceRevDir cmpath.Absolute, syncDir cmpath.Relative, reconcilerName string) (commit string, sourceDir cmpath.Absolute, _ status.Error)
SourceCommitAndDirWithRetry returns the source hash (a git commit hash or an OCI image digest or a helm chart version), the absolute path of the sync directory, and source errors. It retries with the provided backoff.
func ValidateAndRunKustomize ¶
ValidateAndRunKustomize validates if the Kustomize and Helm binaries are supported. If supported, it copies the source configs to a temp directory, run 'kustomize build', save the output to another temp directory, and return the output path for further parsing and validation.
func ValidateHydrateFlags ¶
func ValidateHydrateFlags(sourceFormat configsync.SourceFormat) (cmpath.Absolute, bool, error)
ValidateHydrateFlags validates the hydrate and vet flags. It returns the absolute path of the source directory, if hydration is needed, and errors.
Types ¶
type ActionableError ¶
type ActionableError struct {
// contains filtered or unexported fields
}
ActionableError represents the user actionable hydration error.
func NewActionableError ¶
func NewActionableError(e error) ActionableError
NewActionableError returns the wrapper of the user actionable error.
func (ActionableError) Code ¶
func (e ActionableError) Code() string
Code returns the user actionable error code.
type ClusterFilterFunc ¶ added in v1.17.0
type ClusterFilterFunc func(clusterName string, fileObjects []ast.FileObject, err status.MultiError)
ClusterFilterFunc is the type alias for the function that filters objects for selected clusters.
type HydrationError ¶
type HydrationError interface { // Code is the error code to indicate if it is a user error or an internal error. Code() string error }
HydrationError is a wrapper of the error in the hydration process with the error code.
type HydrationErrorPayload ¶
type HydrationErrorPayload struct { // Code is the error code to indicate if it is a user error or an internal error. Code string // Error is the message of the hydration error. Error string }
HydrationErrorPayload is the payload of the hydration error in the error file.
type Hydrator ¶
type Hydrator struct { // DonePath is the absolute path to the done file under the /repo directory. DonePath cmpath.Absolute // SourceType is the type of the source repository, must be git or oci. SourceType configsync.SourceType // SourceRoot is the absolute path to the source root directory. SourceRoot cmpath.Absolute // HydratedRoot is the absolute path to the hydrated root directory. HydratedRoot cmpath.Absolute // SourceLink is the name of (a symlink to) the source directory under SourceRoot, which contains the clone of the git repo. SourceLink string // HydratedLink is the name of (a symlink to) the source directory under HydratedRoot, which contains the hydrated configs. HydratedLink string // SyncDir is the relative path to the configs within the Git repository. SyncDir cmpath.Relative // PollingPeriod is the period of time between checking the filesystem for source updates to render. PollingPeriod time.Duration // RehydratePeriod is the period of time between rehydrating on errors. RehydratePeriod time.Duration // ReconcilerName is the name of the reconciler. ReconcilerName string }
Hydrator runs the hydration process.
type InternalError ¶
type InternalError struct {
// contains filtered or unexported fields
}
InternalError represents the internal hydration error.
func NewInternalError ¶
func NewInternalError(e error) InternalError
NewInternalError returns the wrapper of the internal error.
func (InternalError) Code ¶
func (e InternalError) Code() string
Code returns the internal error code.
type ParseOptions ¶ added in v1.17.0
type ParseOptions struct { // Parser is an interface to read configs from a filesystem. Parser filesystem.ConfigParser // SourceFormat specifies how the Parser should parse the source configs. SourceFormat configsync.SourceFormat // FilePaths encapsulates the list of absolute file paths to read and the // absolute and relative path of the root directory. FilePaths reader.FilePaths }
ParseOptions includes information needed by the parsing step in nomos CLI. It is different from pkg/parse/opts.go used in the reconciler container on the server side.
type TransientError ¶ added in v1.15.1
type TransientError struct {
// contains filtered or unexported fields
}
TransientError represents the transient error that will be autoresolved in the retry.
func NewTransientError ¶ added in v1.15.1
func NewTransientError(e error) TransientError
NewTransientError returns the wrapper of the transient error.
func (TransientError) Code ¶ added in v1.15.1
func (e TransientError) Code() string
Code returns the transient error code.