Documentation
¶
Overview ¶
Package bundle implements support for unified runtime bundles.
Index ¶
- Constants
- Variables
- func ExplodedPath(dataDir string) string
- func HashAllData(d Data) (hash.Hash, error)
- func ReadAllData(d Data) ([]byte, error)
- type Bundle
- func (bnd *Bundle) Add(fn string, data Data) error
- func (bnd *Bundle) Close() error
- func (bnd *Bundle) EnclaveIdentities(id component.ID) ([]sgx.EnclaveIdentity, error)
- func (bnd *Bundle) EnclaveIdentity(id component.ID) (*sgx.EnclaveIdentity, error)deprecated
- func (bnd *Bundle) ExplodedPath(dataDir string) string
- func (bnd *Bundle) GenerateFilename() string
- func (bnd *Bundle) MrEnclave(id component.ID) (*sgx.MrEnclave, error)
- func (bnd *Bundle) MrSigner(id component.ID) (*sgx.MrSigner, error)
- func (bnd *Bundle) ResetManifest()
- func (bnd *Bundle) Validate() error
- func (bnd *Bundle) Write(fn string) error
- func (bnd *Bundle) WriteExploded(dir string) error
- type Component
- type Data
- type ELFMetadata
- type ExplodedComponent
- type ExplodedManifest
- type GPUResource
- type Identity
- type Manager
- type Manifest
- func (m *Manifest) GetAvailableComponents() map[component.ID]*Component
- func (m *Manifest) GetComponentByID(id component.ID) (*Component, bool)
- func (m *Manifest) Hash() hash.Hash
- func (m *Manifest) IsDetached() bool
- func (m *Manifest) IsLegacy() bool
- func (m *Manifest) UnmarshalJSON(b []byte) (err error)
- func (m *Manifest) Validate() error
- type ManifestStore
- type OpenOption
- type OpenOptions
- type Registry
- func (r *Registry) AddManifest(manifest *ExplodedManifest) error
- func (r *Registry) Components(runtimeID common.Namespace) []*ExplodedComponent
- func (r *Registry) GetVersions(runtimeID common.Namespace) []version.Version
- func (r *Registry) HasManifest(hash hash.Hash) bool
- func (r *Registry) Manifests() []*ExplodedManifest
- func (r *Registry) RemoveManifest(hash hash.Hash) bool
- func (r *Registry) WatchComponents(runtimeID common.Namespace) (<-chan *ExplodedComponent, *pubsub.Subscription)
- type SGXMetadata
- type TDXMetadata
- type TDXResources
Constants ¶
const ( // GPUNvidiaH100 is the NVIDIA H100 GPU. GPUNvidiaH100 = "nvidia-h100" // GPUNvidiaH200 is the NVIDIA H200 GPU. GPUNvidiaH200 = "nvidia-h200" )
const CfgDebugMockIDs = "runtime.debug.mock_ids"
CfgDebugMockIDs configures mock runtime IDs for the purpose of testing.
const FileExtension = ".orc"
FileExtension is the file extension used for storing the bundle.
Variables ¶
var Flags = flag.NewFlagSet("", flag.ContinueOnError)
Flags has the configuration flags.
Functions ¶
func ExplodedPath ¶
ExplodedPath returns the path under the data directory that contains all of the exploded bundles.
func HashAllData ¶ added in v0.2403.0
HashAllData hashes all of the underlying data and returns the hash.
func ReadAllData ¶ added in v0.2403.0
ReadAllData reads all of the underlying data into a buffer and returns it.
Types ¶
type Bundle ¶
type Bundle struct { Manifest *Manifest Data map[string]Data // contains filtered or unexported fields }
Bundle is a runtime bundle instance.
func Open ¶
func Open(fn string, opts ...OpenOption) (_ *Bundle, err error)
Open opens and validates a runtime bundle instance.
func (*Bundle) EnclaveIdentities ¶ added in v0.2500.0
EnclaveIdentities returns the enclave identities of the given component.
func (*Bundle) EnclaveIdentity
deprecated
added in
v0.2400.0
func (*Bundle) ExplodedPath ¶
ExplodedPath returns the path under the data directory that contains the exploded bundle assets.
func (*Bundle) GenerateFilename ¶ added in v0.2500.0
GenerateFilename returns the recommended filename for storing the bundle.
func (*Bundle) MrSigner ¶ added in v0.2400.0
MrSigner returns the MRSIGNER that signed the SGX executable.
func (*Bundle) ResetManifest ¶ added in v0.2201.9
func (bnd *Bundle) ResetManifest()
ResetManifest removes the serialized manifest from the bundle so that it can be regenerated on the next call to Write.
This needs to be used after doing modifications to bundles.
func (*Bundle) WriteExploded ¶
WriteExploded extracts the runtime bundle to the given directory.
type Component ¶ added in v0.2400.0
type Component struct { // Kind is the component kind. Kind component.Kind `json:"kind"` // Name is the name of the component that can be used to filter components when multiple are // provided by a runtime. Name string `json:"name,omitempty"` // Version is the component version. Version version.Version `json:"version,omitempty"` // Executable is the name of the runtime ELF executable file if any. // NOTE: This may go away in the future, use `ELF` instead. Executable string `json:"executable,omitempty"` // ELF is the ELF specific manifest metadata if any. ELF *ELFMetadata `json:"elf,omitempty"` // SGX is the SGX specific manifest metadata if any. SGX *SGXMetadata `json:"sgx,omitempty"` // TDX is the TDX specific manifest metadata if any. TDX *TDXMetadata `json:"tdx,omitempty"` // Identities are the (optional) expected enclave identities. When not provided, it must be // computed at runtime. In the future, this field will become required. // // Multiple identities may be provided because they can differ across different deployment // systems (e.g. hypervisors). Identities []Identity `json:"identity,omitempty"` // Disabled specifies whether the component is disabled by default and needs to be explicitly // enabled via node configuration to be used. Disabled bool `json:"disabled,omitempty"` }
Component is a runtime component.
func (*Component) IsNetworkAllowed ¶ added in v0.2400.0
IsNetworkAllowed returns true if network access should be allowed for the component.
func (*Component) Matches ¶ added in v0.2400.0
Matches returns true iff the component matches the given component ID.
type Data ¶ added in v0.2403.0
type Data interface { // Open returns an io.ReadCloser that can be used to access the underlying data. Open() (io.ReadCloser, error) }
Data is a data item in the bundle.
func NewBytesData ¶ added in v0.2403.0
NewBytesData creates a new Data instance from the given byte slice. The slice is not copied.
func NewFileData ¶ added in v0.2403.0
NewFileData creates a new Data instance that opens and reads the given file path.
type ELFMetadata ¶ added in v0.2500.0
type ELFMetadata struct { // Executable is the name of the ELF executable file. Executable string `json:"executable"` }
ELFMetadata is the ELF specific manifest metadata.
func (*ELFMetadata) Validate ¶ added in v0.2500.0
func (e *ELFMetadata) Validate() error
Validate validates the ELF metadata structure for well-formedness.
type ExplodedComponent ¶ added in v0.2500.0
type ExplodedComponent struct { *Component // TEEKind specifies the kind of Trusted Execution Environment (TEE) // in which the component should run. TEEKind component.TEEKind // Detached is true iff the bundle containing the component does not // include a RONL component. Detached bool // ExplodedDataDir is the path to the data directory where the bundle // containing the component has been extracted. ExplodedDataDir string }
ExplodedComponent is an exploded runtime component ready for execution.
func (*ExplodedComponent) ExplodedPath ¶ added in v0.2500.0
func (c *ExplodedComponent) ExplodedPath(fn string) string
ExplodedPath returns the path that the corresponding asset will be written to via WriteExploded.
type ExplodedManifest ¶ added in v0.2500.0
type ExplodedManifest struct { *Manifest // ExplodedDataDir is the path to the data directory where the bundle // represented by manifest has been extracted. ExplodedDataDir string }
ExplodedManifest is manifest with corresponding exploded bundle dir.
type GPUResource ¶ added in v0.2500.0
type GPUResource struct { // Model is the GPU model. It may be omitted to specify that the model is not important. Model string `json:"model,omitempty"` // Count is the number of GPUs requested. Count uint8 `json:"count"` }
GPUResource is the GPU resource descriptor.
func (*GPUResource) Validate ¶ added in v0.2500.0
func (g *GPUResource) Validate() error
Validate validates the GPU resource.
type Identity ¶ added in v0.2500.0
type Identity struct { // Hypervisor is the optional hypervisor this identity is for. Hypervisor string `json:"hypervisor,omitempty"` // Enclave is the enclave identity. Enclave sgx.EnclaveIdentity `json:"enclave"` }
Identity is the cryptographic identity of a component.
type Manager ¶ added in v0.2500.0
type Manager struct {
// contains filtered or unexported fields
}
Manager is responsible for managing bundles.
func NewManager ¶ added in v0.2500.0
func NewManager(dataDir string, runtimeIDs []common.Namespace, store ManifestStore) (*Manager, error)
NewManager creates a new bundle manager.
func (*Manager) Cleanup ¶ added in v0.2500.0
Cleanup updates the runtime's maximum bundle version for pending clean-up.
If the specified runtime already exists in the cleanup queue, its version is updated only if the provided versions is greater.
Warning: If clean-up fails it's not retried.
func (*Manager) Download ¶ added in v0.2500.0
Download updates the checksums of bundles pending download for the given runtime.
Any existing checksums in the download queue for the given runtime are removed and replaced with the given ones.
type Manifest ¶
type Manifest struct { // Name is the optional human readable runtime name. Name string `json:"name,omitempty"` // ID is the runtime identifier. ID common.Namespace `json:"id"` // Version is the runtime version. // NOTE: This may go away in the future, use `Component.Version` instead. Version version.Version `json:"version,omitempty"` // Executable is the name of the runtime ELF executable file. // NOTE: This may go away in the future, use `Components` instead. Executable string `json:"executable,omitempty"` // SGX is the SGX specific manifest metadata if any. // NOTE: This may go away in the future, use `Components` instead. SGX *SGXMetadata `json:"sgx,omitempty"` // Components are the additional runtime components. Components []*Component `json:"components,omitempty"` // Digests is the cryptographic digests of the bundle contents, // excluding the manifest. Digests map[string]hash.Hash `json:"digests"` }
Manifest is a deserialized runtime bundle manifest.
func (*Manifest) GetAvailableComponents ¶ added in v0.2400.0
GetAvailableComponents collects all of the available components into a map.
func (*Manifest) GetComponentByID ¶ added in v0.2400.0
GetComponentByID returns the first component with the given kind.
func (*Manifest) Hash ¶ added in v0.2401.0
Hash returns a cryptographic hash of the CBOR-serialized manifest.
func (*Manifest) IsDetached ¶ added in v0.2401.0
IsDetached returns true iff the manifest does not include a RONL component. Such bundles require that the RONL component is provided out-of-band (e.g. in a separate bundle).
func (*Manifest) IsLegacy ¶ added in v0.2403.0
IsLegacy returns true iff this is a legacy manifest that defines executables at the top level.
func (*Manifest) UnmarshalJSON ¶ added in v0.2500.0
UnmarshalJSON customizes the unmarshalling of the manifest.
type ManifestStore ¶ added in v0.2500.0
type ManifestStore interface { // HasManifest returns true iff the store already contains an exploded manifest // with the given hash. HasManifest(hash hash.Hash) bool // AddManifest adds the provided exploded manifest to the store. AddManifest(manifest *ExplodedManifest) error // RemoveManifest removes an exploded manifest with provided hash. RemoveManifest(hash hash.Hash) bool // Manifests returns all known exploded manifests. Manifests() []*ExplodedManifest }
ManifestStore is an interface that defines methods for storing exploded manifests.
type OpenOption ¶ added in v0.2500.0
type OpenOption func(o *OpenOptions)
OpenOption is an option used when opening a bundle file.
func WithManifestHash ¶ added in v0.2500.0
func WithManifestHash(manifestHash hash.Hash) OpenOption
WithManifestHash sets the manifest hash for verification.
type OpenOptions ¶ added in v0.2500.0
type OpenOptions struct {
// contains filtered or unexported fields
}
OpenOptions are options for opening bundle files.
func NewOpenOptions ¶ added in v0.2500.0
func NewOpenOptions(opts ...OpenOption) *OpenOptions
NewOpenOptions creates options using default and given values.
type Registry ¶ added in v0.2500.0
type Registry struct {
// contains filtered or unexported fields
}
Registry is a registry of manifests and components.
func NewRegistry ¶ added in v0.2500.0
func NewRegistry() *Registry
NewRegistry creates a new registry of manifests and components.
func (*Registry) AddManifest ¶ added in v0.2500.0
func (r *Registry) AddManifest(manifest *ExplodedManifest) error
AddManifest adds the provided exploded manifest to the store.
func (*Registry) Components ¶ added in v0.2500.0
func (r *Registry) Components(runtimeID common.Namespace) []*ExplodedComponent
Components returns all components for the given runtime.
func (*Registry) GetVersions ¶ added in v0.2500.0
GetVersions returns versions for the given runtime, sorted in ascending order.
func (*Registry) HasManifest ¶ added in v0.2500.0
HasManifest returns true iff the store already contains a manifest with the given hash.
func (*Registry) Manifests ¶ added in v0.2500.0
func (r *Registry) Manifests() []*ExplodedManifest
Manifests returns all known manifests.
func (*Registry) RemoveManifest ¶ added in v0.2500.0
RemoveManifest removes a manifest with provided hash.
func (*Registry) WatchComponents ¶ added in v0.2500.0
func (r *Registry) WatchComponents(runtimeID common.Namespace) (<-chan *ExplodedComponent, *pubsub.Subscription)
WatchComponents provides a channel that streams runtime components as they are added to the registry.
type SGXMetadata ¶
type SGXMetadata struct { // Executable is the name of the SGX enclave executable file. Executable string `json:"executable"` // Signature is the name of the SGX enclave signature file. Signature string `json:"signature"` }
SGXMetadata is the SGX specific manifest metadata.
func (*SGXMetadata) Validate ¶ added in v0.2400.0
func (s *SGXMetadata) Validate() error
Validate validates the SGX metadata structure for well-formedness.
type TDXMetadata ¶ added in v0.2403.0
type TDXMetadata struct { // Firmware is the name of the virtual firmware file. It should rarely change and multiple // components may use the same firmware. Firmware string `json:"firmware"` // Kernel is the name of the kernel image file. It should rarely change and multiple components // may use the same kernel. Kernel string `json:"kernel,omitempty"` // InitRD is the name of the initial RAM disk image file. It should rarely change and multiple // components may use the same initrd. InitRD string `json:"initrd,omitempty"` // ExtraKernelOptions are the extra kernel options to pass to the kernel after any of the // default options. Note that kernel options affect TD measurements. ExtraKernelOptions []string `json:"extra_kernel_options,omitempty"` // Stage2Image is the name of the stage 2 VM image file. Stage2Image string `json:"stage2_image,omitempty"` // Stage2Format is the format of the stage 2 VM image file. Empty means raw. Stage2Format string `json:"stage2_format,omitempty"` // Stage2Persist is the flag specifying whether the modifications to stage 2 image file should // be (locally) persisted across TD restarts. Stage2Persist bool `json:"stage2_persist,omitempty"` // Resources are the requested VM resources. Resources TDXResources `json:"resources"` }
TDXMetadata is the TDX specific manifest metadata.
Note that changes to these fields may change the TD measurements.
func (*TDXMetadata) HasInitRD ¶ added in v0.2403.0
func (t *TDXMetadata) HasInitRD() bool
HasInitRD returns true iff the TDX metadata indicates there is an initial RAM disk image present.
func (*TDXMetadata) HasKernel ¶ added in v0.2403.0
func (t *TDXMetadata) HasKernel() bool
HasKernel returns true iff the TDX metadata indicates there is a kernel present.
func (*TDXMetadata) HasStage2 ¶ added in v0.2403.0
func (t *TDXMetadata) HasStage2() bool
HasStage2 returns true iff the TDX metadata indicates there is a stage 2 image present.
func (*TDXMetadata) Validate ¶ added in v0.2403.0
func (t *TDXMetadata) Validate() error
Validate validates the TDX metadata structure for well-formedness.
type TDXResources ¶ added in v0.2403.0
type TDXResources struct { // Memory is the requested VM memory amount in megabytes. Memory uint64 `json:"memory"` // CPUCount is the requested number of vCPUs. CPUCount uint8 `json:"cpus"` // GPU is the optional GPU resource configuration. GPU *GPUResource `json:"gpu,omitempty"` }
TDXResources are the requested VM resources for TDX VMs.
Note that changes to these fields may change the TD measurements.
func (*TDXResources) Validate ¶ added in v0.2403.0
func (r *TDXResources) Validate() error
Validate validates the VM resources.