bundle

package
v2.0.0-...-f0a61fb Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPermission   = 0644
	RegistryV1Type      = "registry+v1"
	PlainType           = "plain"
	HelmType            = "helm"
	AnnotationsFile     = "annotations.yaml"
	DockerFile          = "bundle.Dockerfile"
	ManifestsDir        = "manifests/"
	MetadataDir         = "metadata/"
	ManifestsLabel      = "operators.operatorframework.io.bundle.manifests.v1"
	MetadataLabel       = "operators.operatorframework.io.bundle.metadata.v1"
	MediatypeLabel      = "operators.operatorframework.io.bundle.mediatype.v1"
	PackageLabel        = "operators.operatorframework.io.bundle.package.v1"
	ChannelsLabel       = "operators.operatorframework.io.bundle.channels.v1"
	ChannelDefaultLabel = "operators.operatorframework.io.bundle.channel.default.v1"
)
View Source
const (
	CSVKind                   = "ClusterServiceVersion"
	CRDKind                   = "CustomResourceDefinition"
	SecretKind                = "Secret"
	ClusterRoleKind           = "ClusterRole"
	ClusterRoleBindingKind    = "ClusterRoleBinding"
	ConfigMapKind             = "ConfigMap"
	ServiceAccountKind        = "ServiceAccount"
	ServiceKind               = "Service"
	RoleKind                  = "Role"
	RoleBindingKind           = "RoleBinding"
	PrometheusRuleKind        = "PrometheusRule"
	ServiceMonitorKind        = "ServiceMonitor"
	PodDisruptionBudgetKind   = "PodDisruptionBudget"
	PriorityClassKind         = "PriorityClass"
	VerticalPodAutoscalerKind = "VerticalPodAutoscaler"
	ConsoleYAMLSampleKind     = "ConsoleYAMLSample"
	ConsoleQuickStartKind     = "ConsoleQuickStart"
	ConsoleCLIDownloadKind    = "ConsoleCLIDownload"
	ConsoleLinkKind           = "ConsoleLink"
)

Variables

This section is empty.

Functions

func BuildBundleImage

func BuildBundleImage(imageTag, imageBuilder string) (*exec.Cmd, error)

Create build command to build bundle manifests image

func BuildFunc

func BuildFunc(directory, outputDir, imageTag, imageBuilder, packageName, channels, channelDefault string,
	overwrite bool) error

BuildFunc is used to build bundle container image from a list of manifests that exist in local directory and it also generates Dockerfile annotations.yaml which contains media type, package name and channels information if the file doesn't exist locally. Inputs: @directory: The local directory where bundle manifests and metadata are located @imageTag: The image tag that is applied to the bundle image @imageBuilder: The image builder tool that is used to build container image (docker, buildah or podman) @packageName: The name of the package that bundle image belongs to @channels: The list of channels that bundle image belongs to @channelDefault: The default channel for the bundle image @overwrite: Boolean flag to enable overwriting annotations.yaml locally if existed

func CopyYamlOutput

func CopyYamlOutput(annotationsContent []byte, manifestDir, outputDir, workingDir string, overwrite bool) (resultManifests, resultMetadata string, err error)

CopyYamlOutput takes the generated annotations yaml and writes it to disk. If an outputDir is specified, it will copy the input manifests It returns two strings. resultMetadata is the path to the output metadata/ folder. resultManifests is the path to the output manifests/ folder -- if no copy occured, it just returns the input manifestDir

func ExecuteCommand

func ExecuteCommand(cmd *exec.Cmd) error

func GenerateAnnotations

func GenerateAnnotations(mediaType, manifests, metadata, packageName, channels, channelDefault string) ([]byte, error)

GenerateAnnotations builds annotations.yaml with mediatype, manifests & metadata directories in bundle image, package name, channels and default channels information.

func GenerateDockerfile

func GenerateDockerfile(mediaType, manifests, metadata, copyManifestDir, copyMetadataDir, workingDir, packageName, channels, channelDefault string) ([]byte, error)

GenerateDockerfile builds Dockerfile with mediatype, manifests & metadata directories in bundle image, package name, channels and default channels information in LABEL section.

func GenerateFunc

func GenerateFunc(directory, outputDir, packageName, channels, channelDefault string, overwrite bool) error

GenerateFunc builds annotations.yaml with mediatype, manifests & metadata directories in bundle image, package name, channels and default channels information and then writes the file to `/metadata` directory. Inputs: @directory: The local directory where bundle manifests and metadata are located @outputDir: Optional generated path where the /manifests and /metadata directories are copied as they would appear on the bundle image @packageName: The name of the package that bundle image belongs to @channels: The list of channels that bundle image belongs to @channelDefault: The default channel for the bundle image @overwrite: Boolean flag to enable overwriting annotations.yaml locally if existed

func GetMediaType

func GetMediaType(directory string) (string, error)

GetMediaType determines mediatype from files (yaml) in given directory Currently able to detect helm chart, registry+v1 (CSV) and plain k8s resources such as CRD.

func IsChartDir

func IsChartDir(dirName string) (bool, error)

IsChartDir validates a chart directory.

Checks for a valid Chart.yaml.

func NewBundleDirInterperter

func NewBundleDirInterperter(bundleDir string) (*bundleDirInterpreter, error)

func ValidateAnnotations

func ValidateAnnotations(existing, expected []byte) error

ValidateAnnotations validates existing annotations.yaml against generated annotations.yaml to ensure existing annotations.yaml contains expected values.

func WriteFile

func WriteFile(fileName, directory string, content []byte) error

WriteFile writes `fileName` file with `content` into a `directory` Note: Will overwrite the existing `fileName` file if it exists

Types

type AnnotationMetadata

type AnnotationMetadata struct {
	Annotations map[string]string `yaml:"annotations" json:"annotations"`
}

type BundleExporter

type BundleExporter struct {
	// contains filtered or unexported fields
}

BundleExporter exports the manifests of a bundle image into a directory

func NewExporterForBundle

func NewExporterForBundle(image, directory string, containerTool containertools.ContainerTool) *BundleExporter

func (*BundleExporter) Export

func (i *BundleExporter) Export(skipTLSVerify, plainHTTP bool) error

type BundleImageValidator

type BundleImageValidator interface {
	// PullBundleImage takes an imageTag to pull and a directory to push
	// the contents of the image to
	PullBundleImage(imageTag string, directory string) error
	// Validate bundle takes a directory containing the contents of a bundle image
	// and validates that the format is correct
	ValidateBundleFormat(directory string) error
	// Validate bundle takes a directory containing the contents of a bundle image
	// and validates that the content is correct
	ValidateBundleContent(directory string) error
}

BundleImageValidator provides a toolset for pulling and then validating bundle container images

func NewImageValidator

func NewImageValidator(registry image.Registry, logger *logrus.Entry, options ...string) BundleImageValidator

NewImageValidator is a constructor that returns an ImageValidator

type Dependency

type Dependency struct {
	// Name is the name of the dependency.
	//
	// This must mach the name in the dependency's Chart.yaml.
	Name string `json:"name"`
	// Version is the version (range) of this chart.
	//
	// A lock file will always produce a single version, while a dependency
	// may contain a semantic version range.
	Version string `json:"version,omitempty"`
	// The URL to the repository.
	//
	// Appending `index.yaml` to this string should result in a URL that can be
	// used to fetch the repository index.
	Repository string `json:"repository"`
	// A yaml path that resolves to a boolean, used for enabling/disabling charts (e.g. subchart1.enabled )
	Condition string `json:"condition,omitempty"`
	// Tags can be used to group charts for enabling/disabling together
	Tags []string `json:"tags,omitempty"`
	// Enabled bool determines if chart should be loaded
	Enabled bool `json:"enabled,omitempty"`
	// ImportValues holds the mapping of source values to parent key to be imported. Each item can be a
	// string or pair of child/parent sublist items.
	ImportValues []interface{} `json:"import-values,omitempty"`
	// Alias usable alias to be used for the chart
	Alias string `json:"alias,omitempty"`
}

Dependency describes a chart upon which another chart depends.

Dependencies can be used to express developer intent, or to capture the state of a chart.

type Maintainer

type Maintainer struct {
	// Name is a user name or organization name
	Name string `json:"name,omitempty"`
	// Email is an optional email address to contact the named maintainer
	Email string `json:"email,omitempty"`
	// URL is an optional URL to an address for the named maintainer
	URL string `json:"url,omitempty"`
}

Maintainer describes a Chart maintainer.

type Meta

type Meta struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata"`
}

type Metadata

type Metadata struct {
	// The name of the chart
	Name string `json:"name,omitempty"`
	// The URL to a relevant project page, git repo, or contact person
	Home string `json:"home,omitempty"`
	// Source is the URL to the source code of this chart
	Sources []string `json:"sources,omitempty"`
	// A SemVer 2 conformant version string of the chart
	Version string `json:"version,omitempty"`
	// A one-sentence description of the chart
	Description string `json:"description,omitempty"`
	// A list of string keywords
	Keywords []string `json:"keywords,omitempty"`
	// A list of name and URL/email address combinations for the maintainer(s)
	Maintainers []*Maintainer `json:"maintainers,omitempty"`
	// The URL to an icon file.
	Icon string `json:"icon,omitempty"`
	// The API Version of this chart.
	APIVersion string `json:"apiVersion,omitempty"`
	// The condition to check to enable chart
	Condition string `json:"condition,omitempty"`
	// The tags to check to enable chart
	Tags string `json:"tags,omitempty"`
	// The version of the application enclosed inside of this chart.
	AppVersion string `json:"appVersion,omitempty"`
	// Whether or not this chart is deprecated
	Deprecated bool `json:"deprecated,omitempty"`
	// Annotations are additional mappings uninterpreted by Helm,
	// made available for inspection by other applications.
	Annotations map[string]string `json:"annotations,omitempty"`
	// KubeVersion is a SemVer constraint specifying the version of Kubernetes required.
	KubeVersion string `json:"kubeVersion,omitempty"`
	// Dependencies are a list of dependencies for a chart.
	Dependencies []*Dependency `json:"dependencies,omitempty"`
	// Specifies the chart type: application or library
	Type string `json:"type,omitempty"`
}

Metadata for a Chart file. This models the structure of a Chart.yaml file.

type Namespaced

type Namespaced bool

Namespaced indicates whether the resource is namespace scoped (true) or cluster-scoped (false).

func IsSupported

func IsSupported(kind string) (bool, Namespaced)

IsSupported checks if the object kind is OLM-supported and if it is namespaced

type ValidationError

type ValidationError struct {
	Errors []error
}

ValidationError is an imlementation of the Error type that defines a list of errors when validating the bundle

func NewValidationError

func NewValidationError(errs []error) ValidationError

func (ValidationError) Error

func (v ValidationError) Error() string

Jump to

Keyboard shortcuts

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