Documentation
¶
Overview ¶
Package projectstore is the single read+mutate surface for a forge project's state. Every consumer outside the config loader reads project metadata, components, and feature flags through a Store rather than touching *config.ProjectConfig directly.
Why the indirection: the project + component + feature state is the part of forge.yaml that a future revision (the "Phase 2" source swap) wants to relocate — out of the hand-edited forge.yaml and into a denormalized, generated backing store. Routing every consumer through this one type localizes that swap to one implementation; nothing else in the tree assumes the state lives in a *config.ProjectConfig.
Interfaces at the consumer, not here. New returns a concrete *Store (accept interfaces, return structs). Callers that take the store as a dependency declare the narrow interface they actually use next to themselves — e.g. `type featureReader interface { Features() FeatureSet }` for the feature-gate helpers, `type metaReader interface { Meta() ProjectMeta }` for the namespace resolvers. A wide interface declared here that each caller used a slice of was interface bloat: 16 of its 29 methods had zero callers. The store therefore exposes only the accessors that are actually read; add a method when a consumer needs it, not before.
forge:exclude-contract projectstore is the project-state persistence store (a concrete *Store over a *config.ProjectConfig), not a bootstrap-wired Connect service. It has no Service/Deps/New contract shape, so opt out of the require-contract rule.
Index ¶
- type Component
- type FeatureSet
- type ProjectMeta
- func (m ProjectMeta) EffectiveBinary() string
- func (m ProjectMeta) EffectiveForgeVersion() string
- func (m ProjectMeta) EffectiveKind() string
- func (m ProjectMeta) IsBinaryShared() bool
- func (m ProjectMeta) IsCLIKind() bool
- func (m ProjectMeta) IsLibraryKind() bool
- func (m ProjectMeta) IsServiceKind() bool
- type Store
- func (s *Store) AppendComponent(c config.ComponentConfig)
- func (s *Store) CI() config.CIConfig
- func (s *Store) Components() []Component
- func (s *Store) Config() *config.ProjectConfig
- func (s *Store) Contracts() config.ContractsConfig
- func (s *Store) Database() config.DatabaseConfig
- func (s *Store) Features() FeatureSet
- func (s *Store) Frontends() []config.FrontendConfig
- func (s *Store) K8s() config.K8sConfig
- func (s *Store) Lint() config.LintConfig
- func (s *Store) Meta() ProjectMeta
- func (s *Store) Packs() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component struct {
Name string
Kind string // raw kind: "" | server | worker | cron | operator | binary
Path string
Ports map[string]config.PortSpec
Schedule string
ProtoPackages []string
Group string
Version string
CRDs []config.CRDConfig
}
Component is the per-component view: name, kind, ports, schedule, and the kind-specific fields. It mirrors config.ComponentConfig's read surface so a Phase-2 backing can synthesize components without a config struct.
func (Component) EffectiveKind ¶
EffectiveKind returns the lowercased kind, defaulting to "server".
func (Component) IsBinary ¶
IsBinary reports whether the component is a standalone binary subcommand.
func (Component) IsOperator ¶
IsOperator reports whether the component is a controller-runtime operator.
func (Component) PrimaryPort ¶
PrimaryPort returns the component's primary HTTP port (ports.http), or 0.
type FeatureSet ¶
type FeatureSet = config.FeaturesConfig
FeatureSet is the resolved feature state of a project — the same derived+explicit resolution config.FeaturesConfig performs. It is a thin alias today (yamlStore returns the config block directly) so every existing *Enabled() accessor keeps working; the type exists so the interface advertises features as a first-class surface for Phase 2.
type ProjectMeta ¶
type ProjectMeta struct {
Name string
ModulePath string
Kind string // raw kind: "" | service | cli | library
Binary string // raw binary mode: "" | per-service | shared
Version string
ForgeVersion string
}
ProjectMeta is the project-level metadata view: identity, kind, binary mode, and the pinned versions. The Effective*/Is* accessors mirror the config helpers so consumers get the derived forms without re-deriving.
func (ProjectMeta) EffectiveBinary ¶
func (m ProjectMeta) EffectiveBinary() string
EffectiveBinary returns the binary mode, defaulting to "per-service".
func (ProjectMeta) EffectiveForgeVersion ¶
func (m ProjectMeta) EffectiveForgeVersion() string
EffectiveForgeVersion returns the pinned forge version, defaulting to "0.0.0" for projects predating the field.
func (ProjectMeta) EffectiveKind ¶
func (m ProjectMeta) EffectiveKind() string
EffectiveKind returns the project kind, defaulting to "service".
func (ProjectMeta) IsBinaryShared ¶
func (m ProjectMeta) IsBinaryShared() bool
IsBinaryShared reports whether the project uses the shared-binary mode.
func (ProjectMeta) IsCLIKind ¶
func (m ProjectMeta) IsCLIKind() bool
IsCLIKind reports whether the project is a CLI binary.
func (ProjectMeta) IsLibraryKind ¶
func (m ProjectMeta) IsLibraryKind() bool
IsLibraryKind reports whether the project is a pure Go library.
func (ProjectMeta) IsServiceKind ¶
func (m ProjectMeta) IsServiceKind() bool
IsServiceKind reports whether the project is a Connect-RPC service.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the forge.yaml-backed project store. It wraps a *config.ProjectConfig that has already been through the loader (LoadStrict → ApplyDerivedDefaults → path/kind normalization) and projects its read surface into the view types below.
This is the ONLY type that holds a *config.ProjectConfig. Phase 2's source swap replaces (or supplements) this implementation; consumers depend on narrow interfaces they declare themselves (see the package doc), so the swap stays invisible to them.
Accept interfaces, return structs: New returns a concrete *Store rather than a wide interface. Each consumer that takes the store as a dependency declares the one- or two-method interface it actually uses (e.g. `featureReader { Features() FeatureSet }`), so there is no speculative all-methods abstraction for callers to over-depend on.
func New ¶
func New(cfg *config.ProjectConfig) *Store
New wraps an already-loaded, already-derived project config in a *Store. The caller owns loading + normalization (the cli/generator loaders); New takes the resulting config and exposes it through the view accessors. The pointer is retained (not copied) so mutation methods and Config() observe the same underlying config the loader produced.
func (*Store) AppendComponent ¶
func (s *Store) AppendComponent(c config.ComponentConfig)
AppendComponent appends a component to the project (the `forge add` server/worker/cron/operator/binary write path).
func (*Store) Components ¶
Components returns every component in declaration order, as view types.
func (*Store) Config ¶
func (s *Store) Config() *config.ProjectConfig
Config returns the underlying project config — the write/marshal + whole-config escape hatch, and the one seam Phase 2 must reconcile.
func (*Store) Contracts ¶
func (s *Store) Contracts() config.ContractsConfig
Contracts returns the `contracts:` section.
func (*Store) Database ¶
func (s *Store) Database() config.DatabaseConfig
Database returns the `database:` section.
func (*Store) Features ¶
func (s *Store) Features() FeatureSet
Features returns the resolved (derived + explicit) feature set.
func (*Store) Frontends ¶
func (s *Store) Frontends() []config.FrontendConfig
Frontends returns the declared frontend configs.
func (*Store) Meta ¶
func (s *Store) Meta() ProjectMeta
Meta returns project-level metadata (name, module, kind, versions).