Documentation ¶
Index ¶
- Constants
- Variables
- func AddHWAccess(snapname, device string) error
- func BareName(p Part) string
- func BuildLegacySnap(sourceDir, targetDir string) (string, error)
- func BuildSnapfsSnap(sourceDir, targetDir string) (string, error)
- func FirstBoot() error
- func FullName(p Part) string
- func GarbageCollect(name string, flags InstallFlags, pb progress.Meter) error
- func Install(name string, flags InstallFlags, meter progress.Meter) (string, error)
- func IsBuiltInSoftware(name string) bool
- func ListHWAccess(snapname string) ([]string, error)
- func PackageNameActive(name string) bool
- func Purge(partSpec string, flags PurgeFlags, meter progress.Meter) error
- func QualifiedName(p Part) string
- func RemoteManifestPath(s Part) string
- func Remove(partSpec string, flags RemoveFlags, meter progress.Meter) error
- func RemoveAllHWAccess(snapname string) error
- func RemoveHWAccess(snapname, device string) error
- func Rollback(pkg, ver string, inter progress.Meter) (version string, err error)
- func RunHooks() error
- func SetActive(fullName string, active bool, meter progress.Meter) error
- func SetArchitecture(newArch ArchitectureType)
- func SetProperty(pkgname string, inter progress.Meter, args ...string) (err error)
- func SplitOrigin(name string) (string, string)
- func StoreID() string
- func VersionCompare(va, vb string) (res int)
- func VersionIsValid(a string) bool
- func WriteStoreToken(token StoreToken) error
- type ArchitectureType
- type Binary
- type BootAssetFiles
- type BootAssetRawFiles
- type BootAssets
- type BySnapVersion
- type ByVersion
- type Configuration
- type ErrApparmorGenerate
- type ErrArchitectureNotSupported
- type ErrDataCopyFailed
- type ErrDownload
- type ErrFrameworkInUse
- type ErrGarbageCollectImpossible
- type ErrHookFailed
- type ErrInstallFailed
- type ErrInvalidYaml
- type ErrMissingFrameworks
- type ErrNameClash
- type ErrStructIllegalContent
- type ErrUpgradeVerificationFailed
- type HardwareAssign
- type InstallFlags
- type MetaRepository
- type OEM
- type PackageFile
- type PackageServiceStatus
- type Part
- func ActiveSnapByName(needle string) Part
- func ActiveSnapsByType(snapTs ...pkg.Type) (res []Part, err error)
- func FindSnapsByName(needle string, haystack []Part) (res []Part)
- func FindSnapsByNameAndVersion(needle, version string, haystack []Part) []Part
- func ListInstalled() ([]Part, error)
- func ListUpdates() ([]Part, error)
- func Update(flags InstallFlags, meter progress.Meter) ([]Part, error)
- type Port
- type Ports
- type PurgeFlags
- type RemoteSnapPart
- func (s *RemoteSnapPart) Channel() string
- func (s *RemoteSnapPart) Config(configuration []byte) (new string, err error)
- func (s *RemoteSnapPart) Date() time.Time
- func (s *RemoteSnapPart) Description() string
- func (s *RemoteSnapPart) Download(pbar progress.Meter) (string, error)
- func (s *RemoteSnapPart) DownloadSize() int64
- func (s *RemoteSnapPart) Frameworks() ([]string, error)
- func (s *RemoteSnapPart) Hash() string
- func (s *RemoteSnapPart) Icon() string
- func (s *RemoteSnapPart) Install(pbar progress.Meter, flags InstallFlags) (string, error)
- func (s *RemoteSnapPart) InstalledSize() int64
- func (s *RemoteSnapPart) IsActive() bool
- func (s *RemoteSnapPart) IsInstalled() bool
- func (s *RemoteSnapPart) Name() string
- func (s *RemoteSnapPart) NeedsReboot() bool
- func (s *RemoteSnapPart) Origin() string
- func (s *RemoteSnapPart) SetActive(bool, progress.Meter) error
- func (s *RemoteSnapPart) Type() pkg.Type
- func (s *RemoteSnapPart) Uninstall(progress.Meter) error
- func (s *RemoteSnapPart) Vendor() string
- func (s *RemoteSnapPart) Version() string
- type RemoveFlags
- type Repository
- type SecurityDefinitions
- type SecurityOverrideDefinition
- type SecurityPolicyDefinition
- type ServiceActor
- type ServiceYaml
- type ServiceYamler
- type SharedName
- type SharedNames
- type SnapDataDir
- type SnapLocalRepository
- func (s *SnapLocalRepository) All() ([]Part, error)
- func (s *SnapLocalRepository) Description() string
- func (s *SnapLocalRepository) Details(name string, origin string) (versions []Part, err error)
- func (s *SnapLocalRepository) Installed() (parts []Part, err error)
- func (s *SnapLocalRepository) Updates() (parts []Part, err error)
- type SnapPart
- func (s *SnapPart) Binaries() []Binary
- func (s *SnapPart) CanInstall(allowOEM bool, inter interacter) error
- func (s *SnapPart) Channel() string
- func (s *SnapPart) Config(configuration []byte) (new string, err error)
- func (s *SnapPart) Date() time.Time
- func (s *SnapPart) DependentNames() ([]string, error)
- func (s *SnapPart) Dependents() ([]*SnapPart, error)
- func (s *SnapPart) Description() string
- func (s *SnapPart) DownloadSize() int64
- func (s *SnapPart) Frameworks() ([]string, error)
- func (s *SnapPart) Hash() string
- func (s *SnapPart) Icon() string
- func (s *SnapPart) Install(inter progress.Meter, flags InstallFlags) (name string, err error)
- func (s *SnapPart) InstalledSize() int64
- func (s *SnapPart) IsActive() bool
- func (s *SnapPart) IsInstalled() bool
- func (s *SnapPart) Name() string
- func (s *SnapPart) NeedsReboot() bool
- func (s *SnapPart) OemConfig() SystemConfig
- func (s *SnapPart) Origin() string
- func (s *SnapPart) RefreshDependentsSecurity(oldPart *SnapPart, inter interacter) (err error)
- func (s *SnapPart) RequestAppArmorUpdate(policies, templates map[string]bool) error
- func (s *SnapPart) ServiceYamls() []ServiceYaml
- func (s *SnapPart) SetActive(active bool, pb progress.Meter) (err error)
- func (s *SnapPart) Type() pkg.Type
- func (s *SnapPart) Uninstall(pb progress.Meter) (err error)
- func (s *SnapPart) Vendor() string
- func (s *SnapPart) Version() string
- type SnapUbuntuStoreRepository
- func (s *SnapUbuntuStoreRepository) All() ([]Part, error)
- func (s *SnapUbuntuStoreRepository) Description() string
- func (s *SnapUbuntuStoreRepository) Details(name string, origin string) (parts []Part, err error)
- func (s *SnapUbuntuStoreRepository) Installed() (parts []Part, err error)
- func (s *SnapUbuntuStoreRepository) Search(searchTerm string) (SharedNames, error)
- func (s *SnapUbuntuStoreRepository) Updates() (parts []Part, err error)
- type Software
- type Store
- type StoreToken
- type SystemConfig
- type SystemImagePart
- func (s *SystemImagePart) Channel() string
- func (s *SystemImagePart) Config(configuration []byte) (newConfig string, err error)
- func (s *SystemImagePart) Date() time.Time
- func (s *SystemImagePart) Description() string
- func (s *SystemImagePart) DownloadSize() int64
- func (s *SystemImagePart) Frameworks() ([]string, error)
- func (s *SystemImagePart) Hash() string
- func (s *SystemImagePart) Icon() string
- func (s *SystemImagePart) Install(pb progress.Meter, flags InstallFlags) (name string, err error)
- func (s *SystemImagePart) InstalledSize() int64
- func (s *SystemImagePart) IsActive() bool
- func (s *SystemImagePart) IsInstalled() bool
- func (s *SystemImagePart) MarkBootSuccessful() (err error)
- func (s *SystemImagePart) Name() string
- func (s *SystemImagePart) NeedsReboot() bool
- func (s *SystemImagePart) Origin() string
- func (s *SystemImagePart) SetActive(active bool, pb progress.Meter) error
- func (s *SystemImagePart) Type() pkg.Type
- func (s *SystemImagePart) Uninstall(progress.Meter) error
- func (s *SystemImagePart) Vendor() string
- func (s *SystemImagePart) Version() string
- type SystemImageRepository
- func (s *SystemImageRepository) All() ([]Part, error)
- func (s *SystemImageRepository) Description() string
- func (s *SystemImageRepository) Details(name string, origin string) ([]Part, error)
- func (s *SystemImageRepository) Installed() ([]Part, error)
- func (s *SystemImageRepository) Search(terms string) (versions []Part, err error)
- func (s *SystemImageRepository) Updates() ([]Part, error)
- type Timeout
Constants ¶
const ( // Archi386 is the i386 architecture Archi386 ArchitectureType = "i386" // ArchAmd64 is the amd64 architecture ArchAmd64 = "amd64" // ArchArmhf is the armhf architecture ArchArmhf = "armhf" )
const ( SystemImagePartName = "ubuntu-core" // SystemImagePartOrigin is the origin of any system image part SystemImagePartOrigin = "ubuntu" // SystemImagePartVendor is the vendor of any system image part SystemImagePartVendor = "Canonical Ltd." )
SystemImagePart have constant name, origin, and vendor.
const (
// SideloadedOrigin is the (forced) origin for sideloaded snaps
SideloadedOrigin = "sideload"
)
Variables ¶
var ( // ErrPackageNotFound is returned when a snap can not be found ErrPackageNotFound = errors.New("snappy package not found") // ErrServiceNotFound is returned when a service can not be found ErrServiceNotFound = errors.New("snappy service not found") // ErrNeedRoot is returned when a command needs root privs but // the caller is not root ErrNeedRoot = errors.New("this command requires root access. Please re-run using 'sudo'") // ErrPackageNotRemovable is returned when trying to remove a package // that cannot be removed. ErrPackageNotRemovable = errors.New("snappy package cannot be removed") // ErrConfigNotFound is returned if a snap without a config is // getting configured ErrConfigNotFound = errors.New("no config found for this snap") // ErrInvalidHWDevice is returned when a invalid hardware device // is given in the hw-assign command ErrInvalidHWDevice = errors.New("invalid hardware device") // ErrHWAccessRemoveNotFound is returned if the user tries to // remove a device that does not exist ErrHWAccessRemoveNotFound = errors.New("can not find device in hw-access list") // ErrHWAccessAlreadyAdded is returned if you try to add a device // that is already in the hwaccess list ErrHWAccessAlreadyAdded = errors.New("device is already in hw-access list") // ErrReadmeInvalid is returned if the package contains a invalid // meta/readme.md ErrReadmeInvalid = errors.New("meta/readme.md invalid") // ErrAuthenticationNeeds2fa is returned if the authentication // needs 2factor ErrAuthenticationNeeds2fa = errors.New("authentication needs second factor") // ErrNotInstalled is returned when the snap is not installed ErrNotInstalled = errors.New("the given snap is not installed") // ErrAlreadyInstalled is returned when the snap is already installed ErrAlreadyInstalled = errors.New("the given snap is already installed") // ErrStillActive is returned when the snap is still installed ErrStillActive = errors.New("the given snap is still installed") // ErrPackageNameAlreadyInstalled is returned when you try to install // a fork of something you already have installed ErrPackageNameAlreadyInstalled = errors.New("a package by that name is already installed") // ErrOEMPackageInstall is returned when you try to install // an oem package type on a running system. ErrOEMPackageInstall = errors.New("oem package installation not allowed") // ErrPrivOpInProgress is returned when a privileged operation // cannot be performed since an existing privileged operation is // still running. ErrPrivOpInProgress = errors.New("privileged operation already in progress") // ErrInvalidCredentials is returned on login error ErrInvalidCredentials = errors.New("invalid credentials") // ErrInvalidFrameworkSpecInYaml is returned if a package.yaml // has both frameworks and framework entries. ErrInvalidFrameworkSpecInYaml = errors.New("yaml can't have both \"frameworks\" and (deprecated) \"framework\" keys") // ErrSnapNotActive is returned if you try to unset a snap from // active to inactive ErrSnapNotActive = errors.New("snap not active") // ErrBuildPlatformNotSupported is returned if you build on // a not (yet) supported platform ErrBuildPlatformNotSupported = errors.New("building on a not (yet) supported platform") // ErrLicenseNotAccepted is returned when the user does not accept the // license ErrLicenseNotAccepted = errors.New("license not accepted") // ErrLicenseBlank is returned when the package specifies that // accepting license is required, but the license file was empty or // blank ErrLicenseBlank = errors.New("package.yaml requires accepting a license, but license file was blank") // ErrLicenseNotProvided is returned when the package specifies that // accepting a license is required, but no license file is provided ErrLicenseNotProvided = errors.New("package.yaml requires license, but no license was provided") // ErrNotFirstBoot is an error that indicates that the first boot has already // run ErrNotFirstBoot = errors.New("this is not your first boot") // ErrNotImplemented may be returned when an implementation of // an interface is partial. ErrNotImplemented = errors.New("not implemented") // ErrNoOemConfiguration may be returned when there is a pkg.TypeOem installed // but does not provide a configuration. ErrNoOemConfiguration = errors.New("no configuration entry found in the oem snap") // ErrInstalledNonSnapPart is returned if a part that is purportedly // installed turns out to not be a SnapPart. ErrInstalledNonSnapPart = errors.New("installed dependent snap is not a SnapPart") // ErrSideLoaded is returned on system update if the system was // created with a custom enablement part. ErrSideLoaded = errors.New("cannot update system that uses custom enablement") // ErrPackageNameNotSupported is returned when installing legacy package such as those // that have the origin specified in their package names. ErrPackageNameNotSupported = errors.New("package name with origin not supported") // ErrInvalidPart is returned when something on the filesystem does not make sense ErrInvalidPart = errors.New("invalid package on system") // ErrInvalidSeccompPolicy is returned when policy-version and policy-vender are not set together ErrInvalidSeccompPolicy = errors.New("policy-version and policy-vendor must be specified together") // ErrNoSeccompPolicy is returned when an expected seccomp policy is not provided. ErrNoSeccompPolicy = errors.New("no seccomp policy provided") )
var ActiveSnapIterByType = activeSnapIterByTypeImpl
ActiveSnapIterByType returns the result of applying the given function to all active snaps with the given type.
var DefaultTimeout = Timeout(30 * time.Second)
DefaultTimeout specifies the timeout for services that do not specify StopTimeout
Functions ¶
func AddHWAccess ¶
AddHWAccess allows the given snap package to access the given hardware device
func BuildLegacySnap ¶
BuildLegacySnap the given sourceDirectory and return the generated snap file
func BuildSnapfsSnap ¶
BuildSnapfsSnap the given sourceDirectory and return the generated snap file
func FirstBoot ¶
func FirstBoot() error
FirstBoot checks whether it's the first boot, and if so enables the first ethernet device and runs oemConfig (as well as flagging that it run)
func GarbageCollect ¶
func GarbageCollect(name string, flags InstallFlags, pb progress.Meter) error
GarbageCollect removes all versions two older than the current active version, as long as NeedsReboot() is false on all the versions found, and DoInstallGC is set.
func Install ¶
Install the givens snap names provided via args. This can be local files or snaps that are queried from the store
func IsBuiltInSoftware ¶
IsBuiltInSoftware returns true if the package is part of the built-in software defined by the oem.
func ListHWAccess ¶
ListHWAccess returns a list of hardware-device strings that the snap can access
func PackageNameActive ¶
PackageNameActive checks whether a fork of the given name is active in the system
func Purge ¶
func Purge(partSpec string, flags PurgeFlags, meter progress.Meter) error
Purge a part by a partSpec string, name[.origin][=version]
func QualifiedName ¶
QualifiedName of a Part is the Name, in most cases qualified with the Origin
func RemoteManifestPath ¶
RemoteManifestPath returns the would be path for the store manifest meta data
func Remove ¶
func Remove(partSpec string, flags RemoveFlags, meter progress.Meter) error
Remove a part by a partSpec string, name[.origin][=version]
func RemoveAllHWAccess ¶
RemoveAllHWAccess removes all hw access from the given snap.
func RemoveHWAccess ¶
RemoveHWAccess allows the given snap package to access the given hardware device
func Rollback ¶
Rollback will roll the given pkg back to the given ver. If the version is empty the previous installed version will be used.
The version needs to be installed on disk
func SetArchitecture ¶
func SetArchitecture(newArch ArchitectureType)
SetArchitecture allows overriding the auto detected Architecture
func SetProperty ¶
SetProperty sets a property for the given pkgname from the args list
func SplitOrigin ¶
SplitOrigin splits a snappy name name into a (name, origin) pair
func StoreID ¶
func StoreID() string
StoreID returns the store id setup by the oem package or an empty string
func VersionCompare ¶
VersionCompare compare two version strings and Returns:
-1 if a is smaller than b 0 if a equals b +1 if a is bigger than b
func VersionIsValid ¶
VersionIsValid returns true if the given string is a valid snap version number
func WriteStoreToken ¶
func WriteStoreToken(token StoreToken) error
WriteStoreToken takes the token and stores it on the filesystem for later reading via ReadStoreToken()
Types ¶
type ArchitectureType ¶
type ArchitectureType string
ArchitectureType is the type for a supported snappy architecture
func Architecture ¶
func Architecture() ArchitectureType
Architecture returns the native architecture that snappy runs on
type Binary ¶
type Binary struct { Name string `yaml:"name"` Exec string `yaml:"exec"` SecurityDefinitions `yaml:",inline"` }
Binary represents a single binary inside the binaries: package.yaml
type BootAssetFiles ¶
BootAssetFiles represent all the files required for booting a system that are particular to the board
type BootAssetRawFiles ¶
BootAssetRawFiles represent all the artifacts required for booting a system that are particular to the board and require copying to specific sectors of the disk
type BootAssets ¶
type BootAssets struct { Files []BootAssetFiles `yaml:"files,omitempty"` RawFiles []BootAssetRawFiles `yaml:"raw-files,omitempty"` }
BootAssets represent all the artifacts required for booting a system that are particular to the board.
type BySnapVersion ¶
type BySnapVersion []Part
BySnapVersion provides a sort interface
func (BySnapVersion) Len ¶
func (bv BySnapVersion) Len() int
func (BySnapVersion) Less ¶
func (bv BySnapVersion) Less(a, b int) bool
func (BySnapVersion) Swap ¶
func (bv BySnapVersion) Swap(a, b int)
type Configuration ¶
type Configuration interface {
OemConfig() SystemConfig
}
Configuration allows requesting an oem snappy package type's config
type ErrApparmorGenerate ¶
ErrApparmorGenerate is reported if the apparmor profile generation fails
func (ErrApparmorGenerate) Error ¶
func (e ErrApparmorGenerate) Error() string
type ErrArchitectureNotSupported ¶
type ErrArchitectureNotSupported struct {
Architectures []string
}
ErrArchitectureNotSupported is returned when trying to install a snappy package that is not supported on the system
func (*ErrArchitectureNotSupported) Error ¶
func (e *ErrArchitectureNotSupported) Error() string
type ErrDataCopyFailed ¶
ErrDataCopyFailed is returned if copying the snap data fialed
func (*ErrDataCopyFailed) Error ¶
func (e *ErrDataCopyFailed) Error() string
type ErrDownload ¶
ErrDownload represents a download error
func (*ErrDownload) Error ¶
func (e *ErrDownload) Error() string
type ErrFrameworkInUse ¶
type ErrFrameworkInUse []string
ErrFrameworkInUse reports that a framework is still needed by apps currently installed
func (ErrFrameworkInUse) Error ¶
func (e ErrFrameworkInUse) Error() string
type ErrGarbageCollectImpossible ¶
type ErrGarbageCollectImpossible string
ErrGarbageCollectImpossible is alerting about some of the assumptions of the garbage collector not being true (and thus not safe to run the gc).
func (ErrGarbageCollectImpossible) Error ¶
func (e ErrGarbageCollectImpossible) Error() string
type ErrHookFailed ¶
ErrHookFailed is returned if a hook command fails
func (*ErrHookFailed) Error ¶
func (e *ErrHookFailed) Error() string
type ErrInstallFailed ¶
ErrInstallFailed is an error type for installation errors for snaps
func (*ErrInstallFailed) Error ¶
func (e *ErrInstallFailed) Error() string
ErrInstallFailed is an error type for installation errors for snaps
type ErrInvalidYaml ¶
ErrInvalidYaml is returned if a yaml file can not be parsed
func (*ErrInvalidYaml) Error ¶
func (e *ErrInvalidYaml) Error() string
type ErrMissingFrameworks ¶
type ErrMissingFrameworks []string
ErrMissingFrameworks reports a conflict between the frameworks needed by an app and those installed in the system
func (ErrMissingFrameworks) Error ¶
func (e ErrMissingFrameworks) Error() string
type ErrNameClash ¶
type ErrNameClash string
ErrNameClash reports a conflict between a named service and binary in a package.
func (ErrNameClash) Error ¶
func (e ErrNameClash) Error() string
type ErrStructIllegalContent ¶
ErrStructIllegalContent is returned if a struct contains illegal content as matched via "verifyWhitelistForStruct"
func (*ErrStructIllegalContent) Error ¶
func (e *ErrStructIllegalContent) Error() string
type ErrUpgradeVerificationFailed ¶
type ErrUpgradeVerificationFailed struct {
Msg string
}
ErrUpgradeVerificationFailed is returned if the upgrade has not worked (i.e. no new version on the other partition)
func (*ErrUpgradeVerificationFailed) Error ¶
func (e *ErrUpgradeVerificationFailed) Error() string
type HardwareAssign ¶
type HardwareAssign struct { PartID string `yaml:"part-id,omitempty"` Rules []struct { Kernel string `yaml:"kernel,omitempty"` Subsystem string `yaml:"subsystem,omitempty"` WithSubsystems string `yaml:"with-subsystems,omitempty"` WithDriver string `yaml:"with-driver,omitempty"` WithAttrs []string `yaml:"with-attrs,omitempty"` WithProps []string `yaml:"with-props,omitempty"` } `yaml:"rules,omitempty"` }
HardwareAssign describes the hardware a app can use
type InstallFlags ¶
type InstallFlags uint
InstallFlags can be used to pass additional flags to the install of a snap
const ( // AllowUnauthenticated allows to install a snap even if it can not be authenticated AllowUnauthenticated InstallFlags = 1 << iota // InhibitHooks will ensure that the hooks are not run InhibitHooks // DoInstallGC will ensure that garbage collection is done DoInstallGC // AllowOEM allows the installation of OEM packages, this does not affect updates. AllowOEM )
type MetaRepository ¶
type MetaRepository struct {
// contains filtered or unexported fields
}
MetaRepository contains all available single repositories can can be used to query in a single place
func NewMetaLocalRepository ¶
func NewMetaLocalRepository() *MetaRepository
NewMetaLocalRepository returns a MetaRepository of stores
func NewMetaRepository ¶
func NewMetaRepository() *MetaRepository
NewMetaRepository returns a new MetaRepository
func NewMetaStoreRepository ¶
func NewMetaStoreRepository() *MetaRepository
NewMetaStoreRepository returns a MetaRepository of stores
func (*MetaRepository) Details ¶
func (m *MetaRepository) Details(name string, origin string) ([]Part, error)
Details returns details for the given snap name
func (*MetaRepository) Installed ¶
func (m *MetaRepository) Installed() (parts []Part, err error)
Installed returns all installed parts
func (*MetaRepository) Updates ¶
func (m *MetaRepository) Updates() (parts []Part, err error)
Updates returns all updatable parts
type OEM ¶
type OEM struct { Store Store `yaml:"store,omitempty"` Hardware struct { Assign []HardwareAssign `yaml:"assign,omitempty"` BootAssets *BootAssets `yaml:"boot-assets,omitempty"` } `yaml:"hardware,omitempty"` Software Software `yaml:"software,omitempty"` }
OEM represents the structure inside the package.yaml for the oem component of an oem package type.
type PackageFile ¶
type PackageFile interface { Verify(allowUnauthenticated bool) error Close() error UnpackWithDropPrivs(targetDir, rootDir string) error ControlMember(name string) ([]byte, error) MetaMember(name string) ([]byte, error) ExtractHashes(targetDir string) error }
PackageFile is the interface to interact with the low-level snap files
func OpenPackageFile ¶
func OpenPackageFile(path string) (PackageFile, error)
OpenPackageFile opens a given snap file with the right backend
type PackageServiceStatus ¶
type PackageServiceStatus struct { systemd.ServiceStatus PackageName string `json:"package_name"` ServiceName string `json:"service_name"` }
A PackageServiceStatus annotates systemd's ServiceStatus with package information systemd is unaware of.
type Part ¶
type Part interface { // query Name() string Version() string Description() string Origin() string Vendor() string Hash() string IsActive() bool IsInstalled() bool // Will become active on the next reboot NeedsReboot() bool // returns the date when the snap was last updated Date() time.Time // returns the channel of the part Channel() string // returns the path to the icon (local or uri) Icon() string // Returns app, framework, core Type() pkg.Type InstalledSize() int64 DownloadSize() int64 // Install the snap Install(pb progress.Meter, flags InstallFlags) (name string, err error) // Uninstall the snap Uninstall(pb progress.Meter) error // Config takes a yaml configuration and returns the full snap // config with the changes. Note that "configuration" may be empty. Config(configuration []byte) (newConfig string, err error) // make an inactive part active, or viceversa SetActive(bool, progress.Meter) error // get the list of frameworks needed by the part Frameworks() ([]string, error) }
Part representation of a snappy part
func ActiveSnapByName ¶
ActiveSnapByName returns all active snaps with the given name
func ActiveSnapsByType ¶
ActiveSnapsByType returns all installed snaps with the given type
func FindSnapsByName ¶
FindSnapsByName returns all snaps with the given name in the "haystack" slice of parts (useful for filtering)
func FindSnapsByNameAndVersion ¶
FindSnapsByNameAndVersion returns the parts with the name/version in the given slice of parts
type Port ¶
type Port struct { Port string `yaml:"port,omitempty"` Negotiable bool `yaml:"negotiable,omitempty"` }
Port is used to declare the Port and Negotiable status of such port that is bound to a ServiceYaml.
type Ports ¶
type Ports struct { Internal map[string]Port `yaml:"internal,omitempty" json:"internal,omitempty"` External map[string]Port `yaml:"external,omitempty" json:"external,omitempty"` }
Ports is a representation of Internal and External ports mapped with a Port.
type PurgeFlags ¶
type PurgeFlags uint
PurgeFlags can be used to pass additional flags to the snap removal request
const ( // DoPurgeActive requests that the data files of an active // package be removed. Without this that is disallowed. DoPurgeActive PurgeFlags = 1 << iota )
type RemoteSnapPart ¶
type RemoteSnapPart struct {
// contains filtered or unexported fields
}
RemoteSnapPart represents a snap available on the server
func NewRemoteSnapPart ¶
func NewRemoteSnapPart(data remote.Snap) *RemoteSnapPart
NewRemoteSnapPart returns a new RemoteSnapPart from the given remote.Snap data
func (*RemoteSnapPart) Channel ¶
func (s *RemoteSnapPart) Channel() string
Channel returns the channel used
func (*RemoteSnapPart) Config ¶
func (s *RemoteSnapPart) Config(configuration []byte) (new string, err error)
Config is used to to configure the snap
func (*RemoteSnapPart) Date ¶
func (s *RemoteSnapPart) Date() time.Time
Date returns the last update time
func (*RemoteSnapPart) Description ¶
func (s *RemoteSnapPart) Description() string
Description returns the description
func (*RemoteSnapPart) Download ¶
func (s *RemoteSnapPart) Download(pbar progress.Meter) (string, error)
Download downloads the snap and returns the filename
func (*RemoteSnapPart) DownloadSize ¶
func (s *RemoteSnapPart) DownloadSize() int64
DownloadSize returns the dowload size
func (*RemoteSnapPart) Frameworks ¶
func (s *RemoteSnapPart) Frameworks() ([]string, error)
Frameworks returns the list of frameworks needed by the snap
func (*RemoteSnapPart) Install ¶
func (s *RemoteSnapPart) Install(pbar progress.Meter, flags InstallFlags) (string, error)
Install installs the snap
func (*RemoteSnapPart) InstalledSize ¶
func (s *RemoteSnapPart) InstalledSize() int64
InstalledSize returns the size of the installed snap
func (*RemoteSnapPart) IsActive ¶
func (s *RemoteSnapPart) IsActive() bool
IsActive returns true if the snap is active
func (*RemoteSnapPart) IsInstalled ¶
func (s *RemoteSnapPart) IsInstalled() bool
IsInstalled returns true if the snap is installed
func (*RemoteSnapPart) NeedsReboot ¶
func (s *RemoteSnapPart) NeedsReboot() bool
NeedsReboot returns true if the snap becomes active on the next reboot
func (*RemoteSnapPart) SetActive ¶
func (s *RemoteSnapPart) SetActive(bool, progress.Meter) error
SetActive sets the snap active
func (*RemoteSnapPart) Type ¶
func (s *RemoteSnapPart) Type() pkg.Type
Type returns the type of the SnapPart (app, oem, ...)
func (*RemoteSnapPart) Uninstall ¶
func (s *RemoteSnapPart) Uninstall(progress.Meter) error
Uninstall remove the snap from the system
func (*RemoteSnapPart) Vendor ¶
func (s *RemoteSnapPart) Vendor() string
Vendor is the publisher. Author. Whatever.
func (*RemoteSnapPart) Version ¶
func (s *RemoteSnapPart) Version() string
Version returns the version
type RemoveFlags ¶
type RemoveFlags uint
RemoveFlags can be used to pass additional flags to the snap removal request
const ( // DoRemoveGC will ensure that garbage collection is done, unless a // version is specified. DoRemoveGC RemoveFlags = 1 << iota )
type Repository ¶
type Repository interface { // query Description() string // action Details(name string, origin string) ([]Part, error) Updates() ([]Part, error) Installed() ([]Part, error) All() ([]Part, error) }
Repository is the interface for a collection of snaps
type SecurityDefinitions ¶
type SecurityDefinitions struct { // SecurityTemplate is a template like "default" SecurityTemplate string `yaml:"security-template,omitempty" json:"security-template,omitempty"` // SecurityOverride is a override for the high level security json SecurityOverride *SecurityOverrideDefinition `yaml:"security-override,omitempty" json:"security-override,omitempty"` // SecurityPolicy is a hand-crafted low-level policy SecurityPolicy *SecurityPolicyDefinition `yaml:"security-policy,omitempty" json:"security-policy,omitempty"` // SecurityCaps is are the apparmor/seccomp capabilities for an app SecurityCaps []string `yaml:"caps,omitempty" json:"caps,omitempty"` }
SecurityDefinitions contains the common apparmor/seccomp definitions
func (*SecurityDefinitions) NeedsAppArmorUpdate ¶
func (sd *SecurityDefinitions) NeedsAppArmorUpdate(policies, templates map[string]bool) bool
NeedsAppArmorUpdate checks whether the security definitions are impacted by changes to policies or templates.
type SecurityOverrideDefinition ¶
type SecurityOverrideDefinition struct { Apparmor string `yaml:"apparmor" json:"apparmor"` Seccomp string `yaml:"seccomp" json:"seccomp"` }
SecurityOverrideDefinition is used to override apparmor or seccomp security defaults
type SecurityPolicyDefinition ¶
type SecurityPolicyDefinition struct { Apparmor string `yaml:"apparmor" json:"apparmor"` Seccomp string `yaml:"seccomp" json:"seccomp"` }
SecurityPolicyDefinition is used to provide hand-crafted policy
type ServiceActor ¶
type ServiceActor interface { Enable() error Disable() error Start() error Stop() error Restart() error Status() ([]string, error) ServiceStatus() ([]*PackageServiceStatus, error) Logs() ([]systemd.Log, error) Loglines() ([]string, error) }
A ServiceActor collects the services found by FindServices and lets you perform differnt actions (start, stop, etc) on them.
func FindServices ¶
FindServices finds all matching services (empty string matches all) and lets you perform different actions (start, stop, etc) on them.
If a snap is specified and no matching snaps are found, ErrPackageNotFound is returned. If a snap is specified and the matching snaps has no matching services, ErrServiceNotFound is returned.
If no snap is specified, an empty result is not an error.
type ServiceYaml ¶
type ServiceYaml struct { Name string `yaml:"name" json:"name,omitempty"` Description string `yaml:"description,omitempty" json:"description,omitempty"` Start string `yaml:"start,omitempty" json:"start,omitempty"` Stop string `yaml:"stop,omitempty" json:"stop,omitempty"` PostStop string `yaml:"poststop,omitempty" json:"poststop,omitempty"` StopTimeout Timeout `yaml:"stop-timeout,omitempty" json:"stop-timeout,omitempty"` BusName string `yaml:"bus-name,omitempty" json:"bus-name,omitempty"` Forking bool `yaml:"forking,omitempty" json:"forking,omitempty"` // set to yes if we need to create a systemd socket for this service Socket bool `yaml:"socket,omitempty" json:"socket,omitempty"` ListenStream string `yaml:"listen-stream,omitempty" json:"listen-stream,omitempty"` SocketMode string `yaml:"socket-mode,omitempty" json:"socket-mode,omitempty"` SocketUser string `yaml:"socket-user,omitempty" json:"socket-user,omitempty"` SocketGroup string `yaml:"socket-group,omitempty" json:"socket-group,omitempty"` // must be a pointer so that it can be "nil" and omitempty works Ports *Ports `yaml:"ports,omitempty" json:"ports,omitempty"` SecurityDefinitions `yaml:",inline"` }
ServiceYaml represents a service inside a SnapPart
type ServiceYamler ¶
type ServiceYamler interface {
ServiceYamls() []ServiceYaml
}
ServiceYamler implements snappy packages that offer services
type SharedName ¶
type SharedName struct {}
SharedName is a structure that holds an Alias to the preferred package and the list of all the alternatives.
func (*SharedName) IsAlias ¶
func (f *SharedName) IsAlias(origin string) bool
IsAlias determines if origin is the one that is an alias for the shared name.
type SharedNames ¶
type SharedNames map[string]*SharedName
SharedNames is a list of all packages and it's SharedName structure.
func Search ¶
func Search(args []string) (SharedNames, error)
Search searches all repositories with the given keywords in the args slice
type SnapDataDir ¶
A SnapDataDir represents a single data directory for a version of a package
func DataDirs ¶
func DataDirs(spec string) []SnapDataDir
DataDirs returns the list of all SnapDataDirs in the system.
func (SnapDataDir) QualifiedName ¶
func (dd SnapDataDir) QualifiedName() string
QualifiedName returns the filesystem directory name for this SnapDataDir
type SnapLocalRepository ¶
type SnapLocalRepository struct {
// contains filtered or unexported fields
}
SnapLocalRepository is the type for a local snap repository
func NewLocalSnapRepository ¶
func NewLocalSnapRepository(path string) *SnapLocalRepository
NewLocalSnapRepository returns a new SnapLocalRepository for the given path
func (*SnapLocalRepository) All ¶
func (s *SnapLocalRepository) All() ([]Part, error)
All the parts (ie all installed + removed-but-not-purged)
TODO: that thing about removed
func (*SnapLocalRepository) Description ¶
func (s *SnapLocalRepository) Description() string
Description describes the local repository
func (*SnapLocalRepository) Details ¶
func (s *SnapLocalRepository) Details(name string, origin string) (versions []Part, err error)
Details returns details for the given snap
func (*SnapLocalRepository) Installed ¶
func (s *SnapLocalRepository) Installed() (parts []Part, err error)
Installed returns the installed snaps from this repository
func (*SnapLocalRepository) Updates ¶
func (s *SnapLocalRepository) Updates() (parts []Part, err error)
Updates returns the available updates
type SnapPart ¶
type SnapPart struct {
// contains filtered or unexported fields
}
SnapPart represents a generic snap type
func NewInstalledSnapPart ¶
NewInstalledSnapPart returns a new SnapPart from the given yamlPath
func NewSnapPartFromSnapFile ¶
NewSnapPartFromSnapFile loads a snap from the given (clickdeb) snap file. Caller should call Close on the pkg. TODO: expose that Close.
func NewSnapPartFromYaml ¶
NewSnapPartFromYaml returns a new SnapPart from the given *packageYaml at yamlPath
func (*SnapPart) CanInstall ¶
CanInstall checks whether the SnapPart passes a series of tests required for installation
func (*SnapPart) DependentNames ¶
DependentNames returns a list of the names of apps installed that depend on this one
/!\ not part of the Part interface.
func (*SnapPart) Dependents ¶
Dependents gives the list of apps installed that depend on this one
/!\ not part of the Part interface.
func (*SnapPart) Description ¶
Description returns the description
func (*SnapPart) DownloadSize ¶
DownloadSize returns the dowload size
func (*SnapPart) Frameworks ¶
Frameworks returns the list of frameworks needed by the snap
func (*SnapPart) InstalledSize ¶
InstalledSize returns the size of the installed snap
func (*SnapPart) IsInstalled ¶
IsInstalled returns true if the snap is installed
func (*SnapPart) NeedsReboot ¶
NeedsReboot returns true if the snap becomes active on the next reboot
func (*SnapPart) OemConfig ¶
func (s *SnapPart) OemConfig() SystemConfig
OemConfig return a list of packages to configure
func (*SnapPart) RefreshDependentsSecurity ¶
RefreshDependentsSecurity refreshes the security policies of dependent snaps
func (*SnapPart) RequestAppArmorUpdate ¶
RequestAppArmorUpdate checks whether changes to the given policies and templates impacts the snap, and updates the timestamp of the relevant json symlinks (thus requesting aaClickHookCmd regenerate the appropriate bits).
func (*SnapPart) ServiceYamls ¶
func (s *SnapPart) ServiceYamls() []ServiceYaml
ServiceYamls return a list of ServiceYamls the package declares
type SnapUbuntuStoreRepository ¶
type SnapUbuntuStoreRepository struct {
// contains filtered or unexported fields
}
SnapUbuntuStoreRepository represents the ubuntu snap store
func NewUbuntuStoreSnapRepository ¶
func NewUbuntuStoreSnapRepository() *SnapUbuntuStoreRepository
NewUbuntuStoreSnapRepository creates a new SnapUbuntuStoreRepository
func (*SnapUbuntuStoreRepository) All ¶
func (s *SnapUbuntuStoreRepository) All() ([]Part, error)
All (installable) parts from the store
func (*SnapUbuntuStoreRepository) Description ¶
func (s *SnapUbuntuStoreRepository) Description() string
Description describes the repository
func (*SnapUbuntuStoreRepository) Details ¶
func (s *SnapUbuntuStoreRepository) Details(name string, origin string) (parts []Part, err error)
Details returns details for the given snap in this repository
func (*SnapUbuntuStoreRepository) Installed ¶
func (s *SnapUbuntuStoreRepository) Installed() (parts []Part, err error)
Installed returns the installed snaps from this repository
func (*SnapUbuntuStoreRepository) Search ¶
func (s *SnapUbuntuStoreRepository) Search(searchTerm string) (SharedNames, error)
Search searches the repository for the given searchTerm
func (*SnapUbuntuStoreRepository) Updates ¶
func (s *SnapUbuntuStoreRepository) Updates() (parts []Part, err error)
Updates returns the available updates
type Software ¶
type Software struct {
BuiltIn []string `yaml:"built-in,omitempty"`
}
Software describes the installed software provided by an OEM snap
type Store ¶
type Store struct {
ID string `yaml:"id,omitempty"`
}
Store holds information relevant to the store provided by an OEM snap
type StoreToken ¶
type StoreToken struct { OpenID string `json:"openid"` TokenName string `json:"token_name"` DateUpdated string `json:"date_updated"` DateCreated string `json:"date_created"` Href string `json:"href"` oauth.Token }
StoreToken contains the personal token to access the store
func ReadStoreToken ¶
func ReadStoreToken() (*StoreToken, error)
ReadStoreToken reads a token previously write via WriteStoreToken
func RequestStoreToken ¶
func RequestStoreToken(username, password, tokenName, otp string) (*StoreToken, error)
RequestStoreToken requests a token for accessing the ubuntu store
type SystemConfig ¶
type SystemConfig map[string]interface{}
SystemConfig is a config map holding configs for multiple packages
type SystemImagePart ¶
type SystemImagePart struct {
// contains filtered or unexported fields
}
SystemImagePart represents a "core" snap that is managed via the SystemImage client
func (*SystemImagePart) Channel ¶
func (s *SystemImagePart) Channel() string
Channel returns the system-image-server channel used
func (*SystemImagePart) Config ¶
func (s *SystemImagePart) Config(configuration []byte) (newConfig string, err error)
Config is used to to configure the snap
func (*SystemImagePart) Date ¶
func (s *SystemImagePart) Date() time.Time
Date returns the last update date
func (*SystemImagePart) Description ¶
func (s *SystemImagePart) Description() string
Description returns the description
func (*SystemImagePart) DownloadSize ¶
func (s *SystemImagePart) DownloadSize() int64
DownloadSize returns the dowload size
func (*SystemImagePart) Frameworks ¶
func (s *SystemImagePart) Frameworks() ([]string, error)
Frameworks returns the list of frameworks needed by the snap
func (*SystemImagePart) Install ¶
func (s *SystemImagePart) Install(pb progress.Meter, flags InstallFlags) (name string, err error)
Install installs the snap
func (*SystemImagePart) InstalledSize ¶
func (s *SystemImagePart) InstalledSize() int64
InstalledSize returns the size of the installed snap
func (*SystemImagePart) IsActive ¶
func (s *SystemImagePart) IsActive() bool
IsActive returns true if the snap is active
func (*SystemImagePart) IsInstalled ¶
func (s *SystemImagePart) IsInstalled() bool
IsInstalled returns true if the snap is installed
func (*SystemImagePart) MarkBootSuccessful ¶
func (s *SystemImagePart) MarkBootSuccessful() (err error)
MarkBootSuccessful marks the *currently* booted rootfs as "good" (it booted :) Note: Not part of the Part interface.
func (*SystemImagePart) NeedsReboot ¶
func (s *SystemImagePart) NeedsReboot() bool
NeedsReboot returns true if the snap becomes active on the next reboot
func (*SystemImagePart) Origin ¶
func (s *SystemImagePart) Origin() string
Origin returns the origin ("ubuntu")
func (*SystemImagePart) SetActive ¶
func (s *SystemImagePart) SetActive(active bool, pb progress.Meter) error
SetActive sets the snap active
func (*SystemImagePart) Type ¶
func (s *SystemImagePart) Type() pkg.Type
Type returns pkg.TypeCore for this snap
func (*SystemImagePart) Uninstall ¶
func (s *SystemImagePart) Uninstall(progress.Meter) error
Uninstall can not be used for "core" snaps
func (*SystemImagePart) Vendor ¶
func (s *SystemImagePart) Vendor() string
Vendor returns the vendor ("Canonical Ltd.")
func (*SystemImagePart) Version ¶
func (s *SystemImagePart) Version() string
Version returns the version
type SystemImageRepository ¶
type SystemImageRepository struct {
// contains filtered or unexported fields
}
SystemImageRepository is the type used for the system-image-server
func NewSystemImageRepository ¶
func NewSystemImageRepository() *SystemImageRepository
NewSystemImageRepository returns a new SystemImageRepository
func (*SystemImageRepository) All ¶
func (s *SystemImageRepository) All() ([]Part, error)
All installed parts. SystemImageParts are non-removable.
func (*SystemImageRepository) Description ¶
func (s *SystemImageRepository) Description() string
Description describes the repository
func (*SystemImageRepository) Details ¶
func (s *SystemImageRepository) Details(name string, origin string) ([]Part, error)
Details returns details for the given snap
func (*SystemImageRepository) Installed ¶
func (s *SystemImageRepository) Installed() ([]Part, error)
Installed returns the installed snaps from this repository
func (*SystemImageRepository) Search ¶
func (s *SystemImageRepository) Search(terms string) (versions []Part, err error)
Search searches the SystemImageRepository for the given terms
func (*SystemImageRepository) Updates ¶
func (s *SystemImageRepository) Updates() ([]Part, error)
Updates returns the available updates
type Timeout ¶
Timeout is a time.Duration that knows how to roundtrip to json and yaml
func (Timeout) MarshalJSON ¶
MarshalJSON is from the json.Marshaler interface
func (*Timeout) UnmarshalJSON ¶
UnmarshalJSON is from the json.Unmarshaler interface
Source Files ¶
- arch.go
- auth.go
- build.go
- click.go
- config.go
- datadir.go
- dbus.go
- errors.go
- firstboot.go
- globals.go
- hashes.go
- hwaccess.go
- install.go
- list.go
- oem.go
- parts.go
- pkgformat.go
- purge.go
- remove.go
- rollback.go
- search.go
- security.go
- service.go
- set.go
- set_active.go
- snapp.go
- sort.go
- systemimage.go
- systemimage_native.go
- timeout.go