config

package
v3.15.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRegistered

func IsRegistered(version Version) bool

IsRegistered returns true if the given version has been registered through Register

func Register

func Register(version Version, constructor func() Config)

Register allows implementations of Config to register themselves so that they can be created with New

Types

type Config

type Config interface {

	// GetVersion returns the current project version.
	GetVersion() Version

	// GetDomain returns the project domain.
	GetDomain() string
	// SetDomain sets the project domain.
	SetDomain(domain string) error

	// GetRepository returns the project repository.
	GetRepository() string
	// SetRepository sets the project repository.
	SetRepository(repository string) error

	// GetProjectName returns the project name.
	// This method was introduced in project version 3.
	GetProjectName() string
	// SetProjectName sets the project name.
	// This method was introduced in project version 3.
	SetProjectName(name string) error

	// GetPluginChain returns the plugin chain.
	// This method was introduced in project version 3.
	GetPluginChain() []string
	// SetPluginChain sets the plugin chain.
	// This method was introduced in project version 3.
	SetPluginChain(pluginChain []string) error

	// IsMultiGroup checks if multi-group is enabled.
	IsMultiGroup() bool
	// SetMultiGroup enables multi-group.
	SetMultiGroup() error
	// ClearMultiGroup disables multi-group.
	ClearMultiGroup() error

	// IsComponentConfig checks if component config is enabled.
	// This method was introduced in project version 3.
	IsComponentConfig() bool
	// SetComponentConfig enables component config.
	// This method was introduced in project version 3.
	SetComponentConfig() error
	// ClearComponentConfig disables component config.
	// This method was introduced in project version 3.
	ClearComponentConfig() error

	// ResourcesLength returns the number of tracked resources.
	ResourcesLength() int
	// HasResource checks if the provided GVK is stored in the Config.
	HasResource(gvk resource.GVK) bool
	// GetResource returns the stored resource matching the provided GVK.
	GetResource(gvk resource.GVK) (resource.Resource, error)
	// GetResources returns all the stored resources.
	GetResources() ([]resource.Resource, error)
	// AddResource adds the provided resource if it was not present, no-op if it was already present.
	AddResource(res resource.Resource) error
	// UpdateResource adds the provided resource if it was not present, modifies it if it was already present.
	UpdateResource(res resource.Resource) error

	// HasGroup checks if the provided group is the same as any of the tracked resources.
	HasGroup(group string) bool
	// ListCRDVersions returns a list of the CRD versions in use by the tracked resources.
	ListCRDVersions() []string
	// ListWebhookVersions returns a list of the webhook versions in use by the tracked resources.
	ListWebhookVersions() []string

	// DecodePluginConfig decodes a plugin config stored in Config into configObj, which must be a pointer.
	// This method is intended to be used for custom configuration objects, which were introduced in project version 3.
	DecodePluginConfig(key string, configObj interface{}) error
	// EncodePluginConfig encodes a config object into Config by overwriting the existing object stored under key.
	// This method is intended to be used for custom configuration objects, which were introduced in project version 3.
	EncodePluginConfig(key string, configObj interface{}) error

	// Marshal returns the YAML representation of the Config.
	MarshalYAML() ([]byte, error)
	// Unmarshal loads the Config fields from its YAML representation.
	UnmarshalYAML([]byte) error
}

Config defines the interface that project configuration types must follow.

func New

func New(version Version) (Config, error)

New creates Config instances from the previously registered implementations through Register

type MarshalError

type MarshalError struct {
	Err error
}

MarshalError is returned by Config.Marshal when something went wrong while marshalling to YAML

func (MarshalError) Error

func (e MarshalError) Error() string

Error implements error interface

func (MarshalError) Unwrap

func (e MarshalError) Unwrap() error

Unwrap implements Wrapper interface

type PluginKeyNotFoundError

type PluginKeyNotFoundError struct {
	Key string
}

PluginKeyNotFoundError is returned by Config.DecodePluginConfig when the provided key cannot be found

func (PluginKeyNotFoundError) Error

func (e PluginKeyNotFoundError) Error() string

Error implements error interface

type ResourceNotFoundError

type ResourceNotFoundError struct {
	GVK resource.GVK
}

ResourceNotFoundError is returned by Config.GetResource when the provided GVK cannot be found

func (ResourceNotFoundError) Error

func (e ResourceNotFoundError) Error() string

Error implements error interface

type UnmarshalError

type UnmarshalError struct {
	Err error
}

UnmarshalError is returned by Config.Unmarshal when something went wrong while unmarshalling from YAML

func (UnmarshalError) Error

func (e UnmarshalError) Error() string

Error implements error interface

func (UnmarshalError) Unwrap

func (e UnmarshalError) Unwrap() error

Unwrap implements Wrapper interface

type UnsupportedFieldError

type UnsupportedFieldError struct {
	Version Version
	Field   string
}

UnsupportedFieldError is returned when a project configuration version does not support one of the fields as interface must be common for all the versions

func (UnsupportedFieldError) Error

func (e UnsupportedFieldError) Error() string

Error implements error interface

type UnsupportedVersionError

type UnsupportedVersionError struct {
	Version Version
}

UnsupportedVersionError is returned by New when a project configuration version is not supported.

func (UnsupportedVersionError) Error

func (e UnsupportedVersionError) Error() string

Error implements error interface

type Version

type Version struct {
	// Number denotes the current version of a plugin. Two different numbers between versions
	// indicate that they are incompatible.
	Number int
	// Stage indicates stability.
	Stage stage.Stage
}

Version is a project version containing a non-zero positive integer and a stage value that represents stability.

func (Version) Compare

func (v Version) Compare(other Version) int

Compare returns -1 if v < other, 0 if v == other, and 1 if v > other.

func (Version) IsStable

func (v Version) IsStable() bool

IsStable returns true if v is stable.

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller

func (*Version) Parse

func (v *Version) Parse(version string) error

Parse parses version inline, assuming it adheres to format: [1-9][0-9]*(-(alpha|beta))?

func (Version) String

func (v Version) String() string

String returns the string representation of v.

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaller

func (Version) Validate

func (v Version) Validate() error

Validate ensures that the version number is positive and the stage is one of the valid stages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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