torcx

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
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/"
)
View Source
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

View Source
var DefaultLowerProfiles = []string{VendorProfileName, OemProfileName}

DefaultLowerProfiles are the default lower profiles (for vendor and oem entries)

View Source
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 AddToProfile(profilePath string, im Image) error

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

func CurrentOsVersionID(path string) (string, error)

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

func CurrentProfileNames() (string, []string, error)

CurrentProfileNames returns the name of the currently running user and vendor profiles

func CurrentProfilePath

func CurrentProfilePath() (string, error)

CurrentProfilePath returns the path of the currently running profile

func FilterStoreVersions

func FilterStoreVersions(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

func IsExistingPath(fusePath string) bool

IsExistingPath checks whether the given path already exists.

func ListProfiles

func ListProfiles(profileDirs []string) (map[string]string, error)

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

func ReadMetadata(fusePath string) (map[string]string, error)

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 Archive

type Archive struct {
	Image
	Filepath string `json:"filepath"`
}

Archive represents a .torcx.tgz on disk

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

type Image struct {
	Name      string `json:"name"`
	Reference string `json:"reference"`
}

Image is an archive name + Reference

func (*Image) ArchiveFilename

func (im *Image) ArchiveFilename() string

ArchiveFilename is the filename (no directory) for the archive of an image.

type ImageManifestV0

type ImageManifestV0 struct {
	Kind  string `json:"kind"`
	Value Assets `json:"value"`
}

ImageManifestV0 holds JSON image manifest

type Images

type Images struct {
	Images []Image `json:"images"`
}

func ReadCurrentProfile

func ReadCurrentProfile() (Images, error)

ReadCurrentProfile returns the content of the currently running profile

func ReadProfilePath

func ReadProfilePath(path string) (Images, error)

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

type ProfileManifestV0 struct {
	Kind  string `json:"kind"`
	Value Images `json:"value"`
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL