Documentation
¶
Overview ¶
Package sori provides OCI-based packaging, push/fetch, and metadata helpers for reference datasets.
Preferred entrypoint:
- Load configuration with LoadConfig
- Build a Client with Config.NewClient or NewClient
- Package with Client.PackageVolumeWithOptions
- Push with Client.PushPackagedVolumeWithOptions
- Build generic metadata with BuildArtifactMetadata
The Client path plus generic packaging, push, fetch, metadata, and core error/option surfaces form the preferred core path and the current stable core candidate.
NodeVault-oriented data spec, registration, and referrer helpers remain in this package for compatibility, but they are still experimental and are not yet part of the frozen core contract.
This package is intentionally in a soft-boundary stage: core and higher-level experimental helpers share the same package path today, but not the same stability level. Some experimental areas may be reevaluated before any future stable promotion.
Index ¶
- Constants
- Variables
- func MarshalSpec(v interface{}) ([]byte, error)
- func TarGzDir(fsDir, prefixPath string) ([]byte, error)
- func UntarGzDir(gzipStream io.Reader, dest string) error
- func ValidateVolumeDir(volDir string) ([]byte, error)
- type ArtifactContents
- type ArtifactDisplay
- type ArtifactFormat
- type ArtifactIdentity
- type ArtifactLocation
- type ArtifactMetadata
- type ArtifactMetadataInput
- type ArtifactSource
- type AuthConfig
- type Client
- func (c *Client) EnsureVolumeFromRemote(ctx context.Context, destRoot string, target RemoteTarget, tag string) (*VolumeIndex, error)
- func (c *Client) FetchVolume(ctx context.Context, destRoot, repo, tag string, opts FetchOptions) (*VolumeIndex, error)
- func (c *Client) FetchVolumeFresh(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)
- func (c *Client) FetchVolumeFromRemote(ctx context.Context, destRoot string, target RemoteTarget, tag string, ...) (*VolumeIndex, error)
- func (c *Client) FetchVolumeParallel(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)
- func (c *Client) FetchVolumeSequential(ctx context.Context, destRoot, repo, tag string) (*VolumeIndex, error)
- func (c *Client) LocalStorePath() string
- func (c *Client) PackageVolume(ctx context.Context, req PackageRequest) (*PackageResult, error)
- func (c *Client) PackageVolumeWithOptions(ctx context.Context, req PackageRequest, opts PackageOptions) (*PackageResult, error)
- func (c *Client) PublishVolume(ctx context.Context, vi *VolumeIndex, volPath, volName string, ...) (*VolumeIndex, error)
- func (c *Client) PublishVolumeFromDir(ctx context.Context, volDir, displayName, tag string) (*PackageResult, error)
- func (c *Client) PushPackagedVolume(ctx context.Context, pkg *PackageResult, target RemoteTarget) (*PushResult, error)
- func (c *Client) PushPackagedVolumeWithOptions(ctx context.Context, pkg *PackageResult, opts PushOptions) (*PushResult, error)
- type ClientOption
- type CollectionManager
- func (m *CollectionManager) AddOrUpdate(v VolumeEntry) error
- func (m *CollectionManager) Flush() error
- func (m *CollectionManager) Get(ref string) (VolumeEntry, bool)
- func (m *CollectionManager) GetSnapshot() VolumeCollection
- func (m *CollectionManager) PublishVolumeFromDir(ctx context.Context, volDir, displayName, tag string) error
- func (m *CollectionManager) Remove(ref string) (bool, error)
- type Config
- type ConfigBlob
- type DataCatalog
- type DataDisplay
- type DataIdentity
- type DataProvenance
- type DataRegisterRequest
- type DataRegisterResponse
- type DataSection
- type DataSpec
- type DisplaySpec
- type Error
- type ErrorKind
- type FetchOptions
- type LocalStore
- type PackageOptions
- type PackageRequest
- type PackageResult
- type Partition
- type PushOptions
- type PushResult
- type ReferrerOptions
- type ReferrerPushResult
- type ReferrerTarget
- type RegisteredDataDefinition
- type RemoteStore
- type RemoteTarget
- type SpecReferrerResult
- func PushDataSpecReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, ...) (SpecReferrerResult, error)
- func PushSecurityReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, ...) (SpecReferrerResult, error)
- func PushToolProfileReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, ...) (SpecReferrerResult, error)
- func PushToolSpecReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, ...) (SpecReferrerResult, error)
- type TLSConfig
- type VolumeCollection
- type VolumeEntry
- type VolumeIndex
Examples ¶
Constants ¶
const ( // MediaTypeToolSpec is the current media type used by the experimental tool // referrer helpers. MediaTypeToolSpec = "application/vnd.nodevault.toolspec.v1+json" // MediaTypeDataSpec is the current media type used by the experimental data // referrer helpers. MediaTypeDataSpec = "application/vnd.nodevault.dataspec.v1+json" // MediaTypeToolProfile is the media type for observed dry-run profile referrers. // It carries validationHash, observedIoProfile, observedResourceProfile, and // contractCheck for a given tool image. MediaTypeToolProfile = "application/vnd.nodevault.toolprofile.v1+json" // MediaTypeSecurityScan is the media type for security scan result referrers. // It carries CVE summary, scanner identity, and policy evaluation results // for a given tool image. MediaTypeSecurityScan = "application/vnd.nodevault.security.v1+json" )
const ( ConfigBlobJson = "configblob.json" CollectionJson = "volume-collection.json" VolumeIndexJson = "volume-index.json" )
const ArtifactMetadataSchemaVersion = "sori.artifact.v1"
Variables ¶
var ( // ErrValidation marks validation failures on the exported core error path. ErrValidation = &Error{Kind: KindValidation} // ErrNotFound marks missing-resource failures on the exported core error path. ErrNotFound = &Error{Kind: KindNotFound} // ErrConflict marks state conflicts on the exported core error path. ErrConflict = &Error{Kind: KindConflict} // ErrIntegrity marks integrity or decode failures on the exported core error path. ErrIntegrity = &Error{Kind: KindIntegrity} // ErrTransport marks IO, network, or remote-transport failures on the exported core error path. ErrTransport = &Error{Kind: KindTransport} // ErrAuth marks authentication and authorization failures on the exported core error path. ErrAuth = &Error{Kind: KindAuth} )
var Log = logrus.New()
Functions ¶
func MarshalSpec ¶
MarshalSpec marshals the payload used by the experimental referrer helpers.
Experimental: this helper remains available for the current referrer API but is not yet part of the frozen core contract.
func ValidateVolumeDir ¶
Types ¶
type ArtifactContents ¶
type ArtifactContents struct {
Format string `json:"format,omitempty"`
TotalSize int64 `json:"total_size"`
CreatedAt string `json:"created_at,omitempty"`
Partitions []Partition `json:"partitions,omitempty"`
}
ArtifactContents describes packaged contents in the generic core model.
type ArtifactDisplay ¶
type ArtifactDisplay struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Category string `json:"category,omitempty"`
Tags []string `json:"tags,omitempty"`
}
ArtifactDisplay holds display-oriented metadata in the generic core model.
type ArtifactFormat ¶ added in v0.7.1
type ArtifactFormat int
ArtifactFormat selects the OCI artifact layout used during packaging. The zero value is ArtifactFormatLegacy, preserving backward compatibility.
const ( // ArtifactFormatLegacy packages each partition as a gzip-compressed tar // layer. This is the original sori format and is always supported on fetch. ArtifactFormatLegacy ArtifactFormat = iota // ArtifactFormatChunkedCAS packages files as fixed-size raw chunks with a // chunk-index.json manifest. Fetch requires a sori client at v0.7.0 or later. ArtifactFormatChunkedCAS )
type ArtifactIdentity ¶
type ArtifactIdentity struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
StableRef string `json:"stable_ref"`
}
ArtifactIdentity identifies the packaged artifact in the generic core model.
type ArtifactLocation ¶
type ArtifactLocation struct {
LocalTag string `json:"local_tag,omitempty"`
Repository string `json:"repository,omitempty"`
Reference string `json:"reference,omitempty"`
ManifestDigest string `json:"manifest_digest,omitempty"`
ConfigDigest string `json:"config_digest,omitempty"`
}
ArtifactLocation describes where the packaged artifact lives in the generic core model.
type ArtifactMetadata ¶
type ArtifactMetadata struct {
SchemaVersion string `json:"schema_version"`
Kind string `json:"kind"`
Identity ArtifactIdentity `json:"identity"`
Display ArtifactDisplay `json:"display"`
Source ArtifactSource `json:"source"`
Location ArtifactLocation `json:"location"`
Contents ArtifactContents `json:"contents"`
Annotations map[string]string `json:"annotations,omitempty"`
Extras map[string]interface{} `json:"extras,omitempty"`
}
ArtifactMetadata is the generic metadata model for the preferred core path.
This type is intended to remain the long-lived metadata surface even while higher-level NodeVault-oriented adapters stay experimental.
func BuildArtifactMetadata ¶
func BuildArtifactMetadata(input ArtifactMetadataInput, pkg *PackageResult, push *PushResult) (*ArtifactMetadata, error)
BuildArtifactMetadata derives generic metadata from the preferred core packaging and push results.
This function is part of the intended long-lived core surface and is the preferred metadata entrypoint for new code.
type ArtifactMetadataInput ¶
type ArtifactMetadataInput struct {
Kind string
Name string
Version string
StableRef string
DisplayName string
Description string
Category string
Tags []string
Format string
SourceDir string
SourceURI string
Annotations map[string]string
Extras map[string]interface{}
}
ArtifactMetadataInput is the input contract for BuildArtifactMetadata in the preferred core path.
type ArtifactSource ¶
type ArtifactSource struct {
SourceDir string `json:"source_dir,omitempty"`
SourceURI string `json:"source_uri,omitempty"`
}
ArtifactSource describes the source location for the generic core model.
type AuthConfig ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the preferred entrypoint for the core packaging, push, and fetch path.
Client is the intended long-lived core surface for new code.
Example (FetchVolume) ¶
client := NewClient(WithLocalStorePath(filepath.Join("/tmp", "sori-oci")))
_, _ = client.FetchVolume(context.Background(), "/tmp/restored", "/tmp/sori-oci", "example.v1", FetchOptions{
Concurrency: 1,
RequireEmptyDestination: true,
})
fmt.Println("fetch options supported")
Output: fetch options supported
Example (PackagePushMetadata) ¶
client := NewClient(WithLocalStorePath("/tmp/sori-oci"))
pkg, _ := client.PackageVolumeWithOptions(context.Background(), PackageRequest{
SourceDir: "./test-vol",
DisplayName: "HumanRef GRCh38",
Tag: "grch38.v1.0.0",
Dataset: "grch38-reference",
Version: "v1.0.0",
}, PackageOptions{})
metadata, _ := BuildArtifactMetadata(ArtifactMetadataInput{
Kind: "dataset",
Name: "grch38-reference",
Version: "v1.0.0",
DisplayName: "HumanRef GRCh38",
Description: "Human reference genome",
SourceDir: "./test-vol",
}, pkg, nil)
fmt.Println(pkg.LocalTag)
fmt.Println(metadata.Identity.StableRef)
Output: grch38.v1.0.0 grch38-reference@v1.0.0
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
NewClient constructs the preferred core client path for packaging, pushing, and fetching datasets.
This constructor is part of the intended long-lived core surface.
func (*Client) EnsureVolumeFromRemote ¶ added in v0.7.2
func (c *Client) EnsureVolumeFromRemote(ctx context.Context, destRoot string, target RemoteTarget, tag string) (*VolumeIndex, error)
EnsureVolumeFromRemote fetches a packaged dataset from a remote OCI registry into destRoot only if the local content is absent or out of date.
It resolves the remote tag to its manifest digest and compares it with the VolumeRef stored in destRoot/volume-index.json. If they match the download is skipped and the returned VolumeIndex has Skipped set to true, reducing a typical k8s init-container re-check to a single network round-trip.
If destRoot does not exist or contains a different version, the dataset is fetched via the 3-phase atomic overwrite path so the transition is safe under concurrent reads.
This is the recommended call pattern for k8s init containers:
vi, err := client.EnsureVolumeFromRemote(ctx, "/data/refs/hg38-star", target, "hg38-2.7.10a")
if vi != nil && vi.Skipped {
// already up to date, no download performed
}
func (*Client) FetchVolume ¶
func (c *Client) FetchVolume(ctx context.Context, destRoot, repo, tag string, opts FetchOptions) (*VolumeIndex, error)
FetchVolume fetches a packaged dataset using the preferred client-based core path and core fetch options.
When RequireEmptyDestination is true, extraction uses a staging directory so that destRoot is either left untouched (on failure) or fully populated (on success), preventing partial-extraction states.
When AtomicOverwrite is true, the 3-phase overwrite path is used: the new content is extracted to a staging sibling, the existing destRoot is renamed to a backup sibling, then staging is renamed to destRoot.
func (*Client) FetchVolumeFresh ¶
func (c *Client) FetchVolumeFresh(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)
FetchVolumeFresh fetches a packaged dataset into destRoot using the staging path: destRoot must not exist before the call. On success destRoot is fully populated; on failure it is left absent, never partial.
It is a convenience wrapper over FetchVolume with RequireEmptyDestination:true.
func (*Client) FetchVolumeFromRemote ¶
func (c *Client) FetchVolumeFromRemote(ctx context.Context, destRoot string, target RemoteTarget, tag string, opts FetchOptions) (*VolumeIndex, error)
FetchVolumeFromRemote fetches a packaged dataset from a remote OCI registry into destRoot.
Staging is always used: content is extracted to a sibling staging directory and renamed to destRoot only on full success, preventing partial-extraction states. By default destRoot must not exist. Set AtomicOverwrite in opts to replace an existing destRoot via the 3-phase backup-swap path.
RequireEmptyDestination and AtomicOverwrite are mutually exclusive and return ErrValidation if both are set.
func (*Client) FetchVolumeParallel ¶
func (c *Client) FetchVolumeParallel(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)
FetchVolumeParallel fetches a packaged dataset using the preferred client path with explicit parallelism.
func (*Client) FetchVolumeSequential ¶
func (c *Client) FetchVolumeSequential(ctx context.Context, destRoot, repo, tag string) (*VolumeIndex, error)
FetchVolumeSequential fetches a packaged dataset using the preferred client path with sequential extraction.
func (*Client) LocalStorePath ¶
LocalStorePath returns the local OCI store path used by the client.
func (*Client) PackageVolume ¶
func (c *Client) PackageVolume(ctx context.Context, req PackageRequest) (*PackageResult, error)
PackageVolume packages a dataset using the preferred client-based core path.
func (*Client) PackageVolumeWithOptions ¶
func (c *Client) PackageVolumeWithOptions(ctx context.Context, req PackageRequest, opts PackageOptions) (*PackageResult, error)
PackageVolumeWithOptions packages a dataset using the preferred client-based core path with explicit core packaging options.
func (*Client) PublishVolume ¶
func (c *Client) PublishVolume(ctx context.Context, vi *VolumeIndex, volPath, volName string, configBlob []byte) (*VolumeIndex, error)
PublishVolume publishes an already-built VolumeIndex through the client path.
This method exists for callers that still operate at the VolumeIndex level, but the preferred core path for new code is PackageVolumeWithOptions.
func (*Client) PublishVolumeFromDir ¶
func (c *Client) PublishVolumeFromDir(ctx context.Context, volDir, displayName, tag string) (*PackageResult, error)
PublishVolumeFromDir is a convenience wrapper over the preferred client packaging path for callers that start from a directory.
func (*Client) PushPackagedVolume ¶
func (c *Client) PushPackagedVolume(ctx context.Context, pkg *PackageResult, target RemoteTarget) (*PushResult, error)
PushPackagedVolume pushes a packaged dataset using the preferred client-based core path.
func (*Client) PushPackagedVolumeWithOptions ¶
func (c *Client) PushPackagedVolumeWithOptions(ctx context.Context, pkg *PackageResult, opts PushOptions) (*PushResult, error)
PushPackagedVolumeWithOptions pushes a packaged dataset using the preferred client-based core path with explicit core push options.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption configures the preferred Client-based core path.
func WithClock ¶
func WithClock(now func() time.Time) ClientOption
WithClock injects the clock used by client flows that need timestamps.
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient injects the HTTP client used by the preferred core push path.
func WithLocalStorePath ¶
func WithLocalStorePath(path string) ClientOption
WithLocalStorePath configures the local OCI store path used by the preferred core client path.
type CollectionManager ¶
type CollectionManager struct {
// contains filtered or unexported fields
}
func NewCollectionManager ¶
func NewCollectionManager(rootDir string, initial ...VolumeEntry) (*CollectionManager, error)
func (*CollectionManager) AddOrUpdate ¶
func (m *CollectionManager) AddOrUpdate(v VolumeEntry) error
func (*CollectionManager) Flush ¶
func (m *CollectionManager) Flush() error
func (*CollectionManager) Get ¶
func (m *CollectionManager) Get(ref string) (VolumeEntry, bool)
func (*CollectionManager) GetSnapshot ¶
func (m *CollectionManager) GetSnapshot() VolumeCollection
func (*CollectionManager) PublishVolumeFromDir ¶
func (m *CollectionManager) PublishVolumeFromDir(ctx context.Context, volDir, displayName, tag string) error
type Config ¶
type Config struct {
Local LocalStore `json:"local"`
Remotes []RemoteStore `json:"remotes"`
}
func InitConfig
deprecated
func LoadConfig ¶
LoadConfig reads and validates the JSON configuration file used by the preferred core client path.
func (*Config) EnsureDir ¶
EnsureDir creates the local OCI store directory defined in the config if it does not already exist. Returns ErrTransport if the directory cannot be created (e.g. insufficient permissions on the parent path).
func (*Config) NewClient ¶
func (conf *Config) NewClient(opts ...ClientOption) *Client
NewClient constructs the preferred core client path from configuration.
type ConfigBlob ¶
type ConfigBlob map[string]interface{}
type DataCatalog ¶
type DataCatalog struct {
// contains filtered or unexported fields
}
DataCatalog is a local JSON-backed catalog for the current experimental registration model.
Experimental: this helper remains in the root package for compatibility but is not yet part of the intended long-lived core surface.
func NewDataCatalog ¶
func NewDataCatalog(rootDir string) *DataCatalog
NewDataCatalog constructs the local catalog used by the experimental registration helpers.
Experimental: this helper is not yet part of the frozen core contract.
func (*DataCatalog) Get ¶
func (c *DataCatalog) Get(casHash string) (*RegisteredDataDefinition, error)
Get returns one entry from the local experimental catalog by CAS hash.
Experimental: this method is not yet part of the frozen core contract.
func (*DataCatalog) List ¶
func (c *DataCatalog) List(stableRef string) ([]RegisteredDataDefinition, error)
List returns entries from the local experimental catalog, optionally filtered by stableRef.
Experimental: this method is not yet part of the frozen core contract.
func (*DataCatalog) Register ¶
func (c *DataCatalog) Register(_ context.Context, req DataRegisterRequest, pkg *PackageResult, push *PushResult) (*DataRegisterResponse, error)
Register stores or updates a registration record in the local experimental catalog.
Experimental: this method is not yet part of the frozen core contract.
type DataDisplay ¶
type DataDisplay struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
}
DataDisplay describes the presentation-oriented section of an experimental DataSpec.
Experimental: this shape is NodeVault-oriented and may change.
type DataIdentity ¶
type DataIdentity struct {
StableRef string `json:"stableRef"`
Dataset string `json:"dataset,omitempty"`
Version string `json:"version,omitempty"`
}
DataIdentity describes the logical identity section of an experimental DataSpec.
Experimental: this shape is NodeVault-oriented and may change before any stable promotion.
type DataProvenance ¶
type DataProvenance struct {
PackagedAt string `json:"packagedAt"`
SourceDir string `json:"sourceDir"`
LocalTag string `json:"localTag"`
}
DataProvenance describes the packaging provenance section of an experimental DataSpec.
Experimental: this shape is NodeVault-oriented and may change.
type DataRegisterRequest ¶
type DataRegisterRequest struct {
RequestID string `json:"request_id,omitempty"`
DataName string `json:"data_name"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
Format string `json:"format,omitempty"`
SourceURI string `json:"source_uri,omitempty"`
Checksum string `json:"checksum,omitempty"`
StorageURI string `json:"storage_uri,omitempty"`
StableRef string `json:"stable_ref,omitempty"`
Display DisplaySpec `json:"display,omitempty"`
}
DataRegisterRequest is the current registration input model used by the experimental registration helpers.
Experimental: this shape may still change as the NodeVault-facing contract is reviewed.
type DataRegisterResponse ¶
type DataRegisterResponse struct {
CASHash string `json:"cas_hash"`
Data *RegisteredDataDefinition `json:"data"`
}
DataRegisterResponse is returned by the experimental registration helpers.
Experimental: this type is not yet part of the frozen core contract.
func RegisterPackagedData ¶
func RegisterPackagedData(ctx context.Context, rootDir string, req DataRegisterRequest, pkg *PackageResult, push *PushResult) (*DataRegisterResponse, error)
RegisterPackagedData stores a registration record for pkg and push in the current experimental registration catalog.
Experimental: prefer the core client path plus BuildArtifactMetadata unless a caller explicitly needs the current registration model.
type DataSection ¶
type DataSection struct {
ArtifactType string `json:"artifactType"`
Repository string `json:"repository,omitempty"`
Reference string `json:"reference,omitempty"`
ManifestDigest string `json:"manifestDigest,omitempty"`
ConfigDigest string `json:"configDigest"`
TotalSize int64 `json:"totalSize"`
Partitions []Partition `json:"partitions"`
}
DataSection describes the artifact location and contents section of an experimental DataSpec.
Experimental: this shape is not yet part of the frozen core contract.
type DataSpec ¶
type DataSpec struct {
Identity DataIdentity `json:"identity"`
Data DataSection `json:"data"`
Display DataDisplay `json:"display"`
Provenance DataProvenance `json:"provenance"`
}
DataSpec is a NodeVault-oriented metadata view derived from ArtifactMetadata.
Experimental: this type is kept in the root package for now, but it is not yet part of the frozen core contract and may move or change as the NodeVault-facing model settles.
func ArtifactMetadataToDataSpec ¶
func ArtifactMetadataToDataSpec(meta *ArtifactMetadata) *DataSpec
ArtifactMetadataToDataSpec converts generic ArtifactMetadata into the current NodeVault-oriented DataSpec view.
Experimental: this adapter is intentionally outside the preferred core path and is not yet part of the frozen core contract.
func BuildDataSpec ¶
func BuildDataSpec(pkg *PackageResult, push *PushResult, req PackageRequest) (*DataSpec, error)
BuildDataSpec derives a NodeVault-oriented DataSpec from the generic core metadata inputs.
Experimental: prefer BuildArtifactMetadata for the stable core candidate path. This helper remains available for callers that still need the current DataSpec shape.
type DisplaySpec ¶
type DisplaySpec struct {
Label string `json:"label,omitempty"`
Description string `json:"description,omitempty"`
Category string `json:"category,omitempty"`
Tags []string `json:"tags,omitempty"`
}
DisplaySpec is the display-oriented portion of the experimental registration model.
Experimental: this type is NodeVault-oriented and is not yet part of the frozen core contract.
type ErrorKind ¶
type ErrorKind string
ErrorKind classifies exported core errors returned by the root package.
type FetchOptions ¶
type FetchOptions struct {
Concurrency int
RequireEmptyDestination bool
// AtomicOverwrite enables the 3-phase overwrite path:
// Phase 1 — extract to a staging sibling of destRoot
// Phase 2 — rename existing destRoot to a backup sibling (if present)
// Phase 3 — rename staging to destRoot (atomic commit)
// Cleanup — remove backup (best-effort; warning logged on failure)
//
// On Phase 3 failure a best-effort rollback renames the backup back to
// destRoot. If that rollback also fails, destRoot may be absent; the
// error message includes the staging and backup paths for manual recovery.
//
// AtomicOverwrite and RequireEmptyDestination are mutually exclusive;
// setting both returns ErrValidation.
AtomicOverwrite bool
// SkipIfCurrent, when true, resolves the remote tag to its manifest digest
// and compares it with the VolumeRef stored in destRoot/volume-index.json.
// If they match the fetch is skipped and the returned VolumeIndex has
// Skipped set to true. If destRoot does not contain a valid
// volume-index.json, or VolumeRef is empty, the fetch proceeds normally.
//
// The typical k8s init-container pattern is:
// FetchOptions{AtomicOverwrite: true, SkipIfCurrent: true}
//
// SkipIfCurrent and RequireEmptyDestination are mutually exclusive;
// setting both returns ErrValidation.
SkipIfCurrent bool
}
FetchOptions controls the preferred core fetch path.
This option surface is part of the stable core candidate contract.
type LocalStore ¶
type PackageOptions ¶
type PackageOptions struct {
ConfigBlob []byte
RequireConfigBlob bool
// Format selects the artifact layout. Defaults to ArtifactFormatLegacy.
Format ArtifactFormat
// DatasetMetadata is the serialised dataset-metadata.json to include as a
// dedicated OCI layer (mediaType application/vnd.sori.dataset.metadata.v1+json).
// Optional: fetch works without it; catalog exposure is degraded without it.
DatasetMetadata []byte
// Progress receives per-chunk progress events. Pass nil to suppress.
// Use chunked.ProgressFunc and chunked.ChunkProgress for the callback type.
Progress chunked.ProgressFunc
}
PackageOptions controls the preferred core packaging path.
This option surface is part of the stable core candidate contract.
type PackageRequest ¶
type PackageRequest struct {
SourceDir string `json:"source_dir"`
DisplayName string `json:"display_name"`
Tag string `json:"tag"`
Dataset string `json:"dataset,omitempty"`
Version string `json:"version,omitempty"`
StableRef string `json:"stable_ref,omitempty"`
Description string `json:"description,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
ConfigBlob []byte `json:"-"`
}
PackageRequest is the input to the preferred core packaging path.
This request type is intended to remain part of the long-lived core surface used by Client.PackageVolume and PackageVolumeToStore.
type PackageResult ¶
type PackageResult struct {
StableRef string `json:"stable_ref"`
LocalTag string `json:"local_tag"`
ManifestDigest string `json:"manifest_digest"`
ConfigDigest string `json:"config_digest"`
TotalSize int64 `json:"total_size"`
CreatedAt string `json:"created_at"`
Partitions []Partition `json:"partitions"`
VolumeIndex VolumeIndex `json:"volume_index"`
}
PackageResult is the output of the preferred core packaging path.
This result type is part of the stable core candidate surface used by the client, metadata builder, and remote push flow.
func PackageVolume
deprecated
func PackageVolume(ctx context.Context, req PackageRequest) (*PackageResult, error)
Deprecated: prefer Config.NewClient followed by Client.PackageVolume or Client.PackageVolumeWithOptions so new code stays on the preferred core path.
func PackageVolumeToStore ¶
func PackageVolumeToStore(ctx context.Context, localStorePath string, req PackageRequest) (*PackageResult, error)
PackageVolumeToStore packages a dataset into the given local OCI store using the preferred core packaging contract.
type Partition ¶
type Partition struct {
Name string `json:"name"`
Path string `json:"path"`
ManifestRef string `json:"manifest_ref"`
CreatedAt string `json:"created_at"`
Compression string `json:"compression"`
}
Partition describes one partition entry inside the packaged dataset.
Partition is part of the preferred core path because it is used by the core packaging, push, and fetch results.
type PushOptions ¶
type PushOptions struct {
Target RemoteTarget
}
PushOptions controls the preferred core push path.
This option surface is part of the stable core candidate contract.
type PushResult ¶
type PushResult struct {
Reference string `json:"reference"`
Repository string `json:"repository"`
Tag string `json:"tag"`
ManifestDigest string `json:"manifest_digest"`
}
PushResult reports the remote artifact identity returned by the preferred core push path.
This result type is part of the stable core candidate surface.
func PushLocalToRemote
deprecated
func PushPackagedVolume ¶
func PushPackagedVolume(ctx context.Context, localStorePath string, pkg *PackageResult, target RemoteTarget) (*PushResult, error)
PushPackagedVolume copies a packaged artifact from the local OCI store to a remote registry using the preferred core push contract.
type ReferrerOptions ¶
type ReferrerOptions struct {
Target RemoteTarget
}
ReferrerOptions controls the experimental referrer helpers.
Experimental: this option surface belongs to the referrer API and is not yet part of the frozen core contract.
type ReferrerPushResult ¶
type ReferrerPushResult struct {
SubjectDigest string `json:"subject_digest"`
ManifestDigest string `json:"manifest_digest"`
ConfigDigest string `json:"config_digest"`
Repository string `json:"repository"`
ArtifactType string `json:"artifact_type"`
}
ReferrerPushResult reports the manifest uploaded by the experimental referrer helpers.
Experimental: this type is NodeVault-oriented and is not yet part of the intended long-lived core contract.
func PushRemoteDataSpecReferrer ¶
func PushRemoteDataSpecReferrer(ctx context.Context, push *PushResult, target RemoteTarget, spec *DataSpec) (*ReferrerPushResult, error)
PushRemoteDataSpecReferrer uploads an experimental DataSpec referrer for the pushed artifact identified by push.
Experimental: this helper is NodeVault-oriented and is not yet part of the intended long-lived core contract.
type ReferrerTarget ¶
ReferrerTarget is the target interface accepted by the experimental referrer helpers.
Experimental: this target abstraction is tied to the current referrer helpers and is not yet part of the frozen core contract.
func NewReferrerLocalStore ¶
func NewReferrerLocalStore(path string) (ReferrerTarget, error)
NewReferrerLocalStore opens an OCI layout store for the experimental referrer helpers.
Experimental: this helper is specific to the current referrer API.
func NewReferrerRemoteRepository ¶
func NewReferrerRemoteRepository(repoRef string, plainHTTP bool, credential *auth.Credential) (ReferrerTarget, error)
NewReferrerRemoteRepository creates a remote repository for the experimental referrer helpers.
Experimental: this helper is specific to the current referrer API.
type RegisteredDataDefinition ¶
type RegisteredDataDefinition struct {
CASHash string `json:"cas_hash"`
DataName string `json:"data_name"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
Format string `json:"format,omitempty"`
SourceURI string `json:"source_uri,omitempty"`
Checksum string `json:"checksum,omitempty"`
StorageURI string `json:"storage_uri,omitempty"`
StableRef string `json:"stable_ref"`
Display DisplaySpec `json:"display,omitempty"`
RegisteredAt int64 `json:"registered_at"`
LifecyclePhase string `json:"lifecycle_phase"`
IntegrityHealth string `json:"integrity_health"`
}
RegisteredDataDefinition is the current persisted view of the experimental registration model.
Experimental: this type is not yet part of the frozen core contract.
func ArtifactMetadataToRegisteredDataDefinition ¶
func ArtifactMetadataToRegisteredDataDefinition(meta *ArtifactMetadata, req DataRegisterRequest) *RegisteredDataDefinition
ArtifactMetadataToRegisteredDataDefinition adapts generic ArtifactMetadata into the current experimental registration shape.
Experimental: this adapter is not yet part of the frozen core contract.
func BuildRegisteredDataDefinition ¶
func BuildRegisteredDataDefinition(req DataRegisterRequest, pkg *PackageResult, push *PushResult) (*RegisteredDataDefinition, error)
BuildRegisteredDataDefinition builds the current experimental registration view from the generic core metadata inputs.
Experimental: this adapter remains available for callers that still need the registration model, but it is not yet part of the frozen core contract.
Example ¶
ExampleBuildRegisteredDataDefinition demonstrates the current experimental registration helper layered on top of the core packaging result.
pkg := &PackageResult{
LocalTag: "dataset.v1",
ManifestDigest: "sha256:local",
ConfigDigest: "sha256:config",
StableRef: "dataset@v1",
}
def, _ := BuildRegisteredDataDefinition(DataRegisterRequest{
DataName: "dataset",
Version: "v1",
Description: "example dataset",
Format: "FASTA",
}, pkg, nil)
fmt.Println(def.DataName)
fmt.Println(def.StableRef)
Output: dataset dataset@v1
type RemoteStore ¶
type RemoteTarget ¶
type RemoteTarget struct {
Registry string `json:"registry"`
Repository string `json:"repository"`
PlainHTTP bool `json:"plain_http"`
InsecureTLS bool `json:"insecure_tls,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Token string `json:"token,omitempty"`
CAFile string `json:"ca_file,omitempty"`
HTTPClient *http.Client `json:"-"`
Transport http.RoundTripper `json:"-"`
AuthProvider auth.CredentialFunc `json:"-"`
ReferrersCapability *bool `json:"-"`
}
RemoteTarget describes how the preferred core push path should reach a remote OCI registry.
This type is part of the intended long-lived core surface used by PushPackagedVolume and Client.PushPackagedVolume.
type SpecReferrerResult ¶
SpecReferrerResult reports the manifest uploaded by the experimental PushToolSpecReferrer and PushDataSpecReferrer helpers.
Experimental: this type is not yet part of the frozen core contract.
func PushDataSpecReferrer ¶
func PushDataSpecReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, specJSON []byte) (SpecReferrerResult, error)
PushDataSpecReferrer uploads a data-oriented OCI referrer artifact.
Experimental: this helper is NodeVault-oriented, subject to change, and not yet part of the intended long-lived core surface.
func PushSecurityReferrer ¶
func PushSecurityReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, securityJSON []byte) (SpecReferrerResult, error)
PushSecurityReferrer uploads a security scan result referrer artifact for the given tool image. The securityJSON must be a valid JSON document conforming to the security referrer payload defined in SECURITY_SCAN_SPEC.md.
Experimental: this helper is NodeVault-oriented, subject to change, and not yet part of the intended long-lived core surface.
func PushToolProfileReferrer ¶
func PushToolProfileReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, profileJSON []byte) (SpecReferrerResult, error)
PushToolProfileReferrer uploads an observed dry-run profile referrer artifact for the given tool image. The profileJSON must be a valid JSON document conforming to the toolprofile payload defined in OBSERVED_PROFILE_SPEC.md.
Experimental: this helper is NodeVault-oriented, subject to change, and not yet part of the intended long-lived core surface.
func PushToolSpecReferrer ¶
func PushToolSpecReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, specJSON []byte) (SpecReferrerResult, error)
PushToolSpecReferrer uploads a tool-oriented OCI referrer artifact.
Experimental: this helper is NodeVault-oriented, subject to change, and not yet part of the intended long-lived core surface.
type VolumeCollection ¶
type VolumeCollection struct {
Version int `json:"version"`
Volumes []VolumeEntry `json:"volumes"`
}
func LoadOrNewCollection ¶
func LoadOrNewCollection(rootDir string, initialEntries ...VolumeEntry) (*VolumeCollection, error)
func NewVolumeCollection ¶
func NewVolumeCollection(initialEntries ...VolumeEntry) *VolumeCollection
func (*VolumeCollection) AddVolume ¶
func (vc *VolumeCollection) AddVolume(entry VolumeEntry)
func (*VolumeCollection) HasVolume ¶
func (vc *VolumeCollection) HasVolume(vi VolumeIndex) bool
func (*VolumeCollection) Merge ¶
func (vc *VolumeCollection) Merge(newColl VolumeCollection) bool
func (*VolumeCollection) RemoveVolume ¶
func (vc *VolumeCollection) RemoveVolume(idx int) error
type VolumeEntry ¶
type VolumeEntry struct {
Index VolumeIndex `json:"index"`
ConfigBlob ConfigBlob `json:"configBlob"`
}
type VolumeIndex ¶
type VolumeIndex struct {
VolumeRef string `json:"volume_ref"`
DisplayName string `json:"display_name"`
CreatedAt string `json:"created_at"`
Partitions []Partition `json:"partitions"`
// Skipped is true when FetchVolumeFromRemote detected that destRoot
// already holds the requested manifest digest and skipped the download.
// This field is runtime-only and is never written to volume-index.json.
Skipped bool `json:"-"`
}
VolumeIndex describes the partition layout of a packaged dataset.
VolumeIndex is part of the core candidate surface and is used by the preferred client path as well as compatibility helpers.
func FetchVolParallel ¶
func FetchVolParallel(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)
FetchVolParallel fetches a packaged dataset from a local OCI store with parallel layer extraction. Dual-path (D-13): detects chunked CAS vs legacy format from the manifest Config.MediaType; chunked artifacts use the chunked fetcher's own concurrency.
func FetchVolSeq ¶
func FetchVolSeq(ctx context.Context, destRoot, repo, tag string) (*VolumeIndex, error)
FetchVolSeq fetches a packaged dataset from a local OCI store sequentially. Dual-path (D-13): detects chunked CAS vs legacy format from the manifest Config.MediaType and dispatches accordingly.
func GenerateVolumeIndex ¶
func GenerateVolumeIndex(rootPath, displayName string) (*VolumeIndex, error)
GenerateVolumeIndex builds a VolumeIndex from the top-level subdirectories of rootPath. Only immediate child directories become partitions; nested directories are included in their parent partition's layer. Root-level regular files are NOT listed as partitions — they are handled as a separate layer during publish.
func (*VolumeIndex) PublishVolume
deprecated
func (vi *VolumeIndex) PublishVolume(ctx context.Context, volPath, volName string, configBlob []byte) (*VolumeIndex, error)
Deprecated: prefer Client.PackageVolume, Client.PackageVolumeWithOptions, or PackageVolumeToStore so new code stays on the preferred client-based core path.
func (*VolumeIndex) SaveToFile ¶
func (vi *VolumeIndex) SaveToFile(rootPath string) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
adapters
|
|
|
Package chunked implements the sori chunked CAS artifact format.
|
Package chunked implements the sori chunked CAS artifact format. |
|
internal
|
|
|
bench
Package bench implements the P5-6 benchmark gate for the chunked CAS path.
|
Package bench implements the P5-6 benchmark gate for the chunked CAS path. |