resource

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("resource: not found")

ErrNotFound is returned by Store.Get/UpdateCurrentSnapshot when a Resource isn't registered.

Functions

func SplitRef

func SplitRef(raw string) (uri, ref string, err error)

SplitRef splits a possibly ref-bearing reference — readproof://<ns>/<path> or readproof://<ns>/<path>@<ref> — into its bare URI and ref. A bare URI returns ref "". Only the LAST "@" is treated as the ref delimiter; whatever precedes it must be a valid bare URI, so a stray second "@" is an error rather than a silently mangled path. This is the single entry point for user-supplied references (CLI args, API request bodies); everything downstream works with the bare URI plus an explicit ref, never with the combined string.

Types

type Resource

type Resource struct {
	URI          string
	Namespace    string
	Path         string
	SourceID     string
	SourceConfig source.Config
	PolicyID     string
	Policy       policy.Policy

	// CurrentSnapshotID is "" until the first successful resolve.
	CurrentSnapshotID string

	CreatedAt time.Time
	UpdatedAt time.Time
}

Resource is the stable logical identity consumed by applications.

type Store

type Store interface {
	Create(ctx context.Context, r Resource) error
	Get(ctx context.Context, uri string) (Resource, error)
	List(ctx context.Context) ([]Resource, error)
	UpdateCurrentSnapshot(ctx context.Context, uri, snapshotID string) error
}

Store is the single public port over a Resource's sources+policies+ resources rows — callers never juggle three stores for one Resource.

type URI

type URI struct {
	Namespace string
	Path      string
}

URI is a parsed readproof://<namespace>/<path> logical identifier.

func ParseURI

func ParseURI(raw string) (URI, error)

ParseURI parses a *bare* readproof://<namespace>/<path> identifier. It rejects anything carrying a trailing "@<ref>": "@" is reserved for tag refs, and silently folding one into the path would make `readproof://ns/p@prod` register or look up a resource literally named "p@prod". Callers handling a user-supplied reference that may carry a ref must run it through SplitRef first and parse the bare URI SplitRef returns.

func (URI) String

func (u URI) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL