Documentation
¶
Index ¶
- Constants
- Variables
- func ContainsKind(kinds []environment.EnvironmentKind, kind environment.EnvironmentKind) bool
- func CreateFeatureData(ctx context.Context, feat Feature, details *FeatureTemplateDetails) error
- func DeleteConfig(ctx context.Context, id uuid.UUID) error
- func DeleteEnvConfig(ctx context.Context, id uuid.UUID) error
- func DisableFeature(ctx context.Context, envID uuid.UUID, featureName, reason string) error
- func EnableFeature(ctx context.Context, envID uuid.UUID, featureName string) error
- func FeatureNames(ctx context.Context) ([]string, error)
- func Generate(vals Values, kind environment.EnvironmentKind, values *ComputedValues, ...) error
- func GenerateWith(vals Values, kind environment.EnvironmentKind, values *ComputedValues, ...) error
- func GetFeatureDisabledAt(ctx context.Context, envID uuid.UUID, featureName string) (time.Time, bool, error)
- func HelmValues(ctx context.Context, f *Feature, envID uuid.UUID) (map[string]any, error)
- func IAPAudience() string
- func InitializeTemplateVars(aud string)
- func LatestDeployInstructionsForEnvironment(ctx context.Context, envID uuid.UUID) (map[string]*DeployInstruction, error)
- func LatestDeployInstructionsForFeature(ctx context.Context, featureName string) (map[uuid.UUID]*DeployInstruction, error)
- func LatestDeployedForEnvironment(ctx context.Context, envID uuid.UUID) (map[string]*DeployInstruction, error)
- func LatestDeployedForFeature(ctx context.Context, featureName string) (map[uuid.UUID]*DeployInstruction, error)
- func ListDisabledEnvironmentsForFeature(ctx context.Context, featureName string) (map[uuid.UUID]time.Time, error)
- func MakeHelmConfigMap(vals []MergedConfigRow) (map[string]any, error)
- func Register(ctx context.Context, pool *pgxpool.Pool) context.Context
- func RenderHelmValues(data *HelmRenderData, f *Feature, funcs template.FuncMap, validate bool) (map[string]any, error)
- func RenderSingleTemplate(values *ComputedValues, tpl string) (string, error)
- func ValidateFields(f *Feature, envKind environment.EnvironmentKind, values []MergedConfigRow, ...) []string
- type Computed
- type ComputedConfig
- type ComputedFasit
- type ComputedTenant
- type ComputedValues
- type Config
- type ConfigSource
- type ConfigType
- type Configuration
- func CreateEnvConfig(ctx context.Context, c NewConfiguration) (*Configuration, error)
- func CreateGlobalConfig(ctx context.Context, c NewConfiguration) (*Configuration, error)
- func GetEnvConfig(ctx context.Context, feature *Feature, envID uuid.UUID) ([]*Configuration, error)
- func GetGlobalConfig(ctx context.Context, feature string) ([]*Configuration, error)
- func UpdateConfig(ctx context.Context, id uuid.UUID, c UpdateConfiguration) (*Configuration, error)
- func UpdateEnvConfig(ctx context.Context, id uuid.UUID, c UpdateConfiguration) (*Configuration, error)
- type Dependencies
- type Dependency
- type DeployInstruction
- type DeployStatus
- type EnvConfigOverride
- type Feature
- type FeatureTemplateDetails
- type FeatureYAML
- type HelmRenderData
- type MergedConfigRow
- type NewConfiguration
- type Release
- type UpdateConfiguration
- type Value
- type Values
Constants ¶
const (
QuerierKey ctxKey = iota
)
QuerierKey is exposed so tests can inject fake queriers on the context.
Variables ¶
var DownloadChartFunc = helm.DownloadChart
DownloadChartFunc is used to download a chart from a given source. It is a variable so that it can be mocked in tests.
var TemplateFuncs = func() template.FuncMap { fm := sprig.GenericFuncMap() fm["mapOf"] = mapOf fm["mapJoin"] = mapJoin fm["environmentsAsMap"] = environmentsAsMap fm["prefixedValues"] = prefixedValues fm["subdomain"] = subdomain fm["eachOf"] = eachOf fm["toJSON"] = toJSON fm["fromJSON"] = fromJSON fm["toYAML"] = toYAML fm["join"] = join fm["filter"] = filter fm["exclude"] = exclude fm["replace"] = replace fm["b64enc"] = base64encode fm["quote"] = quote return fm }()
Functions ¶
func ContainsKind ¶
func ContainsKind(kinds []environment.EnvironmentKind, kind environment.EnvironmentKind) bool
func CreateFeatureData ¶
func CreateFeatureData(ctx context.Context, feat Feature, details *FeatureTemplateDetails) error
func DisableFeature ¶
DisableFeature marks a (feature, environment) combination as disabled in the authoritative disabled_features table and writes an audit entry. Insert and audit are committed together via dbtx.WithTx; nested calls reuse the outer transaction.
func EnableFeature ¶
EnableFeature removes a (feature, environment) row from disabled_features and writes an audit entry. No-op if the row does not exist. Delete and audit are committed together via dbtx.WithTx.
func Generate ¶
func Generate(vals Values, kind environment.EnvironmentKind, values *ComputedValues, target map[string]any) error
func GenerateWith ¶
func GenerateWith(vals Values, kind environment.EnvironmentKind, values *ComputedValues, target map[string]any, funcs template.FuncMap) error
func GetFeatureDisabledAt ¶
func GetFeatureDisabledAt(ctx context.Context, envID uuid.UUID, featureName string) (time.Time, bool, error)
GetFeatureDisabledAt reports whether a (feature, environment) row exists in disabled_features. If disabled, returns the disabled_at timestamp and true; otherwise the zero time and false.
func HelmValues ¶
func IAPAudience ¶
func IAPAudience() string
IAPAudience returns the process-wide Fasit IAP audience, or "" if unset.
func InitializeTemplateVars ¶
func InitializeTemplateVars(aud string)
InitializeTemplateVars records the process-wide Fasit IAP audience surfaced to feature templates as .Fasit.IAPAudience.
func LatestDeployInstructionsForEnvironment ¶
func LatestDeployInstructionsForEnvironment(ctx context.Context, envID uuid.UUID) (map[string]*DeployInstruction, error)
LatestDeployInstructionsForEnvironment returns the latest deploy instruction per feature in an environment, keyed by feature name. One query instead of one per feature.
func LatestDeployInstructionsForFeature ¶
func LatestDeployInstructionsForFeature(ctx context.Context, featureName string) (map[uuid.UUID]*DeployInstruction, error)
LatestDeployInstructionsForFeature returns the latest deploy instruction per environment for a feature, keyed by environment id. One query instead of one per environment.
func LatestDeployedForEnvironment ¶
func LatestDeployedForEnvironment(ctx context.Context, envID uuid.UUID) (map[string]*DeployInstruction, error)
LatestDeployedForEnvironment returns the latest successfully deployed deploy instruction per feature in an environment, keyed by feature name. One query instead of one per feature.
func LatestDeployedForFeature ¶
func LatestDeployedForFeature(ctx context.Context, featureName string) (map[uuid.UUID]*DeployInstruction, error)
LatestDeployedForFeature returns the latest successfully deployed deploy instruction per environment for a feature, keyed by environment id. One query instead of one per environment.
func ListDisabledEnvironmentsForFeature ¶
func ListDisabledEnvironmentsForFeature(ctx context.Context, featureName string) (map[uuid.UUID]time.Time, error)
ListDisabledEnvironmentsForFeature returns, for a single feature, the set of environments where it is disabled, keyed by environment id with the disabled timestamp. One query instead of one per environment.
func MakeHelmConfigMap ¶
func MakeHelmConfigMap(vals []MergedConfigRow) (map[string]any, error)
func RenderHelmValues ¶
func RenderHelmValues(data *HelmRenderData, f *Feature, funcs template.FuncMap, validate bool) (map[string]any, error)
RenderHelmValues renders the helm config map from pre-fetched data. When validate is true, missing required fields cause an error.
func RenderSingleTemplate ¶
func RenderSingleTemplate(values *ComputedValues, tpl string) (string, error)
RenderSingleTemplate renders a single Go template string against the given ComputedValues, returning the result as a string.
func ValidateFields ¶
func ValidateFields(f *Feature, envKind environment.EnvironmentKind, values []MergedConfigRow, mp map[string]any) []string
Types ¶
type Computed ¶
type Computed struct {
Template string `yaml:"template,omitempty" json:"template,omitempty"`
}
type ComputedConfig ¶
type ComputedConfig struct {
DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Value any `yaml:"value,omitempty" json:"value,omitempty" jsonschema:"oneof_required=value"`
Template string `yaml:"template,omitempty" json:"template,omitempty" jsonschema:"oneof_required=template"`
}
type ComputedFasit ¶
type ComputedFasit struct {
// IAPAudience is the Identity-Aware Proxy audience of this Fasit instance,
// e.g. so a feature like fasitd can authenticate calls back to Fasit.
IAPAudience string
}
ComputedFasit holds information about the Fasit instance managing the feature.
type ComputedTenant ¶
type ComputedTenant struct {
Name string
}
type ComputedValues ¶
type ComputedValues struct {
// Kind is the kind of environment the feature is deployed to.
Kind environment.EnvironmentKind
// Tenant is information about the tenant that owns the cluster the feature is deployed to.
Tenant ComputedTenant
// Fasit is information about the Fasit instance managing the feature.
Fasit ComputedFasit
// Management is information about the management cluster for the tenant.
Management map[string]any
// Env contains information about the cluster the feature is deployed to.
Env map[string]any
// Envs contains information about all clusters the tenant has access to.
Envs []map[string]any
// Configs contains information about all configs stored on the feature.
Configs map[string]any
}
func MappingValuesForEnvironment ¶
func MappingValuesForEnvironment(ctx context.Context, envID uuid.UUID, showSensitive bool) (*ComputedValues, environment.EnvironmentKind, error)
type Config ¶
type Config struct {
Type ConfigType `yaml:"type,omitempty" json:"type" jsonschema:"enum=string,enum=int,enum=bool,enum=string_array,required"`
Secret bool `json:"secret,omitempty" yaml:"secret,omitempty"`
}
type ConfigSource ¶
type ConfigSource string
const ( ConfigSourceGlobal ConfigSource = "GLOBAL" ConfigSourceEnv ConfigSource = "ENV" ConfigSourceHelm ConfigSource = "HELM" ConfigSourceUnknown ConfigSource = "UNKNOWN" )
func (ConfigSource) IsValid ¶
func (e ConfigSource) IsValid() bool
func (ConfigSource) String ¶
func (e ConfigSource) String() string
type ConfigType ¶
type ConfigType string
const ( ConfigTypeString ConfigType = "string" ConfigTypeInt ConfigType = "int" ConfigTypeBool ConfigType = "bool" ConfigTypeStringArray ConfigType = "string_array" )
func (ConfigType) IsValid ¶
func (e ConfigType) IsValid() bool
func (ConfigType) MarshalJSON ¶
func (e ConfigType) MarshalJSON() ([]byte, error)
func (ConfigType) String ¶
func (e ConfigType) String() string
func (*ConfigType) UnmarshalJSON ¶
func (e *ConfigType) UnmarshalJSON(b []byte) error
type Configuration ¶
type Configuration struct {
ID uuid.UUID `json:"id"`
Value *Value `json:"value"`
Content json.RawMessage `json:"content"`
Created time.Time `json:"created"`
Source ConfigSource `json:"source"`
Key string `json:"key"`
}
func CreateEnvConfig ¶
func CreateEnvConfig(ctx context.Context, c NewConfiguration) (*Configuration, error)
func CreateGlobalConfig ¶
func CreateGlobalConfig(ctx context.Context, c NewConfiguration) (*Configuration, error)
func GetEnvConfig ¶
func GetGlobalConfig ¶
func GetGlobalConfig(ctx context.Context, feature string) ([]*Configuration, error)
func UpdateConfig ¶
func UpdateConfig(ctx context.Context, id uuid.UUID, c UpdateConfiguration) (*Configuration, error)
func UpdateEnvConfig ¶
func UpdateEnvConfig(ctx context.Context, id uuid.UUID, c UpdateConfiguration) (*Configuration, error)
type Dependencies ¶
type Dependencies []*Dependency
func (Dependencies) FindMissing ¶
func (d Dependencies) FindMissing(features []string) []string
type Dependency ¶
type Dependency struct {
AnyOf []string `json:"anyOf,omitempty" yaml:"anyOf,omitempty"`
AllOf []string `json:"allOf,omitempty" yaml:"allOf,omitempty"`
}
func (*Dependency) FindMissing ¶
func (d *Dependency) FindMissing(features []string) []string
type DeployInstruction ¶
type DeployInstruction struct {
ID uuid.UUID
EnvironmentID uuid.UUID
FeatureAssignmentID *uuid.UUID
FeatureName string
FeatureVersion string
Status DeployStatus
Hash string
Created time.Time
LastModified time.Time
// Helm values for this deploy instruction.
Values []byte
}
func ListRecentDeployInstructions ¶
func ListRecentDeployInstructions(ctx context.Context, envID uuid.UUID, featureName string, limit int) ([]*DeployInstruction, error)
ListRecentDeployInstructions returns deploy history for an environment x feature, one entry per deploy (diid). The deploy_log holds one row per status transition, so rows are grouped by diid here: the earliest row is the publish (version/hash/created), the latest row carries the current status.
type DeployStatus ¶
type DeployStatus string
const ( DeployStatusUnknown DeployStatus = "" DeployStatusSent DeployStatus = "sent" DeployStatusInstalling DeployStatus = "installing" DeployStatusDeployed DeployStatus = "deployed" DeployStatusFailed DeployStatus = "failed" )
func (DeployStatus) IsInProgress ¶
func (r DeployStatus) IsInProgress() bool
IsInProgress reports whether the rollout has been dispatched but has not yet reached a terminal state (deployed/failed).
func (DeployStatus) IsValid ¶
func (r DeployStatus) IsValid() bool
func (DeployStatus) String ¶
func (r DeployStatus) String() string
type EnvConfigOverride ¶
EnvConfigOverride holds a single environment config override row.
func ListAllEnvConfigByFeature ¶
func ListAllEnvConfigByFeature(ctx context.Context, feature string) ([]EnvConfigOverride, error)
ListAllEnvConfigByFeature returns all environment config overrides for a feature.
type Feature ¶
type Feature struct {
FeatureYAML
Name string `json:"name"`
Chart string `json:"chart"`
Version string `json:"version"`
Description string `json:"description"`
Source string `json:"source"`
ValuesYAML map[string]json.RawMessage `json:"-"`
// SpecVersion is used to determine which version of the feature spec is used.
SpecVersion string `json:"specVersion"`
TplDetails []byte
}
func FeatureByNameVersion ¶
func (*Feature) RequiredFields ¶
func (f *Feature) RequiredFields(envKind environment.EnvironmentKind) []string
func (*Feature) SecretKeys ¶
SecretKeys returns the dotted key names of all secret values in the feature.
type FeatureTemplateDetails ¶
type FeatureTemplateDetails struct {
Management []string
Env []string
Envs []string
All []string
Functions []string
}
func ParseTemplateDetails ¶
func ParseTemplateDetails(content Values) (*FeatureTemplateDetails, error)
type FeatureYAML ¶
type FeatureYAML struct {
Dependencies Dependencies `json:"dependencies,omitempty" yaml:"dependencies,omitempty" jsonschema:"omitempty"`
EnvironmentKinds []environment.EnvironmentKind `json:"environmentKinds" yaml:"environmentKinds" jsonschema:"enum=management,enum=tenant,enum=onprem,required"`
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty" jsonschema:"omitempty,type=string,pattern=^(\\d+h)?(\\d+m)?(\\d+s)?$"`
Values Values `json:"values,omitempty" yaml:"values,omitempty" jsonschema:"omitempty"`
}
type HelmRenderData ¶
type HelmRenderData struct {
MV *ComputedValues
EnvKind environment.EnvironmentKind
ConfigVals []MergedConfigRow
ConfigMap map[string]any
SecretEnvKeys map[string]bool
}
HelmRenderData holds everything needed to render helm values without additional database access. Fetched once, rendered multiple times for taint detection.
type MergedConfigRow ¶
type MergedConfigRow struct {
ID uuid.UUID
Key string
Value []byte
Secret bool
Created time.Time
EnvironmentID *uuid.UUID
}
MergedConfigRow is a config key-value pair produced by overlaying environment-specific config on top of global config. Exported so that the reconciler package can build these from its own bulk-fetched data.
func MergeConfigs ¶
func MergeConfigs(global []featuresql.ConfigurationsGlobal, env []featuresql.ConfigurationsEnvironment, includeKeys []string) []MergedConfigRow
type NewConfiguration ¶
type UpdateConfiguration ¶
type UpdateConfiguration struct {
Description *string `json:"description,omitempty"`
Value json.RawMessage `json:"value"`
}
type Value ¶
type Value struct {
Description string `yaml:"description,omitempty" json:"description,omitempty"`
DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty"`
Required bool `yaml:"required,omitempty" json:"required,omitempty"`
Computed *Computed `yaml:"computed,omitempty" json:"computed,omitempty" jsonschema:"anyof_required=computed"`
Config *Config `yaml:"config,omitempty" json:"config,omitempty" jsonschema:"anyof_required=config"`
IgnoreKind []environment.EnvironmentKind `yaml:"ignoreKind,omitempty" json:"ignoreKind,omitempty" jsonschema:"enum=management,enum=tenant,enum=onprem"`
}