Documentation ¶
Overview ¶
Package filesystem provides functionality to read Kubernetes objects from a filesystem tree and converting them to Nomos Custom Resource Definition objects.
Index ¶
- Constants
- Variables
- func AddController(clusterName string, mgr manager.Manager, gitDir, policyDirRelative string, ...) error
- func AsCoreObjects(fos []ast.FileObject) []client.Object
- func FilterHierarchyFiles(root cmpath.Absolute, files []cmpath.Absolute) []cmpath.Absolute
- func ValidateInstallation(dc utildiscovery.ServerResourcer) status.MultiError
- type ConfigParser
- type Parser
- func (p *Parser) Parse(filePaths reader.FilePaths) ([]ast.FileObject, status.MultiError)
- func (p *Parser) ReadClusterNamesFromSelector(filePaths reader.FilePaths) ([]string, status.MultiError)
- func (p *Parser) ReadClusterRegistryResources(filePaths reader.FilePaths, format SourceFormat) ([]ast.FileObject, status.MultiError)
- type SourceFormat
Constants ¶
const (
// GitImporterName is the name of the git-importer Deployment.
GitImporterName = "git-importer"
)
const SourceFormatKey = "SOURCE_FORMAT"
SourceFormatKey is the OS env variable and ConfigMap key for the SOT repository format.
Variables ¶
var WalkDirectory = walkDirectory
WalkDirectory exported for testing.
Functions ¶
func AddController ¶
func AddController(clusterName string, mgr manager.Manager, gitDir, policyDirRelative string, pollPeriod time.Duration) error
AddController adds the git-importer controller to the manager.
func AsCoreObjects ¶
func AsCoreObjects(fos []ast.FileObject) []client.Object
AsCoreObjects converts a slice of FileObjects to a slice of client.Objects.
func FilterHierarchyFiles ¶
FilterHierarchyFiles filters out files that aren't in a top-level directory we care about. root and files are all absolute paths.
func ValidateInstallation ¶
func ValidateInstallation(dc utildiscovery.ServerResourcer) status.MultiError
ValidateInstallation checks to see if Nomos is installed on a server, given a client that returns a CachedDiscoveryInterface. TODO: Server-side validation for this check.
Types ¶
type ConfigParser ¶
type ConfigParser interface { Parse(filePaths reader.FilePaths) ([]ast.FileObject, status.MultiError) // ReadClusterRegistryResources returns the list of Clusters contained in the repo. ReadClusterRegistryResources(filePaths reader.FilePaths, sourceFormat SourceFormat) ([]ast.FileObject, status.MultiError) // ReadClusterNamesFromSelector returns the list of cluster names specified in // the `cluster-name-selector` annotation. ReadClusterNamesFromSelector(filePaths reader.FilePaths) ([]string, status.MultiError) }
ConfigParser defines the minimum interface required for Reconciler to use a Parser to read configs from a filesystem.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser reads files on disk and builds Nomos Config objects to be reconciled by the Syncer.
func (*Parser) Parse ¶
func (p *Parser) Parse(filePaths reader.FilePaths) ([]ast.FileObject, status.MultiError)
Parse parses file tree rooted at root and builds policy CRDs from supported Kubernetes policy resources. Resources are read from the following directories:
clusterName is the spec.clusterName of the cluster's ConfigManagement. enableAPIServerChecks, if true, contacts the API Server if it is unable to
determine whether types are namespace- or cluster-scoped.
getSyncedCRDs is a callback that returns the CRDs on the API Server. filePaths is the list of absolute file paths to parse and the absolute and
relative paths of the Nomos root.
It is an error for any files not to be present.
func (*Parser) ReadClusterNamesFromSelector ¶
func (p *Parser) ReadClusterNamesFromSelector(filePaths reader.FilePaths) ([]string, status.MultiError)
ReadClusterNamesFromSelector returns the list of cluster names specified in the `cluster-name-selector` annotation.
func (*Parser) ReadClusterRegistryResources ¶
func (p *Parser) ReadClusterRegistryResources(filePaths reader.FilePaths, format SourceFormat) ([]ast.FileObject, status.MultiError)
ReadClusterRegistryResources reads the manifests declared in clusterregistry/ for hierarchical format. For unstructured format, it reads all files.
type SourceFormat ¶
type SourceFormat string
SourceFormat specifies how the Importer should parse the repository.
const SourceFormatHierarchy SourceFormat = "hierarchy"
SourceFormatHierarchy says to use hierarchical namespace inheritance based on directory structure and requires that manifests be declared in specific subdirectories.
const SourceFormatUnstructured SourceFormat = "unstructured"
SourceFormatUnstructured says to parse all YAMLs in the config directory and ignore directory structure.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package cmpath is a library dedicated specifically to handling paths in a Nomos repository in a type safe way.
|
Package cmpath is a library dedicated specifically to handling paths in a Nomos repository in a type safe way. |