Documentation
¶
Index ¶
- Variables
- func ErrorToAPIError(err error, fallbackIdentifier string) *api.APIError
- func ToAPIError(err error, identifier string) *api.APIError
- type AliasCache
- func (c *AliasCache) Close(ctx context.Context) error
- func (c *AliasCache) Invalidate(ctx context.Context, namespace *string, alias string)
- func (c *AliasCache) InvalidateAliasesByTemplateID(ctx context.Context, templateID string, aliasKeys []string)
- func (c *AliasCache) LookupByID(ctx context.Context, templateID string) (*AliasInfo, error)
- func (c *AliasCache) Resolve(ctx context.Context, identifier string, namespaceFallback string) (*AliasInfo, error)
- type AliasInfo
- type TemplateBuildInfo
- type TemplateCache
- func (c *TemplateCache) Close(ctx context.Context) error
- func (c *TemplateCache) Get(ctx context.Context, templateID string, tag *string, teamID uuid.UUID, ...) (*api.Template, *queries.EnvBuild, error)
- func (c *TemplateCache) GetByID(ctx context.Context, templateID string) (*AliasInfo, error)
- func (c *TemplateCache) GetMetadata(ctx context.Context, templateID string) (*TemplateMetadata, error)
- func (c *TemplateCache) Invalidate(ctx context.Context, templateID string, tag *string)
- func (c *TemplateCache) InvalidateAlias(ctx context.Context, namespace *string, alias string)
- func (c *TemplateCache) InvalidateAliasesByTemplateID(ctx context.Context, templateID string, aliasKeys []string)
- func (c *TemplateCache) InvalidateAllTags(ctx context.Context, templateID string) []string
- func (c *TemplateCache) ResolveAlias(ctx context.Context, identifier string, namespaceFallback string) (*AliasInfo, error)
- func (c *TemplateCache) ResolveAliasWithMetadata(ctx context.Context, identifier string, namespaceFallback string) (*AliasInfo, *TemplateMetadata, error)
- type TemplateInfo
- type TemplateMetadata
- type TemplateMetadataCache
- type TemplateRef
- type TemplatesBuildCache
Constants ¶
This section is empty.
Variables ¶
var ( ErrTemplateNotFound = errors.New("template not found") ErrAccessDenied = errors.New("access denied") ErrClusterMismatch = errors.New("template not available in cluster") )
var ErrTemplateBuildInfoNotFound = errors.New("template build info not found")
Functions ¶
Types ¶
type AliasCache ¶
type AliasCache struct {
// contains filtered or unexported fields
}
AliasCache resolves namespace/alias to templateID with fallback logic. This is the main resolution layer implementing the namespace lookup flowchart.
func NewAliasCache ¶
func NewAliasCache(db *sqlcdb.Client, redisClient redis.UniversalClient) *AliasCache
func (*AliasCache) Invalidate ¶
func (c *AliasCache) Invalidate(ctx context.Context, namespace *string, alias string)
func (*AliasCache) InvalidateAliasesByTemplateID ¶
func (c *AliasCache) InvalidateAliasesByTemplateID(ctx context.Context, templateID string, aliasKeys []string)
InvalidateAliasesByTemplateID deletes alias cache entries for the given keys plus the template-ID-keyed entry. aliasKeys should be cache-key-formatted (e.g. "namespace/alias" or bare "alias"), as returned by DeleteTemplate.
func (*AliasCache) LookupByID ¶
LookupByID looks up template info by direct template ID only (no alias resolution). Uses the same cache as alias lookups since we cache by template ID too.
func (*AliasCache) Resolve ¶
func (c *AliasCache) Resolve(ctx context.Context, identifier string, namespaceFallback string) (*AliasInfo, error)
Resolve implements the namespace resolution flowchart:
- Explicit namespace: lookup with namespace directly, no fallback
- Bare alias: try namespaceFallback first, then NULL (promoted templates)
type AliasInfo ¶
type AliasInfo struct {
TemplateID string `json:"template_id"`
TeamID uuid.UUID `json:"team_id"`
MatchedIdentifier string `json:"-"` // derived from the current lookup key, not persisted
NotFound bool `json:"not_found"` // tombstone marker for caching negative lookups
}
AliasInfo holds resolved alias information (immutable mapping data only). Mutable metadata like Public is in TemplateMetadata.
type TemplateBuildInfo ¶
type TemplateBuildInfo struct {
TeamID uuid.UUID `json:"team_id"`
TemplateID string `json:"template_id"`
BuildStatus types.BuildStatusGroup `json:"build_status"`
Reason types.BuildReason `json:"reason"`
Version *string `json:"version,omitempty"`
ClusterID uuid.UUID `json:"cluster_id"`
NodeID *string `json:"node_id,omitempty"`
}
type TemplateCache ¶
type TemplateCache struct {
// contains filtered or unexported fields
}
TemplateCache caches template+build by templateID:tag. This is a simple lookup layer - resolution happens in AliasCache.
func NewTemplateCache ¶
func NewTemplateCache(db *sqlcdb.Client, redisClient redis.UniversalClient) *TemplateCache
func (*TemplateCache) Get ¶
func (c *TemplateCache) Get(ctx context.Context, templateID string, tag *string, teamID uuid.UUID, clusterID uuid.UUID) (*api.Template, *queries.EnvBuild, error)
Get fetches a template with build by templateID and tag. Does NOT do alias resolution - callers should use ResolveAlias first. Performs access control and cluster checks.
func (*TemplateCache) GetByID ¶
GetByID looks up template info by direct template ID only (no alias resolution).
func (*TemplateCache) GetMetadata ¶
func (c *TemplateCache) GetMetadata(ctx context.Context, templateID string) (*TemplateMetadata, error)
func (*TemplateCache) Invalidate ¶
func (c *TemplateCache) Invalidate(ctx context.Context, templateID string, tag *string)
func (*TemplateCache) InvalidateAlias ¶
func (c *TemplateCache) InvalidateAlias(ctx context.Context, namespace *string, alias string)
InvalidateAlias invalidates the alias cache entry
func (*TemplateCache) InvalidateAliasesByTemplateID ¶
func (c *TemplateCache) InvalidateAliasesByTemplateID(ctx context.Context, templateID string, aliasKeys []string)
InvalidateAliasesByTemplateID invalidates alias cache entries for the given keys. aliasKeys are cache-key-formatted strings as returned by DeleteTemplate.
func (*TemplateCache) InvalidateAllTags ¶
func (c *TemplateCache) InvalidateAllTags(ctx context.Context, templateID string) []string
InvalidateAllTags invalidates the cache for the given templateID across all tags
func (*TemplateCache) ResolveAlias ¶
func (c *TemplateCache) ResolveAlias(ctx context.Context, identifier string, namespaceFallback string) (*AliasInfo, error)
ResolveAlias resolves an identifier to AliasInfo (templateID, teamID). The identifier is "namespace/alias" or just "alias" (already validated by id.ParseName). namespaceFallback is used for bare aliases (no explicit namespace).
func (*TemplateCache) ResolveAliasWithMetadata ¶
func (c *TemplateCache) ResolveAliasWithMetadata(ctx context.Context, identifier string, namespaceFallback string) (*AliasInfo, *TemplateMetadata, error)
ResolveAliasWithMetadata chains alias resolution with metadata lookup.
type TemplateInfo ¶
type TemplateInfo struct {
Template *api.Template `json:"template"`
TeamID uuid.UUID `json:"team_id"`
ClusterID uuid.UUID `json:"cluster_id"`
Build *queries.EnvBuild `json:"build"`
Tag string `json:"tag"`
}
TemplateInfo holds cached template with build information
type TemplateMetadata ¶
type TemplateMetadata struct {
TemplateID string `json:"template_id"`
TeamID uuid.UUID `json:"team_id"`
Public bool `json:"public"`
ClusterID uuid.UUID `json:"cluster_id"`
}
TemplateMetadata holds mutable template metadata (public flag, cluster assignment).
type TemplateMetadataCache ¶
type TemplateMetadataCache struct {
// contains filtered or unexported fields
}
TemplateMetadataCache caches mutable template metadata by templateID.
func NewTemplateMetadataCache ¶
func NewTemplateMetadataCache(db *sqlcdb.Client, redisClient redis.UniversalClient) *TemplateMetadataCache
func (*TemplateMetadataCache) Close ¶
func (c *TemplateMetadataCache) Close(ctx context.Context) error
func (*TemplateMetadataCache) Get ¶
func (c *TemplateMetadataCache) Get(ctx context.Context, templateID string) (*TemplateMetadata, error)
Get returns the metadata for a template, fetching from DB on cache miss.
func (*TemplateMetadataCache) Invalidate ¶
func (c *TemplateMetadataCache) Invalidate(ctx context.Context, templateID string)
Invalidate removes the cached metadata for a template.
type TemplateRef ¶
type TemplatesBuildCache ¶
type TemplatesBuildCache struct {
// contains filtered or unexported fields
}
func NewTemplateBuildCache ¶
func NewTemplateBuildCache(db *sqlcdb.Client, redisClient redis.UniversalClient) *TemplatesBuildCache
func (*TemplatesBuildCache) Get ¶
func (c *TemplatesBuildCache) Get(ctx context.Context, buildID uuid.UUID, templateID string) (TemplateBuildInfo, error)
func (*TemplatesBuildCache) Invalidate ¶
func (c *TemplatesBuildCache) Invalidate(ctx context.Context, buildID uuid.UUID)