declcfg

package
v1.48.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 27 Imported by: 22

Documentation

Index

Constants

View Source
const (
	SchemaPackage     = "olm.package"
	SchemaChannel     = "olm.channel"
	SchemaBundle      = "olm.bundle"
	SchemaDeprecation = "olm.deprecations"
)

Variables

This section is empty.

Functions

func ConvertToModel

func ConvertToModel(cfg DeclarativeConfig) (model.Model, error)

func WalkFS

func WalkFS(root fs.FS, walkFn WalkFunc) error

WalkFS walks root using a gitignore-style filename matcher to skip files that match patterns found in .indexignore files found throughout the filesystem. It calls walkFn for each declarative config file it finds. If WalkFS encounters an error loading or parsing any file, the error will be immediately returned.

func WalkMetasFS added in v1.27.0

func WalkMetasFS(ctx context.Context, root fs.FS, walkFn WalkMetasFSFunc, opts ...LoadOption) error

WalkMetasFS walks the filesystem rooted at root and calls walkFn for each individual meta object found in the root. By default, WalkMetasFS is not thread-safe because it invokes walkFn concurrently. In order to make it thread-safe, use the WithConcurrency(1) to avoid concurrent invocations of walkFn.

func WalkMetasReader added in v1.27.0

func WalkMetasReader(r io.Reader, walkFn WalkMetasReaderFunc) error

func WriteFS added in v1.28.0

func WriteFS(cfg DeclarativeConfig, rootDir string, writeFunc WriteFunc, fileExt string) error

func WriteJSON

func WriteJSON(cfg DeclarativeConfig, w io.Writer) error

func WriteYAML

func WriteYAML(cfg DeclarativeConfig, w io.Writer) error

Types

type Bundle

type Bundle struct {
	Schema        string              `json:"schema"`
	Name          string              `json:"name,omitempty"`
	Package       string              `json:"package,omitempty"`
	Image         string              `json:"image"`
	Properties    []property.Property `json:"properties,omitempty" hash:"set"`
	RelatedImages []RelatedImage      `json:"relatedImages,omitempty" hash:"set"`

	// These fields are present so that we can continue serving
	// the GRPC API the way packageserver expects us to in a
	// backwards-compatible way. These are populated from
	// any `olm.bundle.object` properties.
	//
	// These fields will never be persisted in the bundle blob as
	// first class fields.
	CsvJSON string   `json:"-"`
	Objects []string `json:"-"`
}

Bundle specifies all metadata and data of a bundle object. Top-level fields are the source of truth, i.e. not CSV values.

Notes:

  • Any field slice type field or type containing a slice somewhere where two types/fields are equal if their contents are equal regardless of order must have a `hash:"set"` field tag for bundle comparison.
  • Any fields that have a `json:"-"` tag must be included in the equality evaluation in bundlesEqual().

type Channel

type Channel struct {
	Schema     string              `json:"schema"`
	Name       string              `json:"name"`
	Package    string              `json:"package"`
	Entries    []ChannelEntry      `json:"entries"`
	Properties []property.Property `json:"properties,omitempty" hash:"set"`
}

type ChannelEntry

type ChannelEntry struct {
	Name      string   `json:"name"`
	Replaces  string   `json:"replaces,omitempty"`
	Skips     []string `json:"skips,omitempty"`
	SkipRange string   `json:"skipRange,omitempty"`
}

type DeclarativeConfig

type DeclarativeConfig struct {
	Packages     []Package
	Channels     []Channel
	Bundles      []Bundle
	Deprecations []Deprecation
	Others       []Meta
}

func ConvertFromModel

func ConvertFromModel(mpkgs model.Model) DeclarativeConfig

func LoadFS

func LoadFS(ctx context.Context, root fs.FS, opts ...LoadOption) (*DeclarativeConfig, error)

LoadFS loads a declarative config from the provided root FS. LoadFS walks the filesystem from root and uses a gitignore-style filename matcher to skip files that match patterns found in .indexignore files found throughout the filesystem. If LoadFS encounters an error loading or parsing any file, the error will be immediately returned.

func LoadFile

func LoadFile(root fs.FS, path string) (*DeclarativeConfig, error)

LoadFile will unmarshall declarative config components from a single filename provided in 'path' located at a filesystem hierarchy 'root'

func LoadReader

func LoadReader(r io.Reader) (*DeclarativeConfig, error)

LoadReader reads yaml or json from the passed in io.Reader and unmarshals it into a DeclarativeConfig struct.

func LoadSlice added in v1.44.0

func LoadSlice(metas []*Meta) (*DeclarativeConfig, error)

LoadSlice will compose declarative config components from a slice of Meta objects

func (*DeclarativeConfig) Merge added in v1.32.0

func (destination *DeclarativeConfig) Merge(src *DeclarativeConfig)

type Deprecation added in v1.32.0

type Deprecation struct {
	Schema  string             `json:"schema"`
	Package string             `json:"package"`
	Entries []DeprecationEntry `json:"entries"`
}

type DeprecationEntry added in v1.32.0

type DeprecationEntry struct {
	Reference PackageScopedReference `json:"reference"`
	Message   string                 `json:"message"`
}

type Icon

type Icon struct {
	Data      []byte `json:"base64data"`
	MediaType string `json:"mediatype"`
}

type LoadOption added in v1.28.0

type LoadOption func(*LoadOptions)

func WithConcurrency added in v1.28.0

func WithConcurrency(concurrency int) LoadOption

type LoadOptions added in v1.28.0

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

type MermaidOption

type MermaidOption func(*MermaidWriter)

func WithMinEdgeName

func WithMinEdgeName(minEdgeName string) MermaidOption

func WithSpecifiedPackageName

func WithSpecifiedPackageName(specifiedPackageName string) MermaidOption

type MermaidWriter

type MermaidWriter struct {
	MinEdgeName          string
	SpecifiedPackageName string
}

func NewMermaidWriter

func NewMermaidWriter(opts ...MermaidOption) *MermaidWriter

func (*MermaidWriter) WriteChannels

func (writer *MermaidWriter) WriteChannels(cfg DeclarativeConfig, out io.Writer) error

writes out the channel edges of the declarative config graph in a mermaid format capable of being pasted into mermaid renderers like github, mermaid.live, etc. output is sorted lexicographically by package name, and then by channel name if provided, minEdgeName will be used as the lower bound for edges in the output graph

Example output: graph LR

  %% package "neuvector-certified-operator-rhmp"
  subgraph "neuvector-certified-operator-rhmp"
     %% channel "beta"
     subgraph neuvector-certified-operator-rhmp-beta["beta"]
	      neuvector-certified-operator-rhmp-beta-neuvector-operator.v1.2.8["neuvector-operator.v1.2.8"]
	      neuvector-certified-operator-rhmp-beta-neuvector-operator.v1.2.9["neuvector-operator.v1.2.9"]
	      neuvector-certified-operator-rhmp-beta-neuvector-operator.v1.3.0["neuvector-operator.v1.3.0"]
	      neuvector-certified-operator-rhmp-beta-neuvector-operator.v1.3.0["neuvector-operator.v1.3.0"]-- replaces --> neuvector-certified-operator-rhmp-beta-neuvector-operator.v1.2.8["neuvector-operator.v1.2.8"]
	      neuvector-certified-operator-rhmp-beta-neuvector-operator.v1.3.0["neuvector-operator.v1.3.0"]-- skips --> neuvector-certified-operator-rhmp-beta-neuvector-operator.v1.2.9["neuvector-operator.v1.2.9"]
    end
  end

end

type Meta

type Meta struct {
	Schema  string
	Package string
	Name    string

	Blob json.RawMessage
}

func (Meta) MarshalJSON

func (m Meta) MarshalJSON() ([]byte, error)

func (*Meta) UnmarshalJSON

func (m *Meta) UnmarshalJSON(blob []byte) error

type Package

type Package struct {
	Schema         string              `json:"schema"`
	Name           string              `json:"name"`
	DefaultChannel string              `json:"defaultChannel"`
	Icon           *Icon               `json:"icon,omitempty"`
	Description    string              `json:"description,omitempty"`
	Properties     []property.Property `json:"properties,omitempty" hash:"set"`
}

type PackageScopedReference added in v1.32.0

type PackageScopedReference struct {
	Schema string `json:"schema"`
	Name   string `json:"name,omitempty"`
}

type RelatedImage

type RelatedImage struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

func ModelRelatedImagesToRelatedImages

func ModelRelatedImagesToRelatedImages(relatedImages []model.RelatedImage) []RelatedImage

type WalkFunc

type WalkFunc func(path string, cfg *DeclarativeConfig, err error) error

type WalkMetasFSFunc added in v1.27.0

type WalkMetasFSFunc func(path string, meta *Meta, err error) error

type WalkMetasReaderFunc added in v1.27.0

type WalkMetasReaderFunc func(meta *Meta, err error) error

type WriteFunc added in v1.28.0

type WriteFunc func(config DeclarativeConfig, w io.Writer) error

Jump to

Keyboard shortcuts

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