Documentation
¶
Index ¶
- Constants
- Variables
- func AddToProfile(profilePath string, im Image) error
- func ApplyProfile(applyCfg *ApplyConfig) error
- func CurrentOsVersionID(path string) (string, error)
- func CurrentProfileNames() (string, []string, error)
- func CurrentProfilePath() (string, error)
- func FilterStoreVersions(usrMountpoint string, paths []string, curVersion string, filterVersion string) []string
- func IsExistingPath(fusePath string) bool
- func ListProfiles(profileDirs []string) (map[string]string, error)
- func ReadCommonConfig(cfgPath string, commonCfg *CommonConfig) error
- func ReadMetadata(fusePath string) (map[string]string, error)
- func RuntimeConfigPath() string
- func SealSystemState(applyCfg *ApplyConfig) error
- func ValidateCommonConfig(commonCfg *CommonConfig) error
- func VendorOsReleasePath(usrMountpoint string) string
- func VendorProfilesDir(usrMountpoint string) string
- func VendorRemotesDir(usrMountpoint string) string
- func VendorStoreDir(usrMountpoint string) string
- type ApplyConfig
- type Archive
- type ArchiveFormat
- type Assets
- type CommonConfig
- func (cc *CommonConfig) NextProfile() string
- func (cc *CommonConfig) NextProfileName() (string, error)
- func (cc *CommonConfig) ProfileDirs() []string
- func (cc *CommonConfig) RemotesDirs() []string
- func (cc *CommonConfig) RunBinDir() string
- func (cc *CommonConfig) RunProfile() string
- func (cc *CommonConfig) RunUnpackDir() string
- func (cc *CommonConfig) SetNextProfileName(name string) error
- func (cc *CommonConfig) UserProfileDir() string
- func (cc *CommonConfig) UserStorePath(version string) string
- type ConfigV0
- type Image
- type ImageManifestV0
- type ImageV0
- type ImageV1
- type ImagesV0
- type ImagesV1
- type ProfileConfig
- type ProfileManifestV0JSON
- type ProfileManifestV1JSON
- type Remote
- type RemoteContents
- type RemoteContentsV1JSON
- type RemoteImage
- type RemoteImageV1
- type RemoteImagesV1
- type RemoteKeyV0
- type RemoteManifestV0JSON
- type RemoteV0
- type RemoteVersion
- type RemoteVersionV1
- type RemotesCache
- type StoreCache
Constants ¶
const ( // SealPath is the path where metadata are written once the system has been sealed. SealPath = "/run/metadata/torcx" // VendorUsrDir is the standard mountpoint for vendor USR partition. VendorUsrDir = "/usr" // OemDir contains (mutable) assets provided by the oem. OemDir = "/usr/share/oem/torcx/" // DefaultTagRef is the default image reference looked up in archives. DefaultTagRef = "com.coreos.cl" // VendorProfileName is the default vendor profile used. VendorProfileName = "vendor" // OemProfileName is the default oem profile used. OemProfileName = "oem" )
These are torcx constants that can be overridden via link arguments at build-time.
const ( // ProfileManifestV1K - profile manifest kind, v1 ProfileManifestV1K = "profile-manifest-v1" // ProfileManifestV0K - profile manifest kind, v0 ProfileManifestV0K = "profile-manifest-v0" // RemoteManifestV0K - remote manifest kind, v0 RemoteManifestV0K = "remote-manifest-v0" // RemoteContentsV1K - remote contents kind, v1 RemoteContentsV1K = "torcx-remote-contents-v1" )
const ( // DefaultRunDir is the default path where torcx unpacks/propagates all runtime assets. DefaultRunDir = "/run/torcx/" // DefaultBaseDir is the default torcx base directory DefaultBaseDir = "/var/lib/torcx/" // DefaultConfDir is the default torcx config directory DefaultConfDir = "/etc/torcx/" // OemStoreDir is the OEM store path OemStoreDir = OemDir + "store" // OemProfilesDir is the OEM profiles path OemProfilesDir = OemDir + "profiles" // OemRemotesDir is the OEM remotes path OemRemotesDir = OemDir + "remotes" )
const ( // SealUpperProfile is the key label for user profile name SealUpperProfile = "TORCX_UPPER_PROFILE" // SealLowerProfiles is the key label for vendor profile path SealLowerProfiles = "TORCX_LOWER_PROFILES" // SealRunProfilePath is the key label for vendor profile path SealRunProfilePath = "TORCX_PROFILE_PATH" // SealBindir is the key label for seal bindir SealBindir = "TORCX_BINDIR" // SealUnpackdir is the key label for seal unpackdir SealUnpackdir = "TORCX_UNPACKDIR" // ImageManifestV0K - image manifest kind, v0 ImageManifestV0K = "image-manifest-v0" // CommonConfigV0K - common torcx config kind, v0 CommonConfigV0K = "torcx-config-v0" )
const ( // ArchiveFormatUnknown is the zero value of ArchiveFormat. It indicates the image format is unknown ArchiveFormatUnknown ArchiveFormat = "" // ArchiveFormatTgz indicates a tar-gzipped image ArchiveFormatTgz = "tgz" // ArchiveFormatSquashfs indicates a squashfs image archive ArchiveFormatSquashfs = "squashfs" )
Variables ¶
var DefaultLowerProfiles = []string{VendorProfileName, OemProfileName}
DefaultLowerProfiles are the default lower profiles (for vendor and oem entries)
var ( // ErrUnknownOSVersionID is the error returned on generic os-release parsing errors ErrUnknownOSVersionID = errors.New(`unable to parse "VERSION_ID" from os-release`) )
Functions ¶
func AddToProfile ¶
AddToProfile adds an image to an existing profile.
func ApplyProfile ¶
func ApplyProfile(applyCfg *ApplyConfig) error
ApplyProfile is called at boot-time to apply the configured profile system-wide. Apply operation is split in three phases:
- unpack: all images are unpacked to their own dedicated path under UnpackDir
- propagate: executable assets are propagated into the system; this includes symlinking binaries into BinDir and installing systemd transient units.
- seal: system state is frozen, profile and metadata written to RunDir
func CurrentOsVersionID ¶
CurrentOsVersionID parses an os-release file to extract the VERSION_ID.
For more details about the expect format of the os-release file, see https://www.freedesktop.org/software/systemd/man/os-release.html
func CurrentProfileNames ¶
CurrentProfileNames returns the name of the currently running user and vendor profiles
func CurrentProfilePath ¶
CurrentProfilePath returns the path of the currently running profile
func FilterStoreVersions ¶
func FilterStoreVersions(usrMountpoint string, paths []string, curVersion string, filterVersion string) []string
FilterStoreVersions filters out unversioned store based on the match between the currently detected OS version (`curVersion`) and the one to filter for (`filterVersion`)
func IsExistingPath ¶
IsExistingPath checks whether the given path already exists.
func ListProfiles ¶
ListProfiles returns a list of all available profiles
func ReadCommonConfig ¶
func ReadCommonConfig(cfgPath string, commonCfg *CommonConfig) error
ReadCommonConfig populates common config entries from optional settings from a config file
func ReadMetadata ¶
ReadMetadata returns metadata regarding the currently running profile, as read from the metadata file
func RuntimeConfigPath ¶
func RuntimeConfigPath() string
RuntimeConfigPath determines runtime location of torcx common configuration file.
func SealSystemState ¶
func SealSystemState(applyCfg *ApplyConfig) error
SealSystemState is a one-time-op which seals the current state of the system, after a torcx profile has been applied to it.
func ValidateCommonConfig ¶
func ValidateCommonConfig(commonCfg *CommonConfig) error
ValidateCommonConfig performs validation on torcx common config
func VendorOsReleasePath ¶ added in v0.2.0
VendorOsReleasePath returns the path to vendor os-release file for the specific OS partition mounted at `usrMountpoint`.
func VendorProfilesDir ¶
VendorProfilesDir is the vendor profiles path
func VendorRemotesDir ¶ added in v0.2.0
VendorRemotesDir is the vendor remotes path
func VendorStoreDir ¶
VendorStoreDir is the vendor store path
Types ¶
type ApplyConfig ¶
type ApplyConfig struct { CommonConfig LowerProfiles []string UpperProfile string }
ApplyConfig contains runtime configuration items specific to the `apply` subcommand
type Archive ¶
type Archive struct { Image Filepath string `json:"filepath"` Format ArchiveFormat `json:"format"` }
Archive represents a .torcx.squashfs or .torcx.tgz on disk
func (*Archive) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON unmarshals an Archive, including defaulting the "format" field to "tgz" if it was not set.
type ArchiveFormat ¶ added in v0.2.0
type ArchiveFormat string
ArchiveFormat is a torcx archive format, either 'tgz' or 'squashfs'
func (ArchiveFormat) FileSuffix ¶ added in v0.2.0
func (arf ArchiveFormat) FileSuffix() string
FileSuffix returns the file extension this archive format must have.
func (*ArchiveFormat) UnmarshalJSON ¶ added in v0.2.0
func (arf *ArchiveFormat) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals an ArchiveFormat
type Assets ¶
type Assets struct { Binaries []string `json:"bin,omitempty"` Network []string `json:"network,omitempty"` Units []string `json:"units,omitempty"` Sysusers []string `json:"sysusers,omitempty"` Tmpfiles []string `json:"tmpfiles,omitempty"` UdevRules []string `json:"udev_rules,omitempty"` }
Assets holds lists of assets propagated from an image to the system
type CommonConfig ¶
type CommonConfig struct { BaseDir string `json:"base_dir,omitempty"` RunDir string `json:"run_dir,omitempty"` UsrDir string `json:"usr_dir,omitempty"` ConfDir string `json:"conf_dir,omitempty"` StorePaths []string `json:"store_paths,omitempty"` }
CommonConfig contains runtime configuration items common to all torcx subcommands
func (*CommonConfig) NextProfile ¶
func (cc *CommonConfig) NextProfile() string
NextProfile is the path for the `next-profile` selector configuration file.
func (*CommonConfig) NextProfileName ¶
func (cc *CommonConfig) NextProfileName() (string, error)
NextProfileName determines which profile will be used for the next apply.
func (*CommonConfig) ProfileDirs ¶
func (cc *CommonConfig) ProfileDirs() []string
ProfileDirs are the list of directories where we look for profiles.
func (*CommonConfig) RemotesDirs ¶ added in v0.2.0
func (cc *CommonConfig) RemotesDirs() []string
RemotesDirs returns the list of directories where we look for remotes manifests.
func (*CommonConfig) RunBinDir ¶
func (cc *CommonConfig) RunBinDir() string
RunBinDir is the directory where binaries are symlinked.
func (*CommonConfig) RunProfile ¶
func (cc *CommonConfig) RunProfile() string
RunProfile is the file where we copy the contents of the applied profile.
func (*CommonConfig) RunUnpackDir ¶
func (cc *CommonConfig) RunUnpackDir() string
RunUnpackDir is the directory where root filesystems are unpacked.
func (*CommonConfig) SetNextProfileName ¶
func (cc *CommonConfig) SetNextProfileName(name string) error
SetNextProfileName writes the given profile name as active for the next boot.
func (*CommonConfig) UserProfileDir ¶
func (cc *CommonConfig) UserProfileDir() string
UserProfileDir is where user profiles are written.
func (*CommonConfig) UserStorePath ¶
func (cc *CommonConfig) UserStorePath(version string) string
UserStorePath is the path where user-fetched archives are written. An optional target version can be specified for versioned user store.
type ConfigV0 ¶
type ConfigV0 struct { Kind string `json:"kind"` Value CommonConfig `json:"value"` }
ConfigV0 holds common torcx configuration in JSON format
type Image ¶
type Image struct { Name string `json:"name"` Reference string `json:"reference"` Remote string `json:"remote"` }
Image represents an addon archive within a profile.
func ImageFromJSONV0 ¶ added in v0.2.0
ImageFromJSONV0 converts an ImageV0 into an internal Image.
func ImageFromJSONV1 ¶ added in v0.2.0
ImageFromJSONV1 converts an ImageV1 into an internal Image.
func ImagesFromJSONV0 ¶ added in v0.2.0
ImagesFromJSONV0 converts an ImagesV0 into an internal Image list.
func ImagesFromJSONV1 ¶ added in v0.2.0
ImagesFromJSONV1 converts an ImagesV1 into an internal Image list.
func ReadCurrentProfile ¶
ReadCurrentProfile returns the content of the currently running profile
func ReadProfilePath ¶
ReadProfilePath returns the content of a specific profile, specified via path.
type ImageManifestV0 ¶
ImageManifestV0 holds JSON image manifest
type ImageV1 ¶ added in v0.2.0
type ImageV1 struct { Name string `json:"name"` Reference string `json:"reference"` Remote string `json:"remote"` }
ImageV1 describes and addon image within a v1 profile.
type ImagesV0 ¶ added in v0.2.0
type ImagesV0 struct {
Images []ImageV0 `json:"images"`
}
ImagesV0 contains an array of image entries.
func ImagesToJSONV0 ¶ added in v0.2.0
ImagesToJSONV0 converts an internal Image list into ImagesV0.
type ImagesV1 ¶ added in v0.2.0
type ImagesV1 struct {
Images []ImageV1 `json:"images"`
}
ImagesV1 contains an array of image entries.
func ImagesToJSONV1 ¶ added in v0.2.0
ImagesToJSONV1 converts an internal Image list into ImagesV1.
type ProfileConfig ¶
type ProfileConfig struct { CommonConfig LowerProfileNames []string UserProfileName string CurrentProfilePath string NextProfile string }
ProfileConfig contains runtime configuration items specific to the `profile` subcommand
type ProfileManifestV0JSON ¶ added in v0.2.0
ProfileManifestV0JSON holds JSON profile manifest (version 0).
type ProfileManifestV1JSON ¶ added in v0.2.0
ProfileManifestV1JSON holds JSON profile manifest (version 1).
type Remote ¶ added in v0.2.0
func RemoteFromJSONV0 ¶ added in v0.2.0
RemoteFromJSONV0 translates a RemoteKeyV0 to an internal Remote.
type RemoteContents ¶ added in v0.2.0
type RemoteContents struct {
Images map[string]RemoteImage
}
RemoteContents holds contents metadata for a remote manifest.
func RemoteContentsFromJSONV1 ¶ added in v0.2.0
func RemoteContentsFromJSONV1(j RemoteImagesV1) RemoteContents
RemoteContentsFromJSONV1 translates a RemoteImagesV1 to an internal Remote.
func (*RemoteContents) CheckAvailable ¶ added in v0.2.0
CheckAvailable checks if a given Image is available in the configured remote. On success, it returns its location (anchored at `base_url`).
type RemoteContentsV1JSON ¶ added in v0.2.0
type RemoteContentsV1JSON struct { Kind string `json:"kind"` Value RemoteImagesV1 `json:"value"` }
RemoteContentsV1JSON holds JSON contents metadata for a remote manifest.
type RemoteImage ¶ added in v0.2.0
type RemoteImage struct {
// contains filtered or unexported fields
}
RemoteImage list remote versions of an image.
type RemoteImageV1 ¶ added in v0.2.0
type RemoteImageV1 struct { DefaultVersion string `json:"defaultVersion"` Name string `json:"name"` Versions []RemoteVersionV1 `json:"versions"` }
RemoteImageV1 describes image versions available on a remote.
type RemoteImagesV1 ¶ added in v0.2.0
type RemoteImagesV1 struct {
Images []RemoteImageV1 `json:"images"`
}
RemoteImagesV1 lists all images available on a remote.
type RemoteKeyV0 ¶ added in v0.2.0
type RemoteKeyV0 struct {
ArmoredKeyring string `json:"armored_keyring,omitempty"`
}
RemoteKeyV0 represents a signing key for a remote.
type RemoteManifestV0JSON ¶ added in v0.2.0
RemoteManifestV0JSON holds a JSON remote manifest (version 0).
type RemoteV0 ¶ added in v0.2.0
type RemoteV0 struct { BaseURL string `json:"base_url"` Keys []RemoteKeyV0 `json:"keys"` }
RemoteV0 describes a remote.
type RemoteVersion ¶ added in v0.2.0
type RemoteVersion struct {
// contains filtered or unexported fields
}
RemoteVersion describes a remote image archive.
func RemoteVersionFromJSONV1 ¶ added in v0.2.0
func RemoteVersionFromJSONV1(j RemoteVersionV1) RemoteVersion
RemoteVersionFromJSONV1 translates a RemoteVersionV1 to an internal RemoteVersion.
type RemoteVersionV1 ¶ added in v0.2.0
type RemoteVersionV1 struct { Format string `json:"format"` Hash string `json:"hash"` Location string `json:"location"` Version string `json:"version"` }
RemoteVersionV1 describes a specific image (with version and format) available on a remote.
type RemotesCache ¶ added in v0.2.0
type RemotesCache struct { Configs map[string]Remote Contents map[string]RemoteContents Paths map[string]string UsrMountpoint string }
RemotesCache holds a temporary cache for images/references in the store
func NewRemotesCache ¶ added in v0.2.0
func NewRemotesCache(ctx context.Context, usrMountpoint string, baseDirs []string, remotesFilter []string) (*RemotesCache, error)
NewRemotesCache constructs a new RemotesCache
func (*RemotesCache) CheckAvailable ¶ added in v0.2.0
CheckAvailable checks if a given Image is available in the configured remote. On success, it returns the full evaluated base URL for the remote and the relative image location.
func (*RemotesCache) FetchImage ¶ added in v0.2.0
FetchImage checks and fetch an image archive if available on a known remote.
type StoreCache ¶
type StoreCache struct { Paths []string // The mapping of name + reference to image archive Images map[Image]Archive }
StoreCache holds a temporary cache for images/references in the store
func NewStoreCache ¶
func NewStoreCache(paths []string) (StoreCache, error)
NewStoreCache constructs a new StoreCache using `paths` as lookup directories
func (*StoreCache) ArchiveFor ¶
func (sc *StoreCache) ArchiveFor(im Image) (Archive, error)
ArchiveFor looks for a reference in the store, returning the path to the archive containing it