config

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Filename the default
	Filename = "config.yaml"
	// Label label selector to find the cluster's installer configuration.
	Label = "tssc.redhat-appstudio.github.com/config"
	// Name name of the installer's configuration ConfigMap.
	Name = "tssc-config"
)
View Source
const (
	// DeveloperHub Red Hat Developer Hub (RHDH).
	DeveloperHub = "Developer Hub"
	// OpenShiftPipelines OpenShift Pipelines.
	OpenShiftPipelines = "OpenShift Pipelines"
)

Variables

View Source
var (
	// ErrInvalidConfig indicates the configuration content is invalid.
	ErrInvalidConfig = errors.New("invalid configuration")
	// ErrEmptyConfig indicates the configuration file is empty.
	ErrEmptyConfig = errors.New("empty configuration")
	// ErrUnmarshalConfig indicates the configuration file structure is invalid.
	ErrUnmarshalConfig = errors.New("failed to unmarshal configuration")
)
View Source
var (
	// ErrConfigMapNotFound when the configmap isn't created in the cluster.
	ErrConfigMapNotFound = errors.New("cluster configmap not found")
	// ErrMultipleConfigMapFound when the label selector find multiple resources.
	ErrMultipleConfigMapFound = errors.New("multiple cluster configmaps found")
	// ErrIncompleteConfigMap when the ConfigMap exists, but doesn't contain the
	// expected payload.
	ErrIncompleteConfigMap = errors.New("invalid configmap found in the cluster")
)
View Source
var DefaultRelativeConfigPath = fmt.Sprintf("installer/%s", Filename)

DefaultRelativeConfigPath default relative path to YAML configuration file.

Functions

This section is empty.

Types

type Config

type Config struct {
	Installer Spec `yaml:"tssc"` // root configuration for the installer
	// contains filtered or unexported fields
}

Config root configuration structure.

func NewConfigDefault

func NewConfigDefault() (*Config, error)

NewConfigDefault returns a new Config instance with default values, i.e. the configuration payload is loading embedded data.

func NewConfigFromBytes

func NewConfigFromBytes(payload []byte) (*Config, error)

NewConfigFromBytes instantiates a new Config from the bytes payload informed.

func NewConfigFromFile

func NewConfigFromFile(cfs *chartfs.ChartFS, configPath string) (*Config, error)

NewConfigFromFile returns a new Config instance based on the informed file.

func (*Config) GetEnabledProducts

func (c *Config) GetEnabledProducts() Products

GetEnabledProducts returns a map of enabled products.

func (*Config) GetProduct

func (c *Config) GetProduct(name string) (*Product, error)

GetProduct returns a product by name, or an error if the product is not found.

func (*Config) MarshalYAML

func (c *Config) MarshalYAML() ([]byte, error)

MarshalYAML marshals the Config into a YAML byte array.

func (*Config) String

func (c *Config) String() string

String returns this configuration as string, indented with two spaces.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML() error

UnmarshalYAML Un-marshals the YAML payload into the Config struct, checking the validity of the configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration, checking for missing fields.

type ConfigMapManager

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

ConfigMapManager the actor responsible for managing installer configuration in the cluster.

func NewConfigMapManager

func NewConfigMapManager(kube *k8s.Kube) *ConfigMapManager

NewConfigMapManager instantiates the ConfigMapManager.

func (*ConfigMapManager) Create

func (m *ConfigMapManager) Create(ctx context.Context, cfg *Config) error

Create Bootstrap a ConfigMap with the provided configuration.

func (*ConfigMapManager) Delete

func (m *ConfigMapManager) Delete(ctx context.Context) error

Delete find and delete the ConfigMap from the cluster.

func (*ConfigMapManager) GetConfig

func (m *ConfigMapManager) GetConfig(ctx context.Context) (*Config, error)

GetConfig retrieves configuration from a cluster's ConfigMap.

func (*ConfigMapManager) GetConfigMap

func (m *ConfigMapManager) GetConfigMap(
	ctx context.Context,
) (*corev1.ConfigMap, error)

GetConfigMap retrieves the ConfigMap from the cluster, checking if a single resource is present.

func (*ConfigMapManager) Update

func (m *ConfigMapManager) Update(ctx context.Context, cfg *Config) error

Update updates a ConfigMap with informed configuration.

type Product

type Product struct {
	// Name of the product.
	Name string `yaml:"name"`
	// Enabled product toggle.
	Enabled bool `yaml:"enabled"`
	// Namespace target namespace for the product, which may involve different
	// Helm charts targeting the specific product namespace, while the chart
	// target is deployed in a different namespace.
	Namespace *string `yaml:"namespace,omitempty"`
	// Properties contains the product specific configuration.
	Properties map[string]interface{} `yaml:"properties"`
}

ProductSpec contains the configuration for a specific product.

func (*Product) GetNamespace

func (p *Product) GetNamespace() string

GetNamespace returns the product namespace, or an empty string if not set.

func (*Product) KeyName

func (p *Product) KeyName() string

KeyName returns a sanitized key name for the product.

func (*Product) Validate

func (p *Product) Validate() error

Validate validates the product configuration, checking for missing fields.

type Products

type Products []Product

ProductSpec represents a map of product name and specification.

type Settings

type Settings map[string]interface{}

Settings represents a map of configuration settings.

type Spec

type Spec struct {
	// Namespace installer's namespace, where the installer's resources will be
	// deployed. Note, Helm charts deployed by the installer are likely to use a
	// different namespace.
	Namespace string `yaml:"namespace"`
	// Settings contains the configuration for the installer settings.
	Settings Settings `yaml:"settings"`
	// Products contains the configuration for the installer products.
	Products Products `yaml:"products"`
}

Spec contains all configuration sections.

Jump to

Keyboard shortcuts

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