Documentation
¶
Index ¶
- Constants
- func BuildBundleImage(directory, imageTag, imageBuilder string) (*exec.Cmd, error)
- func BuildFunc(...) error
- func ExecuteCommand(cmd *exec.Cmd) error
- func GenerateAnnotations(mediaType, manifests, metadata, packageName, channels, channelDefault string) ([]byte, error)
- func GenerateDockerfile(mediaType, manifests, metadata, packageName, channels, channelDefault string) ([]byte, error)
- func GenerateFunc(directory, packageName, channels, channelDefault string, overwrite bool) error
- func GetMediaType(directory string) (string, error)
- func IsChartDir(dirName string) (bool, error)
- func IsSupported(kind string) (bool, bool)
- func ValidateAnnotations(existing, expected []byte) error
- func ValidateChannelDefault(channels, channelDefault string) (string, error)
- func WriteFile(fileName, directory string, content []byte) error
- type AnnotationMetadata
- type BundleExporter
- type BundleImageValidator
- type Dependency
- type Maintainer
- type Meta
- type Metadata
- type ValidationError
Constants ¶
const ( DefaultPermission = 0644 RegistryV1Type = "registry+v1" PlainType = "plain" HelmType = "helm" AnnotationsFile = "annotations.yaml" DockerFile = "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" )
const ( CSVKind = "ClusterServiceVersion" CRDKind = "CustomResourceDefinition" SecretKind = "Secret" ClusterRoleKind = "ClusterRole" ClusterRoleBindingKind = "ClusterRoleBinding" ServiceAccountKind = "ServiceAccount" ServiceKind = "Service" RoleKind = "Role" RoleBindingKind = "RoleBinding" PrometheusRuleKind = "PrometheusRule" ServiceMonitorKind = "ServiceMonitor" )
Variables ¶
This section is empty.
Functions ¶
func BuildBundleImage ¶
Create build command to build bundle manifests image
func BuildFunc ¶
func BuildFunc(directory, 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 ExecuteCommand ¶
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, 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 ¶
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 @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 ¶
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 IsSupported ¶
IsSupported checks if the object kind is OLM-supported and if it is namespaced
func ValidateAnnotations ¶
ValidateAnnotations validates existing annotations.yaml against generated annotations.yaml to ensure existing annotations.yaml contains expected values.
func ValidateChannelDefault ¶ added in v1.5.0
ValidateChannelDefault validates provided default channel to ensure it exists in provided channel list.
Types ¶
type AnnotationMetadata ¶
type BundleExporter ¶
type BundleExporter struct {
// contains filtered or unexported fields
}
BundleExporter exports the manifests of a bundle image into a directory
func NewSQLExporterForBundle ¶ added in v1.5.8
func NewSQLExporterForBundle(image, directory, containerTool string) *BundleExporter
func (*BundleExporter) Export ¶
func (i *BundleExporter) Export() 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(containerTool string, logger *logrus.Entry) 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 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