Documentation ¶
Overview ¶
Package packages contains common definitiond and helper methods that are required by sub packages which are responsible for handling PKO packages and package images.
Index ¶
- Constants
- Variables
- func AddPathPrefix(path string) string
- func Index(i int) *int
- func IsManifestFile(fileName string) bool
- func IsManifestLockFile(fileName string) bool
- func IsTemplateFile(path string) bool
- func IsYAMLFile(fileName string) bool
- func StripPathPrefix(path string) (string, error)
- func StripTemplateSuffix(path string) string
- type ViolationError
- type ViolationReason
Constants ¶
const ( // Default location for the manifest of a package file. PackageManifestFilename = "manifest.yaml" // Default location for the package lock file. PackageManifestLockFilename = "manifest.lock.yaml" )
Variables ¶
var ( PackageManifestLockGroupKind = schema.GroupKind{Group: manifestsv1alpha1.GroupVersion.Group, Kind: "PackageManifestLock"} PackageManifestGroupKind = schema.GroupKind{Group: manifestsv1alpha1.GroupVersion.Group, Kind: "PackageManifest"} )
var ErrManifestNotFound = ViolationError{ Reason: ViolationReasonPackageManifestNotFound, Details: fmt.Sprintf("searched at %s and manifest.yml", PackageManifestFilename), }
ErrManifestNotFound indicates that a package manifest was not found at any expected location.
Functions ¶
func AddPathPrefix ¶ added in v1.8.4
AddPathPrefix adds the path that is prefixed to packed package image files.
This is done the prevent clutter in the top level directory of images and to avoid confusion.
func Index ¶ added in v1.8.4
Index creates a *int from the given int parameter to be used in ViolationError.
func IsManifestFile ¶
IsManifestFile returns true if the given file name is considered a package manifest.
func IsManifestLockFile ¶
IsManifestFile returns true if the given file name is considered a package manifest lock file.
func IsTemplateFile ¶
Is path suffixed by [TemplateFileSuffix].
func IsYAMLFile ¶
IsYAMLFile return true if the given fileName is suffixed by .yml or .yaml.
func StripPathPrefix ¶ added in v1.8.4
StripPathPrefix removes the path that is prefixed to packed package image files.
This is done the prevent clutter in the top level directory of images and to avoid confusion.
func StripTemplateSuffix ¶
StripTemplateSuffix removes a [TemplateFileSuffix] suffix from a string if present.
Types ¶
type ViolationError ¶ added in v1.8.4
type ViolationError struct { Reason ViolationReason // Reason is a [ViolationReason] which shortly describes what the reason of this error is. Details string // Details describes the violation and what to do against it in a more verbose matter. Path string // Path shows which file path in the package is responsible for this error. Component string // Component indicates which component the error is associated with Index *int // Index is the index of the YAML document within Path. }
ViolationError describes the reason why and which part of a package is violating sanitation checks.
func (ViolationError) Error ¶ added in v1.8.4
func (v ViolationError) Error() string
type ViolationReason ¶ added in v1.8.4
type ViolationReason string
ViolationReason describes in short how something violates violating sanitation checks.
const ( ViolationReasonPackageManifestNotFound ViolationReason = "PackageManifest not found" ViolationReasonPackageManifestUnknownGVK ViolationReason = "PackageManifest unknown GVK" ViolationReasonPackageManifestConversion ViolationReason = "PackageManifest conversion" ViolationReasonPackageManifestInvalid ViolationReason = "PackageManifest invalid" ViolationReasonPackageManifestDuplicated ViolationReason = "PackageManifest present multiple times" ViolationReasonPackageManifestLockUnknownGVK ViolationReason = "PackageManifestLock unknown GVK" ViolationReasonPackageManifestLockConversion ViolationReason = "PackageManifestLock conversion" ViolationReasonPackageManifestLockInvalid ViolationReason = "PackageManifestLock invalid" ViolationReasonPackageManifestLockDuplicated ViolationReason = "PackageManifestLock present multiple times" ViolationReasonInvalidYAML ViolationReason = "Invalid YAML" ViolationReasonMissingPhaseAnnotation ViolationReason = "Missing " + manifestsv1alpha1.PackagePhaseAnnotation + " Annotation" ViolationReasonMissingGVK ViolationReason = "GroupVersionKind not set" ViolationReasonDuplicateObject ViolationReason = "Duplicate Object" ViolationReasonLabelsInvalid ViolationReason = "Labels invalid" ViolationReasonUnsupportedScope ViolationReason = "Package unsupported scope" ViolationReasonFixtureMismatch ViolationReason = "File mismatch against fixture" ViolationReasonComponentsNotEnabled ViolationReason = "Components not enabled" ViolationReasonComponentNotFound ViolationReason = "Component not found" ViolationReasonInvalidComponentPath ViolationReason = "Invalid component path" ViolationReasonUnknown ViolationReason = "Unknown reason" ViolationReasonNestedMultiComponentPkg ViolationReason = "Nesting multi-component packages not allowed" ViolationReasonInvalidFileInComponentsDir ViolationReason = "The components directory may only contain folders and dot files" )
Predefined reasons for package violations.