Documentation
¶
Index ¶
- Constants
- func Box[T any](v T) *T
- func Empty[T any]() (out T)
- func EmptyIfNil[T any](v *T) T
- func FirstNonEmpty[T comparable](values ...T) T
- func IsEmpty[T comparable](in T) bool
- func IsNil(m any) bool
- func IsNilOrEmpty[T comparable](in *T) bool
- func NamedOutput(in any) any
- func NilIfEmpty[T comparable](in T) *T
- func Unbox[T any](v *T, def T) T
- func UnboxWith[T any](v *T, mkDef func() T) T
- func UuidWithDashes(uuid *string) (*string, error)
- type ConfigProvider
- type Identifiable
- type Identifier
- type Keyed
- type ModelId
- type Nameable
- type NamedOutputV0
- type Resource
- type ResourceContextAware
- type Transformer
- type TransformerMap
- type TransformerResolver
Constants ¶
const ( PlaceholderAppEnv = "app.env" PlaceholderAppName = "app.name" PlaceholderAppTags = "app.tags." )
Placeholder constants for ModelId patterns.
const ConfigKeyModelIdDomainPattern = "app.model_id.domain_pattern"
ConfigKeyModelIdDomainPattern is the config key for the required model id domain pattern.
const NamedView = "named"
Variables ¶
This section is empty.
Functions ¶
func EmptyIfNil ¶
func EmptyIfNil[T any](v *T) T
func FirstNonEmpty ¶ added in v0.40.4
func FirstNonEmpty[T comparable](values ...T) T
func IsEmpty ¶ added in v0.40.4
func IsEmpty[T comparable](in T) bool
func IsNilOrEmpty ¶
func IsNilOrEmpty[T comparable](in *T) bool
func NamedOutput ¶
func NilIfEmpty ¶
func NilIfEmpty[T comparable](in T) *T
func UuidWithDashes ¶
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
Get(key string, optionalDefault ...any) (any, error)
GetString(key string, optionalDefault ...string) (string, error)
GetStringMap(key string, optionalDefault ...map[string]any) (map[string]any, error)
}
ConfigProvider is an interface for reading config values. It is implemented by cfg.Config.
type Identifiable ¶
type Identifiable interface {
GetId() *uint
}
type Identifier ¶
type Identifier struct {
Id *uint `json:"id" binding:"required"`
}
func WithIdentifier ¶
func WithIdentifier(id *uint) *Identifier
func (*Identifier) GetId ¶
func (i *Identifier) GetId() *uint
type ModelId ¶
type ModelId struct {
// Name is the model's name (the {modelId} placeholder)
Name string `cfg:"name"`
// Env is the environment (the {app.env} placeholder)
Env string `cfg:"env"`
// Application is the application name (the {app.name} placeholder)
Application string `cfg:"application"`
// Tags holds dynamic tag values (for {app.tags.<key>} placeholders)
Tags map[string]string `cfg:"tags"`
// DomainPattern is the formatting pattern read from config during PadFromConfig.
DomainPattern string
}
ModelId represents the identity of a model using dynamic tags.
Unlike the legacy fixed-field ModelId (Project/Family/Group/etc), this version uses a dynamic tags map that can hold any key-value pairs.
The canonical string form is determined by the app.model_id.domain_pattern config key. Call PadFromConfig() once to populate fields from config (including the domain pattern), then use String() to obtain the canonical string representation.
func ParseModelId ¶ added in v0.56.0
func ParseModelId(config ConfigProvider, s string) (ModelId, error)
ParseModelId parses a string into a ModelId using the required domain pattern from config. This is the only supported way to parse a canonical model id string.
Returns an error if:
- the domain pattern is not configured or invalid
- the string doesn't match the expected domain pattern structure
func (ModelId) DomainString ¶ added in v0.56.0
DomainString returns the canonical domain string representation of the ModelId (without the model name).
This method requires that the DomainPattern has been set via PadFromConfig. If no DomainPattern is set, DomainString returns an error.
Returns an error if:
- the DomainPattern is not set (call PadFromConfig first)
- the DomainPattern references fields/tags that are missing from the ModelId
func (*ModelId) PadFromConfig ¶
func (m *ModelId) PadFromConfig(config ConfigProvider) error
PadFromConfig fills in empty fields of ModelId from config.
This method reads:
- app.env -> Env (if empty)
- app.name -> Application (if empty)
- app.tags.* -> Tags (merged, existing tags take precedence)
- app.model_id.domain_pattern -> DomainPattern (if empty and available)
The DomainPattern is read if available, enabling String() to work afterward. If the domain pattern config key is missing, the DomainPattern field is left empty, and String() will return an error when called.
All identity fields (env, app, tags) are optional. If a config key is not found, the corresponding field is left unchanged. This allows patterns to determine what's required (enforced at format time).
After loading the domain pattern, this method validates that all {app.tags.<key>} placeholders referenced in the pattern have corresponding entries in the merged Tags map. This prevents formatDomain from silently replacing missing tags with empty strings, which would produce malformed canonical IDs.
func (ModelId) String ¶
String returns the canonical string representation of the ModelId.
This method requires that the DomainPattern has been set via PadFromConfig. If no DomainPattern is set, String returns an error.
Returns an error if:
- the DomainPattern is not set (call PadFromConfig first)
- the DomainPattern references fields/tags that are missing from the ModelId
type Nameable ¶
type Nameable interface {
Identifiable
GetName() *string
}
type NamedOutputV0 ¶
type ResourceContextAware ¶
type Transformer ¶
type TransformerMap ¶
type TransformerMap map[string]map[int]Transformer
type TransformerResolver ¶
func Transform ¶
func Transform(transformers TransformerMap) TransformerResolver