packages

package
v1.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

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

View Source
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

View Source
var (
	PackageManifestLockGroupKind = schema.GroupKind{Group: manifestsv1alpha1.GroupVersion.Group, Kind: "PackageManifestLock"}
	PackageManifestGroupKind     = schema.GroupKind{Group: manifestsv1alpha1.GroupVersion.Group, Kind: "PackageManifest"}
)
View Source
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

func AddPathPrefix(path string) string

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

func Index(i int) *int

Index creates a *int from the given int parameter to be used in ViolationError.

func IsManifestFile

func IsManifestFile(fileName string) bool

IsManifestFile returns true if the given file name is considered a package manifest.

func IsManifestLockFile

func IsManifestLockFile(fileName string) bool

IsManifestFile returns true if the given file name is considered a package manifest lock file.

func IsTemplateFile

func IsTemplateFile(path string) bool

Is path suffixed by [TemplateFileSuffix].

func IsYAMLFile

func IsYAMLFile(fileName string) bool

IsYAMLFile return true if the given fileName is suffixed by .yml or .yaml.

func StripPathPrefix added in v1.8.4

func StripPathPrefix(path string) (string, error)

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

func StripTemplateSuffix(path string) string

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL