Documentation
¶
Overview ¶
Package resolve implements resolution for the ServiceUnit CR.
The ServiceUnit CR stores its spec as a raw JSON contract (spec.contract). ResolveServiceUnit decodes this raw contract into a fully typed ResolvedServiceUnit — the authoritative runtime representation consumed by all downstream domain and application logic. This mirrors the decode style used by every other resolver in this repo (resolution/build, resolution/route, resolution/deployment, resolution/domain): a manual json.Unmarshal into map[string]any, not protojson into the generated proto struct.
Resolution is strict: required fields that are missing or malformed return errors immediately. All failures surface as errors — resolution never panics.
Image resolution for BUILD-type units (reading the referenced Build CR's produced image) is explicitly out of scope here — every resolver in this repo is pure/stateless, taking an already-fetched CR object with no cross-CR reads. Image stays empty for BUILD type until that's designed separately; downstream (intent/deployment/serviceunit.go) already guards this with ErrBuildNotReady.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResolvedBuildRef ¶
ResolvedBuildRef is the resolved Build CR reference for BUILD-type service units.
type ResolvedRouteRef ¶
type ResolvedRouteRef struct {
Name string
}
ResolvedRouteRef is the resolved Route CR reference for this service unit.
type ResolvedServiceUnit ¶
type ResolvedServiceUnit struct {
ServiceUnit *environmentv1alpha1.ServiceUnit
Spec *ResolvedServiceUnitSpec
}
ResolvedServiceUnit is the single runtime representation of a ServiceUnit CR. All downstream domain and application logic MUST use this type.
func ResolveServiceUnit ¶
func ResolveServiceUnit(su *environmentv1alpha1.ServiceUnit) (*ResolvedServiceUnit, error)
ResolveServiceUnit decodes the raw JSON contract from the ServiceUnit CR spec into a ResolvedServiceUnit. Returns an error if the CR is nil, the contract is absent, or the type-specific required fields are missing.
type ResolvedServiceUnitSpec ¶
type ResolvedServiceUnitSpec struct {
// Type discriminates between STATIC, BUILD, and SUPPLYCHAIN source modes.
Type commoncontractv1.ServiceUnitType_ServiceUnitType
// Image is the fully qualified static image reference.
// Present only when Type is SERVICE_UNIT_TYPE_STATIC. Left empty for
// BUILD type — see package doc for why that injection is out of scope here.
Image string
// ImagePullSecret names the registry credential the image is pulled
// with. The contract does not declare it and resolution leaves it
// empty: for BUILD type it is the secret the source Build already
// declared, injected together with the image.
ImagePullSecret string
// BuildRef is the cross-CR reference to the source Build.
// Present only when Type is SERVICE_UNIT_TYPE_BUILD.
BuildRef *ResolvedBuildRef
ContainerPort int32
Size int32
AppType string
StackType string
// RouteRef is the optional cross-CR reference to the Route CR exposing
// this unit. Nil when the contract declares no route.
RouteRef *ResolvedRouteRef
}
ResolvedServiceUnitSpec is the decoded and validated ServiceUnit spec.
Type stores the nested enum value (commoncontractv1.ServiceUnitType_ServiceUnitType) rather than the proto wrapper message — this allows direct comparison in type switches without dereferencing a pointer.