snappy

package
v0.0.0-...-921daf7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2016 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SideloadedOrigin is the (forced) origin for sideloaded snaps
	SideloadedOrigin = "sideload"
)
View Source
const (
	// UbuntuCoreWireProtocol is the protocol level we support when
	// communicating with the store. History:
	//  - "1": client supports squashfs snaps
	UbuntuCoreWireProtocol = "1"
)

Variables

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

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

	// ErrGadgetPackageInstall is returned when you try to install
	// a gadget package type on a running system.
	ErrGadgetPackageInstall = errors.New("gadget 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")

	// 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("snap.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("snap.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")

	// ErrNoGadgetConfiguration may be returned when there is a pkg.TypeGadget installed
	// but does not provide a configuration.
	ErrNoGadgetConfiguration = errors.New("no configuration entry found in the gadget 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")
)
View Source
var ActiveSnapIterByType = activeSnapIterByTypeImpl

ActiveSnapIterByType returns the result of applying the given function to all active snaps with the given type.

Functions

func AddHWAccess

func AddHWAccess(snapname, device string) error

AddHWAccess allows the given snap package to access the given hardware device

func BareName

func BareName(p Part) string

BareName of a Part is just its Name

func BuildSquashfsSnap

func BuildSquashfsSnap(sourceDir, targetDir string) (string, error)

BuildSquashfsSnap the given sourceDirectory and return the generated snap file

func CompareGeneratePolicyFromFile

func CompareGeneratePolicyFromFile(fn string) error

CompareGeneratePolicyFromFile is used to simulate security policy generation and returns if the policy would have changed

func FirstBoot

func FirstBoot() error

FirstBoot checks whether it's the first boot, and if so enables the first ethernet device and runs gadgetConfig (as well as flagging that it run)

func FullName

func FullName(p Part) string

FullName of a Part is Name.Origin

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 GeneratePolicyFromFile

func GeneratePolicyFromFile(fn string, force bool) error

GeneratePolicyFromFile is used to generate security policy on the system from the specified manifest file name

func Install

func Install(name string, flags InstallFlags, meter progress.Meter) (string, error)

Install the givens snap names provided via args. This can be local files or snaps that are queried from the store

func IsBuiltInSoftware

func IsBuiltInSoftware(name string) bool

IsBuiltInSoftware returns true if the package is part of the built-in software defined by the gadget.

func IsLicenseNotAccepted

func IsLicenseNotAccepted(err error) bool

IsLicenseNotAccepted checks whether err is (directly or indirectly) due to a ErrLicenseNotAccepted

func ListHWAccess

func ListHWAccess(snapname string) ([]string, error)

ListHWAccess returns a list of hardware-device strings that the snap can access

func PackageNameActive

func PackageNameActive(name string) bool

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

func QualifiedName(p Part) string

QualifiedName of a Part is the Name, in most cases qualified with the Origin

func RegenerateAllPolicy

func RegenerateAllPolicy(force bool) error

RegenerateAllPolicy will re-generate all policy that needs re-generating

func RemoteManifestPath

func RemoteManifestPath(s Part) string

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

func RemoveAllHWAccess(snapname string) error

RemoveAllHWAccess removes all hw access from the given snap.

func RemoveHWAccess

func RemoveHWAccess(snapname, device string) error

RemoveHWAccess allows the given snap package to access the given hardware device

func Rollback

func Rollback(pkg, ver string, inter progress.Meter) (version string, err error)

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 SetActive

func SetActive(fullName string, active bool, meter progress.Meter) error

SetActive sets the active state of the given package

func SetProperty

func SetProperty(pkgname string, inter progress.Meter, args ...string) (err error)

SetProperty sets a property for the given pkgname from the args list

func SplitOrigin

func SplitOrigin(name string) (string, string)

SplitOrigin splits a snappy name name into a (name, origin) pair

func StoreID

func StoreID() string

StoreID returns the store id setup by the gadget package or an empty string

func SyncBoot

func SyncBoot() error

SyncBoot synchronizes the active kernel and OS snap versions with the versions that actually booted. This is needed because a system may install "os=v2" but that fails to boot. The bootloader fallback logic will revert to "os=v1" but on the filesystem snappy still has the "active" version set to "v2" which is misleading. This code will check what kernel/os booted and set those versions active.

func VersionCompare

func VersionCompare(va, vb string) (res int)

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

func VersionIsValid(a string) bool

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 AppYaml

type AppYaml struct {
	// name is partent key
	Name string
	// part of the yaml
	Version string `yaml:"version"`
	Command string `yaml:"command"`
	Daemon  string `yaml:"daemon"`

	Description string          `yaml:"description,omitempty" json:"description,omitempty"`
	Stop        string          `yaml:"stop,omitempty"`
	PostStop    string          `yaml:"poststop,omitempty"`
	StopTimeout timeout.Timeout `yaml:"stop-timeout,omitempty"`
	BusName     string          `yaml:"bus-name,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"`

	// systemd "restart" thing
	RestartCond systemd.RestartCondition `yaml:"restart-condition,omitempty" json:"restart-condition,omitempty"`

	// must be a pointer so that it can be "nil" and omitempty works
	Ports *Ports `yaml:"ports,omitempty" json:"ports,omitempty"`

	OffersRef []string `yaml:"offers"`
	UsesRef   []string `yaml:"uses"`
}

AppYaml represents an application (binary or service)

type BootAssetFiles

type BootAssetFiles struct {
	Path   string `yaml:"path"`
	Target string `yaml:"target,omitempty"`
}

BootAssetFiles represent all the files required for booting a system that are particular to the board

type BootAssetRawFiles

type BootAssetRawFiles struct {
	Path   string `yaml:"path"`
	Offset string `yaml:"offset"`
}

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 ByVersion

type ByVersion []string

ByVersion provides a sort interface

func (ByVersion) Len

func (bv ByVersion) Len() int

func (ByVersion) Less

func (bv ByVersion) Less(a, b int) bool

func (ByVersion) Swap

func (bv ByVersion) Swap(a, b int)

type Configuration

type Configuration interface {
	GadgetConfig() SystemConfig
}

Configuration allows requesting a gadget snappy package type's config

type ErrApparmorGenerate

type ErrApparmorGenerate struct {
	ExitCode int
	Output   []byte
}

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

type ErrDataCopyFailed

type ErrDataCopyFailed struct {
	OldPath  string
	NewPath  string
	ExitCode int
}

ErrDataCopyFailed is returned if copying the snap data fialed

func (*ErrDataCopyFailed) Error

func (e *ErrDataCopyFailed) Error() string

type ErrDownload

type ErrDownload struct {
	Code int
	URL  *url.URL
}

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

type ErrHookFailed

type ErrHookFailed struct {
	Cmd      string
	Output   string
	ExitCode int
}

ErrHookFailed is returned if a hook command fails

func (*ErrHookFailed) Error

func (e *ErrHookFailed) Error() string

type ErrInstallFailed

type ErrInstallFailed struct {
	Snap    string
	OrigErr error
}

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

type ErrInvalidYaml struct {
	File string
	Err  error
	Yaml []byte
}

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

type ErrStructIllegalContent struct {
	Field     string
	Content   string
	Whitelist string
}

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

type Gadget

type Gadget struct {
	Store                Store    `yaml:"store,omitempty"`
	Hardware             Hardware `yaml:"hardware,omitempty"`
	Software             Software `yaml:"software,omitempty"`
	SkipIfupProvisioning bool     `yaml:"skip-ifup-provisioning"`
}

Gadget represents the structure inside the snap.yaml for the gadget component of a gadget package type.

type Hardware

type Hardware struct {
	Assign     []HardwareAssign `yaml:"assign,omitempty"`
	BootAssets *BootAssets      `yaml:"boot-assets,omitempty"`
	Bootloader string           `yaml:"bootloader,omitempty"`
}

Hardware describes the hardware provided by the gadget snap

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 cannot 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
	// AllowGadget allows the installation of Gadget packages, this does not affect updates.
	AllowGadget
)

type Overlord

type Overlord struct {
}

Overlord is responsible for the overall system state.

func (*Overlord) Configure

func (o *Overlord) Configure(s *SnapPart, configuration []byte) ([]byte, error)

Configure configures the given snap

It returns an error on failure

func (*Overlord) Install

func (o *Overlord) Install(snapFilePath string, origin string, flags InstallFlags, meter progress.Meter) (sp *SnapPart, err error)

Install installs the given snap file to the system.

It returns the local snap file or an error

func (*Overlord) Installed

func (o *Overlord) Installed() ([]*SnapPart, error)

Installed returns the installed snaps from this repository

func (*Overlord) SetActive

func (o *Overlord) SetActive(s *SnapPart, active bool, meter progress.Meter) error

SetActive sets the active state of the given snap

It returns an error on failure

func (*Overlord) Uninstall

func (o *Overlord) Uninstall(s *SnapPart, meter progress.Meter) error

Uninstall removes the given local snap from the system.

It returns an error on failure

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

	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() snap.Type

	InstalledSize() int64
	DownloadSize() int64

	// get the list of frameworks needed by the part
	Frameworks() ([]string, error)
}

Part representation of a snappy part

func ActiveSnapByName

func ActiveSnapByName(needle string) Part

ActiveSnapByName returns all active snaps with the given name

func ActiveSnapsByType

func ActiveSnapsByType(snapTs ...snap.Type) (res []Part, err error)

ActiveSnapsByType returns all installed snaps with the given type

func FindSnapsByName

func FindSnapsByName(needle string, haystack []Part) (res []Part)

FindSnapsByName returns all snaps with the given name in the "haystack" slice of parts (useful for filtering)

func FindSnapsByNameAndVersion

func FindSnapsByNameAndVersion(needle, version string, haystack []Part) []Part

FindSnapsByNameAndVersion returns the parts with the name/version in the given slice of parts

func ListInstalled

func ListInstalled() ([]Part, error)

ListInstalled returns all installed snaps

func ListUpdates

func ListUpdates() ([]Part, error)

ListUpdates returns all snaps with updates

func Update

func Update(name string, flags InstallFlags, meter progress.Meter) ([]Part, error)

Update updates the selected name

func UpdateAll

func UpdateAll(flags InstallFlags, meter progress.Meter) ([]Part, error)

UpdateAll the installed snappy packages, it returns the updated Parts if updates where available and an error and nil if any of the updates fail to apply.

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) 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) Hash

func (s *RemoteSnapPart) Hash() string

Hash returns the hash

func (*RemoteSnapPart) Icon

func (s *RemoteSnapPart) Icon() string

Icon returns the icon

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) Name

func (s *RemoteSnapPart) Name() string

Name returns the name

func (*RemoteSnapPart) NeedsReboot

func (s *RemoteSnapPart) NeedsReboot() bool

NeedsReboot returns true if the snap becomes active on the next reboot

func (*RemoteSnapPart) Origin

func (s *RemoteSnapPart) Origin() string

Origin is the origin

func (*RemoteSnapPart) Type

func (s *RemoteSnapPart) Type() snap.Type

Type returns the type of the SnapPart (app, gadget, ...)

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 SecurityDefinitions

type SecurityDefinitions struct {
	// SecurityTemplate is a template name 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 {
	ReadPaths    []string `yaml:"read-paths,omitempty" json:"read-paths,omitempty"`
	WritePaths   []string `yaml:"write-paths,omitempty" json:"write-paths,omitempty"`
	Abstractions []string `yaml:"abstractions,omitempty" json:"abstractions,omitempty"`
	Syscalls     []string `yaml:"syscalls,omitempty" json:"syscalls,omitempty"`

	// deprecated keys, we warn when we see those
	DeprecatedAppArmor interface{} `yaml:"apparmor,omitempty" json:"apparmor,omitempty"`
	DeprecatedSeccomp  interface{} `yaml:"seccomp,omitempty" json:"seccomp,omitempty"`
}

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

func FindServices(snapName string, serviceName string, pb progress.Meter) (ServiceActor, error)

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 SharedName

type SharedName struct {
	Alias Part
	Parts []Part
}

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(args []string) (SharedNames, error)

Search searches all repositories with the given keywords in the args slice

type SnapDataDir

type SnapDataDir struct {
	Base    string
	Name    string
	Origin  string
	Version string
}

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 SnapFile

type SnapFile struct {
	// contains filtered or unexported fields
}

SnapFile is a local snap file that can get installed

func NewSnapFile

func NewSnapFile(snapFile string, origin string, unsignedOk bool) (*SnapFile, error)

NewSnapFile loads a snap from the given snapFile

func (*SnapFile) Channel

func (s *SnapFile) Channel() string

Channel returns the channel used

func (*SnapFile) Config

func (s *SnapFile) Config(configuration []byte) (new string, err error)

Config is used to to configure the snap

func (*SnapFile) Date

func (s *SnapFile) Date() time.Time

Date returns the last update date

func (*SnapFile) Description

func (s *SnapFile) Description() string

Description returns the description of the snap

func (*SnapFile) DownloadSize

func (s *SnapFile) DownloadSize() int64

DownloadSize returns the download size

func (*SnapFile) Frameworks

func (s *SnapFile) Frameworks() ([]string, error)

Frameworks returns the list of frameworks needed by the snap

func (*SnapFile) Hash

func (s *SnapFile) Hash() string

Hash returns the hash

func (*SnapFile) Icon

func (s *SnapFile) Icon() string

Icon returns the icon

func (*SnapFile) Install

func (s *SnapFile) Install(inter progress.Meter, flags InstallFlags) (name string, err error)

Install installs the snap

func (*SnapFile) InstalledSize

func (s *SnapFile) InstalledSize() int64

InstalledSize returns the installed size

func (*SnapFile) IsActive

func (s *SnapFile) IsActive() bool

IsActive returns whether it is active.

func (*SnapFile) IsInstalled

func (s *SnapFile) IsInstalled() bool

IsInstalled returns if its installed

func (*SnapFile) Name

func (s *SnapFile) Name() string

Name returns the name

func (*SnapFile) NeedsReboot

func (s *SnapFile) NeedsReboot() bool

NeedsReboot tells if the snap needs rebooting

func (*SnapFile) Origin

func (s *SnapFile) Origin() string

Origin returns the origin

func (*SnapFile) Type

func (s *SnapFile) Type() snap.Type

Type returns the type of the SnapPart (app, gadget, ...)

func (*SnapFile) Version

func (s *SnapFile) Version() string

Version returns the version

type SnapLocalRepository

type SnapLocalRepository struct {
	// contains filtered or unexported fields
}

SnapLocalRepository is the type for a local snap repository

func NewLocalSnapRepository

func NewLocalSnapRepository() *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) Installed

func (s *SnapLocalRepository) Installed() (parts []Part, err error)

Installed returns the installed snaps from this repository

type SnapPart

type SnapPart struct {
	// contains filtered or unexported fields
}

SnapPart represents a generic snap type

func NewInstalledSnapPart

func NewInstalledSnapPart(yamlPath, origin string) (*SnapPart, error)

NewInstalledSnapPart returns a new SnapPart from the given yamlPath

func (*SnapPart) Apps

func (s *SnapPart) Apps() map[string]*AppYaml

Apps return a list of AppsYamls the package declares

func (*SnapPart) CanInstall

func (s *SnapPart) CanInstall(allowGadget bool, inter interacter) error

CanInstall checks whether the SnapPart passes a series of tests required for installation

func (*SnapPart) Channel

func (s *SnapPart) Channel() string

Channel returns the channel used

func (*SnapPart) Date

func (s *SnapPart) Date() time.Time

Date returns the last update date

func (*SnapPart) DependentNames

func (s *SnapPart) DependentNames() ([]string, error)

DependentNames returns a list of the names of apps installed that depend on this one

/!\ not part of the Part interface.

func (*SnapPart) Dependents

func (s *SnapPart) Dependents() ([]*SnapPart, error)

Dependents gives the list of apps installed that depend on this one

/!\ not part of the Part interface.

func (*SnapPart) Description

func (s *SnapPart) Description() string

Description returns the summary description

func (*SnapPart) DownloadSize

func (s *SnapPart) DownloadSize() int64

DownloadSize returns the dowload size

func (*SnapPart) Frameworks

func (s *SnapPart) Frameworks() ([]string, error)

Frameworks returns the list of frameworks needed by the snap

func (*SnapPart) GadgetConfig

func (s *SnapPart) GadgetConfig() SystemConfig

GadgetConfig return a list of packages to configure

func (*SnapPart) Hash

func (s *SnapPart) Hash() string

Hash returns the hash

func (*SnapPart) Icon

func (s *SnapPart) Icon() string

Icon returns the path to the icon

func (*SnapPart) Install

func (s *SnapPart) Install(inter progress.Meter, flags InstallFlags) (name string, err error)

Install installs the snap (which does not make sense for an already installed snap

func (*SnapPart) InstalledSize

func (s *SnapPart) InstalledSize() int64

InstalledSize returns the size of the installed snap

func (*SnapPart) IsActive

func (s *SnapPart) IsActive() bool

IsActive returns true if the snap is active

func (*SnapPart) IsInstalled

func (s *SnapPart) IsInstalled() bool

IsInstalled returns true if the snap is installed

func (*SnapPart) Name

func (s *SnapPart) Name() string

Name returns the name

func (*SnapPart) NeedsReboot

func (s *SnapPart) NeedsReboot() bool

NeedsReboot returns true if the snap becomes active on the next reboot

func (*SnapPart) Origin

func (s *SnapPart) Origin() string

Origin returns the origin

func (*SnapPart) RefreshDependentsSecurity

func (s *SnapPart) RefreshDependentsSecurity(oldPart *SnapPart, inter interacter) (err error)

RefreshDependentsSecurity refreshes the security policies of dependent snaps

func (*SnapPart) RequestSecurityPolicyUpdate

func (s *SnapPart) RequestSecurityPolicyUpdate(policies, templates map[string]bool) error

RequestSecurityPolicyUpdate checks whether changes to the given policies and templates impacts the snap, and updates the policy if needed

func (*SnapPart) Type

func (s *SnapPart) Type() snap.Type

Type returns the type of the SnapPart (app, gadget, ...)

func (*SnapPart) Version

func (s *SnapPart) Version() string

Version returns the version

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) 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) Download

func (s *SnapUbuntuStoreRepository) Download(remoteSnap *RemoteSnapPart, pbar progress.Meter) (path string, err error)

Download downloads the given snap and returns its filename. The file is saved in temporary storage, and should be removed after use to prevent the disk from running out of space.

func (*SnapUbuntuStoreRepository) Find

func (s *SnapUbuntuStoreRepository) Find(searchTerm string) ([]Part, error)

Find (installable) parts from the store, matching the given search term.

XXX: this is actually Search, but that name is taken until we clean up aliases

func (*SnapUbuntuStoreRepository) Search

func (s *SnapUbuntuStoreRepository) Search(searchTerm string) (SharedNames, error)

Search searches the repository for the given searchTerm

func (*SnapUbuntuStoreRepository) Snap

func (s *SnapUbuntuStoreRepository) Snap(snapName string) (*RemoteSnapPart, error)

Snap returns the RemoteSnapPart for the given name or an error.

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 a Gadget snap

type Store

type Store struct {
	ID string `yaml:"id,omitempty"`
}

Store holds information relevant to the store provided by a Gadget 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

Jump to

Keyboard shortcuts

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