Documentation
¶
Overview ¶
Package wire defines the JSON request/response shapes for the Readproof HTTP API, plus conversions to/from the domain types in internal/*. It has no server or client logic of its own — internal/api encodes/decodes these types on the server side, internal/client/remote does the same on the client side, so both sides of the wire agree on one definition.
Index ¶
- func DiffResponseToResult(w DiffResponse) diff.Result
- func ManifestFromWire(w ManifestWire) manifest.Manifest
- func MaterializationFromWire(w MaterializationWire) materialization.Materialization
- func PolicyFromWire(w PolicyWire) policy.Policy
- func ReplayResponseToResult(w ReplayResponse) replay.Result
- func ResolveResponseToResult(w ResolveResponse) resolver.ResolveResult
- func ResourceFromWire(w ResourceWire) resource.Resource
- func SnapshotFromWire(w SnapshotWire) snapshot.Snapshot
- func SourceFromWire(w SourceWire) source.Config
- func TagFromWire(w TagWire) tag.Tag
- type DiffEntryWire
- type DiffResponse
- type ErrorResponse
- type FilesystemConfigWire
- type FreshnessWire
- type GitHubConfigWire
- type HTTPConfigWire
- type HistoryResponse
- type ManifestEntryWire
- type ManifestWire
- type MaterializationWire
- type PolicyWire
- type RegisterResourceRequest
- type ReplayEntryWire
- type ReplayResponse
- type ResolveRequest
- type ResolveResourceWire
- type ResolveResponse
- type ResourceListResponse
- type ResourceWire
- type RunCommitRequest
- type RunMountRequest
- type RunMountResponse
- type RunStartRequest
- type SetTagRequest
- type SnapshotWire
- type SourceWire
- type TagListResponse
- type TagWire
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiffResponseToResult ¶
func DiffResponseToResult(w DiffResponse) diff.Result
func ManifestFromWire ¶
func ManifestFromWire(w ManifestWire) manifest.Manifest
func MaterializationFromWire ¶
func MaterializationFromWire(w MaterializationWire) materialization.Materialization
func PolicyFromWire ¶
func PolicyFromWire(w PolicyWire) policy.Policy
func ReplayResponseToResult ¶
func ReplayResponseToResult(w ReplayResponse) replay.Result
func ResolveResponseToResult ¶
func ResolveResponseToResult(w ResolveResponse) resolver.ResolveResult
func ResourceFromWire ¶
func ResourceFromWire(w ResourceWire) resource.Resource
func SnapshotFromWire ¶
func SnapshotFromWire(w SnapshotWire) snapshot.Snapshot
func SourceFromWire ¶
func SourceFromWire(w SourceWire) source.Config
func TagFromWire ¶
Types ¶
type DiffEntryWire ¶
type DiffEntryWire struct {
URI string `json:"uri"`
Status string `json:"status"`
SnapshotIDA string `json:"snapshot_id_a,omitempty"`
SnapshotIDB string `json:"snapshot_id_b,omitempty"`
// Per-side provenance: why the resolved bytes differ. Only populated for
// a side whose manifest actually contains the URI (omitzero drops the
// other side's zero timestamp rather than emitting year 1).
SourceRevisionA string `json:"source_revision_a,omitempty"`
SourceRevisionB string `json:"source_revision_b,omitempty"`
ObservedAtA time.Time `json:"observed_at_a,omitzero"`
ObservedAtB time.Time `json:"observed_at_b,omitzero"`
RefA string `json:"ref_a,omitempty"`
RefB string `json:"ref_b,omitempty"`
UnifiedDiff string `json:"unified_diff,omitempty"`
}
type DiffResponse ¶
type DiffResponse struct {
ManifestA ManifestWire `json:"manifest_a"`
ManifestB ManifestWire `json:"manifest_b"`
Entries []DiffEntryWire `json:"entries"`
}
func DiffResultToWire ¶
func DiffResultToWire(r diff.Result) DiffResponse
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type FilesystemConfigWire ¶
type FilesystemConfigWire struct {
Path string `json:"path"`
}
type FreshnessWire ¶
type GitHubConfigWire ¶
type HTTPConfigWire ¶
type HistoryResponse ¶
type HistoryResponse struct {
Snapshots []SnapshotWire `json:"snapshots"`
}
type ManifestEntryWire ¶
type ManifestEntryWire struct {
Position int `json:"position"`
URI string `json:"uri"`
// Ref is the "@<tag>" this entry was mounted by, absent for a plain URI.
Ref string `json:"ref,omitempty"`
SnapshotID string `json:"snapshot_id"`
MaterializationID string `json:"materialization_id"`
ContentHash string `json:"content_hash"`
}
type ManifestWire ¶
type ManifestWire struct {
ManifestID string `json:"manifest_id"`
RunID string `json:"run_id"`
CreatedAt time.Time `json:"created_at"`
Entries []ManifestEntryWire `json:"entries"`
}
func ManifestToWire ¶
func ManifestToWire(m manifest.Manifest) ManifestWire
type MaterializationWire ¶
type MaterializationWire struct {
ID string `json:"id"`
SnapshotID string `json:"snapshot_id"`
Strategy string `json:"strategy"`
ContentHash string `json:"content_hash"`
Bytes int64 `json:"bytes"`
CreatedAt time.Time `json:"created_at"`
}
func MaterializationToWire ¶
func MaterializationToWire(m materialization.Materialization) MaterializationWire
type PolicyWire ¶
type PolicyWire struct {
Strategy string `json:"strategy"`
MaxAgeSeconds int64 `json:"max_age_seconds,omitempty"`
PinnedSnapshotID string `json:"pinned_snapshot_id,omitempty"`
}
func PolicyToWire ¶
func PolicyToWire(p policy.Policy) PolicyWire
type RegisterResourceRequest ¶
type RegisterResourceRequest struct {
URI string `json:"uri"`
Source SourceWire `json:"source"`
Policy PolicyWire `json:"policy"`
}
RegisterResourceRequest is the POST /v1/resources body.
type ReplayEntryWire ¶
type ReplayResponse ¶
type ReplayResponse struct {
Manifest ManifestWire `json:"manifest"`
Entries []ReplayEntryWire `json:"entries"`
}
func ReplayResultToWire ¶
func ReplayResultToWire(r replay.Result) ReplayResponse
type ResolveRequest ¶
type ResolveRequest struct {
// URI may carry a trailing "@<tag>" (readproof://ns/path@prod), which
// resolves to exactly that tagged snapshot with no source fetch and no
// policy evaluation.
URI string `json:"uri"`
}
type ResolveResourceWire ¶
type ResolveResourceWire struct {
URI string `json:"uri"`
Ref string `json:"ref,omitempty"`
Policy PolicyWire `json:"policy"`
}
ResolveResourceWire carries just enough of the Resource for a resolve response — the URI, the tag ref it was resolved by (if any), and the policy that governed this resolution.
type ResolveResponse ¶
type ResolveResponse struct {
Resource ResolveResourceWire `json:"resource"`
Snapshot SnapshotWire `json:"snapshot"`
Materialization MaterializationWire `json:"materialization"`
Freshness FreshnessWire `json:"freshness"`
// Content is base64-encoded automatically by encoding/json for []byte.
Content []byte `json:"content"`
}
func ResolveResultToWire ¶
func ResolveResultToWire(result resolver.ResolveResult, now time.Time) ResolveResponse
type ResourceListResponse ¶
type ResourceListResponse struct {
Resources []ResourceWire `json:"resources"`
}
type ResourceWire ¶
type ResourceWire struct {
URI string `json:"uri"`
Namespace string `json:"namespace"`
Path string `json:"path"`
Source SourceWire `json:"source"`
Policy PolicyWire `json:"policy"`
CurrentSnapshotID string `json:"current_snapshot_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func ResourceToWire ¶
func ResourceToWire(r resource.Resource) ResourceWire
func ResourceToWireRedacted ¶
func ResourceToWireRedacted(r resource.Resource) ResourceWire
ResourceToWireRedacted is ResourceToWire with sensitive HTTP header values masked — use this for API responses (see SourceToWireRedacted).
type RunCommitRequest ¶
type RunCommitRequest struct {
RunID string `json:"run_id"`
}
type RunMountRequest ¶
type RunMountResponse ¶
type RunMountResponse struct {
Position int `json:"position"`
// Resolve.resource.ref carries the tag this mount was pinned to, and is
// what the manifest entry's "ref" will hold after commit.
Resolve ResolveResponse `json:"resolve"`
}
type RunStartRequest ¶
type RunStartRequest struct {
RunID string `json:"run_id"`
}
type SetTagRequest ¶
type SetTagRequest struct {
URI string `json:"uri"`
Tag string `json:"tag"`
SnapshotID string `json:"snapshot_id"`
}
SetTagRequest is the PUT /v1/tags body. It's an upsert: setting an existing tag re-points it at SnapshotID.
type SnapshotWire ¶
type SnapshotWire struct {
ID string `json:"id"`
ResourceURI string `json:"resource_uri"`
SourceRevision string `json:"source_revision"`
ContentHash string `json:"content_hash"`
ObservedAt time.Time `json:"observed_at"`
CreatedAt time.Time `json:"created_at"`
ContentType string `json:"content_type"`
Bytes int64 `json:"bytes"`
Provenance map[string]string `json:"provenance"`
}
func SnapshotToWire ¶
func SnapshotToWire(s snapshot.Snapshot) SnapshotWire
type SourceWire ¶
type SourceWire struct {
Kind string `json:"kind"`
Filesystem *FilesystemConfigWire `json:"filesystem,omitempty"`
GitHub *GitHubConfigWire `json:"github,omitempty"`
HTTP *HTTPConfigWire `json:"http,omitempty"`
}
func SourceToWire ¶
func SourceToWire(cfg source.Config) SourceWire
func SourceToWireRedacted ¶
func SourceToWireRedacted(cfg source.Config) SourceWire
SourceToWireRedacted is SourceToWire with sensitive HTTP header values masked — use this (never SourceToWire) when building an API *response*. SourceToWire itself stays unredacted because it's also used to encode *requests* (e.g. RegisterResourceRequest on the client side), which must carry the real header values for readproofd to authenticate with.
type TagListResponse ¶
type TagListResponse struct {
Tags []TagWire `json:"tags"`
}