Documentation
¶
Index ¶
- Constants
- Variables
- func HashSpecJSON(specJSON string) string
- func NormalizeResource(res coremodel.Resource) (string, string, error)
- func NormalizeSpec(spec coremodel.ResourceSpec) (specHash string, specJSON string, err error)
- func RecordBootstrapState(ctx context.Context, store *ResourceStoreAdapter, maxVersions int64, ...) error
- func ResourceFromSpecJSON(kind coremodel.ResourceKind, mesh, ruleName, specJSON string) (coremodel.Resource, error)
- type Component
- type DiffResult
- type DiffSide
- type HistorySnapshot
- type InsertRequest
- type ListResult
- type Operation
- type ResourceStoreAdapter
- func (a *ResourceStoreAdapter) GetVersion(kind coremodel.ResourceKind, resourceKey string, versionNo int64) (*Version, error)
- func (a *ResourceStoreAdapter) HistorySnapshot(kind coremodel.ResourceKind, resourceKey string) (*HistorySnapshot, error)
- func (a *ResourceStoreAdapter) InsertVersion(ctx context.Context, req InsertRequest, maxVersions int64) (*Version, error)
- func (a *ResourceStoreAdapter) LatestVersion(kind coremodel.ResourceKind, resourceKey string) (*Version, error)
- func (a *ResourceStoreAdapter) ListLatestVersions(kind coremodel.ResourceKind) ([]Version, error)
- func (a *ResourceStoreAdapter) ListVersions(kind coremodel.ResourceKind, resourceKey string) ([]Version, error)
- type Service
- func (s *Service) Append(ctx context.Context, res coremodel.Resource, op Operation, source Source, ...) (*Version, error)
- func (s *Service) DiffHistoryVersions(kind coremodel.ResourceKind, mesh, ruleName string, versionNo int64, ...) (*DiffResult, error)
- func (s *Service) Get(kind coremodel.ResourceKind, mesh, ruleName string, versionNo int64) (*Version, error)
- func (s *Service) HasHistory(kind coremodel.ResourceKind, mesh, ruleName string) (bool, error)
- func (s *Service) LatestVersion(kind coremodel.ResourceKind, mesh, ruleName string) (*Version, error)
- func (s *Service) List(kind coremodel.ResourceKind, mesh, ruleName string) (*ListResult, error)
- type Source
- type Version
Constants ¶
const ComponentType runtime.ComponentType = "rule versioning"
const DeleteSpecJSON = "{}"
DeleteSpecJSON is the canonical snapshot stored for a rule delete marker.
Variables ¶
Functions ¶
func HashSpecJSON ¶
HashSpecJSON hashes canonical spec JSON for comparison and dedup filters. It is not sufficient on its own to prove operation source.
func NormalizeSpec ¶
func NormalizeSpec(spec coremodel.ResourceSpec) (specHash string, specJSON string, err error)
NormalizeSpec returns the spec hash followed by canonical JSON for stable comparisons. It does not validate whether the spec is acceptable to the registry.
func RecordBootstrapState ¶
func RecordBootstrapState(ctx context.Context, store *ResourceStoreAdapter, maxVersions int64, res coremodel.Resource) error
RecordBootstrapState creates a baseline history entry for a rule that already exists before rule history starts tracking it. Bootstrap is not reconciliation: once any history exists, startup must not record the current registry state as an UPDATE.
func ResourceFromSpecJSON ¶
func ResourceFromSpecJSON(kind coremodel.ResourceKind, mesh, ruleName, specJSON string) (coremodel.Resource, error)
ResourceFromSpecJSON rebuilds a typed rule Resource from a stored version's spec JSON. Used by rollback to re-publish a historical snapshot through the normal ResourceManager mutation path. Only the three governor-managed rule kinds are supported. protojson is tried first (matching how specs are normalized), falling back to plain JSON for resilience.
Types ¶
type DiffResult ¶
type HistorySnapshot ¶
type InsertRequest ¶
type ListResult ¶
type ResourceStoreAdapter ¶
type ResourceStoreAdapter struct {
// contains filtered or unexported fields
}
ResourceStoreAdapter routes RuleVersion resources through the existing resource store. The striped mutexes only keep a single adapter instance internally consistent while it derives monotonically increasing version numbers for audit entries.
func NewResourceStoreAdapter ¶
func NewResourceStoreAdapter(versionStore store.ResourceStore) *ResourceStoreAdapter
func (*ResourceStoreAdapter) GetVersion ¶
func (a *ResourceStoreAdapter) GetVersion(kind coremodel.ResourceKind, resourceKey string, versionNo int64) (*Version, error)
func (*ResourceStoreAdapter) HistorySnapshot ¶
func (a *ResourceStoreAdapter) HistorySnapshot(kind coremodel.ResourceKind, resourceKey string) (*HistorySnapshot, error)
func (*ResourceStoreAdapter) InsertVersion ¶
func (a *ResourceStoreAdapter) InsertVersion(ctx context.Context, req InsertRequest, maxVersions int64) (*Version, error)
func (*ResourceStoreAdapter) LatestVersion ¶
func (a *ResourceStoreAdapter) LatestVersion(kind coremodel.ResourceKind, resourceKey string) (*Version, error)
func (*ResourceStoreAdapter) ListLatestVersions ¶
func (a *ResourceStoreAdapter) ListLatestVersions(kind coremodel.ResourceKind) ([]Version, error)
func (*ResourceStoreAdapter) ListVersions ¶
func (a *ResourceStoreAdapter) ListVersions(kind coremodel.ResourceKind, resourceKey string) ([]Version, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides rule history operations. RuleVersion entries are audit records and rollback material; live current state is still owned by ResourceManager and the backing registry.
func NewService ¶
func NewService(maxVersions int64, store *ResourceStoreAdapter) *Service
func (*Service) DiffHistoryVersions ¶
func (s *Service) DiffHistoryVersions(kind coremodel.ResourceKind, mesh, ruleName string, versionNo int64, against string) (*DiffResult, error)
func (*Service) HasHistory ¶
func (*Service) LatestVersion ¶
func (*Service) List ¶
func (s *Service) List(kind coremodel.ResourceKind, mesh, ruleName string) (*ListResult, error)
type Source ¶
type Source string
Source identifies where a rule mutation originated. Used for auditing and distinguishing user-initiated changes from system-generated ones.
const ( SourceAdmin Source = "ADMIN" // User edit via Admin UI/API // SourceUpstream marks a version imported from an upstream registry event. SourceUpstream Source = "UPSTREAM" // SourceBootstrap represents a baseline record for an existing rule when it // is first brought under version tracking. SourceBootstrap Source = "BOOTSTRAP" // SourceRollback marks a version produced by re-publishing a historical // snapshot. Rollback records a new version and does not rewrite history. SourceRollback Source = "ROLLBACK" )
type Version ¶
type Version struct {
RuleKind coremodel.ResourceKind `json:"ruleKind"`
Mesh string `json:"mesh"`
ResourceKey string `json:"resourceKey"`
RuleName string `json:"ruleName"`
VersionNo int64 `json:"versionNo"`
ContentHash string `json:"contentHash"`
SpecJSON string `json:"specJson"`
Source Source `json:"source"`
Operation Operation `json:"operation"`
Author string `json:"author"`
Reason string `json:"reason,omitempty"`
// RolledBackFromVersionNo records the historical version whose snapshot was
// re-published to produce this version. It is audit metadata only.
RolledBackFromVersionNo *int64 `json:"rolledBackFromVersionNo,omitempty"`
CreatedAt time.Time `json:"createdAt"`
RecordedAt time.Time `json:"recordedAt"`
IsLatestRecorded bool `json:"isLatestRecorded"`
}
Version represents a snapshot of a rule's spec at a point in time. Version entries are immutable after creation. Rollback appends a new version, while retention may delete the oldest entries. IsLatestRecorded is derived from history only; it is not proof that this snapshot equals the live rule.