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(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
- type ApplyConfig
- type Archive
- type Assets
- type CommonConfig
- func (cc *CommonConfig) NextProfile() string
- func (cc *CommonConfig) NextProfileName() (string, error)
- func (cc *CommonConfig) ProfileDirs() []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 Images
- type ProfileConfig
- type ProfileManifestV0
- type StoreCache
Constants ¶
const ( // SealPath is the path where metadata are written once the system has been sealed. SealPath = "/run/metadata/torcx" // VendorDir contains (immutable) assets provided by the vendor. VendorDir = "/usr/share/torcx/" // OemDir contains (mutable) assets provided by the oem. OemDir = "/usr/share/oem/torcx/" // OsReleasePath contains the current os-release version. OsReleasePath = "/usr/lib/os-release" // 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 ( // 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/" // VendorStoreDir is the vendor store path VendorStoreDir = VendorDir + "store/" // VendorProfilesDir is the vendor profiles path VendorProfilesDir = VendorDir + "profiles/" // OemStoreDir is the vendor store path OemStoreDir = OemDir + "store/" // OemProfilesDir is the vendor profiles path OemProfilesDir = OemDir + "profiles/" )
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" // ProfileManifestV0K - profile manifest kind, v0 ProfileManifestV0K = "profile-manifest-v0" // ImageManifestV0K - image manifest kind, v0 ImageManifestV0K = "image-manifest-v0" // CommonConfigV0K - common torcx config kind, v0 CommonConfigV0K = "torcx-config-v0" )
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 ¶
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 ¶
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
Types ¶
type ApplyConfig ¶
type ApplyConfig struct { CommonConfig LowerProfiles []string UpperProfile string }
ApplyConfig contains runtime configuration items specific to the `apply` subcommand
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"` 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) 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 ¶
Image is an archive name + Reference
func (*Image) ArchiveFilename ¶
ArchiveFilename is the filename (no directory) for the archive of an image.
type ImageManifestV0 ¶
ImageManifestV0 holds JSON image manifest
type Images ¶
type Images struct {
Images []Image `json:"images"`
}
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 ProfileConfig ¶
type ProfileConfig struct { CommonConfig LowerProfileNames []string UserProfileName string CurrentProfilePath string NextProfile string }
ProfileConfig contains runtime configuration items specific to the `profile` subcommand
type ProfileManifestV0 ¶
ProfileManifestV0 holds JSON profile manifest
type StoreCache ¶
type StoreCache struct { Paths []string // The mapping of name + reference to .tgz file 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