Documentation ¶
Overview ¶
Package naming implements naming constraints and concepts for snaps and their elements.
Index ¶
- Variables
- func SameSnap(snapRef1, snapRef2 SnapRef) bool
- func UseStagingIDs(staging bool) (restore func())
- func ValidateAlias(alias string) error
- func ValidateApp(n string) error
- func ValidateHook(name string) error
- func ValidateInstance(instanceName string) error
- func ValidateInterface(name string) error
- func ValidatePlug(name string) error
- func ValidateSecurityTag(tag string) error
- func ValidateSlot(name string) error
- func ValidateSnap(name string) error
- func ValidateSnapID(id string) error
- func ValidateSocket(name string) error
- func WellKnownSnapID(snapName string) string
- type AppSecurityTag
- type HookSecurityTag
- type SecurityTag
- type Snap
- type SnapRef
- type SnapSet
Constants ¶
This section is empty.
Variables ¶
var ValidAlias = regexp.MustCompile("^[a-zA-Z0-9][-_.a-zA-Z0-9]*$")
ValidAlias is a regular expression describing a valid alias
var ValidApp = regexp.MustCompile("^[a-zA-Z0-9](?:-?[a-zA-Z0-9])*$")
ValidApp is a regular expression describing a valid application name
var ValidSnapID = regexp.MustCompile("^[a-z0-9A-Z]{32}$")
ValidSnapID is a regular expression describing a valid snapd-id
Functions ¶
func SameSnap ¶
SameSnap returns whether the two arguments refer to the same snap. If ids are not available for both it will fallback to names.
func UseStagingIDs ¶
func UseStagingIDs(staging bool) (restore func())
func ValidateAlias ¶
ValidateAlias checks if a string can be used as an alias name.
func ValidateApp ¶
ValidateApp tells whether a string is a valid application name.
func ValidateHook ¶
ValidateHook checks if a string can be used as a hook name.
func ValidateInstance ¶
ValidateInstance checks if a string can be used as a snap instance name.
func ValidateInterface ¶
ValidateInterface checks if a string can be used as an interface name.
func ValidatePlug ¶
ValidatePlug checks if a string can be used as a slot name.
Slot names and plug names within one snap must have unique names. This is not enforced by this function but is enforced by snap-level validation.
func ValidateSecurityTag ¶
ValidateSecurityTag validates known variants of snap security tag.
Two forms are recognised, one for apps and one for hooks. Other forms are possible but are not handled here.
TODO: handle the weird udev variant.
func ValidateSlot ¶
ValidateSlot checks if a string can be used as a slot name.
Slot names and plug names within one snap must have unique names. This is not enforced by this function but is enforced by snap-level validation.
func ValidateSnap ¶
ValidateSnap checks if a string can be used as a snap name.
func ValidateSnapID ¶
ValidateSnapID checks whether the string is a valid snap-id.
func ValidateSocket ¶
ValidateSockeName checks if a string ca be used as a name for a socket (for socket activation).
func WellKnownSnapID ¶
WellKnownSnapID returns the snap-id of well-known snaps (snapd, core*) given the snap name or the empty string otherwise.
Types ¶
type AppSecurityTag ¶
type AppSecurityTag interface { SecurityTag // AppName returns the name of the application. AppName() string }
AppSecurityTag exposes details of a validated snap application security tag.
func ParseAppSecurityTag ¶
func ParseAppSecurityTag(tag string) (AppSecurityTag, error)
ParseAppSecurityTag parses an app security tag.
type HookSecurityTag ¶
type HookSecurityTag interface { SecurityTag // HookName returns the name of the hook. HookName() string }
HookSecurityTag exposes details of a validated snap hook security tag.
func ParseHookSecurityTag ¶
func ParseHookSecurityTag(tag string) (HookSecurityTag, error)
ParseHookSecurityTag parses a hook security tag.
type SecurityTag ¶
type SecurityTag interface { // String returns the entire security tag. String() string // InstanceName returns the snap name and instance key. InstanceName() string }
SecurityTag exposes details of a validated snap security tag.
func ParseSecurityTag ¶
func ParseSecurityTag(tag string) (SecurityTag, error)
ParseSecurityTag parses a snap security tag and returns a parsed representation or an error.
Further type assertions can be used to described the particular form, either describing an application or a hook specific security tag.
type SnapRef ¶
A SnapRef references a snap by name and/or id.
func NewSnapRef ¶
NewSnapRef returns a reference to the snap with given name and id.
type SnapSet ¶
type SnapSet struct {
// contains filtered or unexported fields
}
SnapSet can hold a set of references to snaps.
func NewSnapSet ¶
NewSnapSet builds a snap set with the given references.
func (*SnapSet) Add ¶
Add adds one reference to the set. Already added ids or names will be ignored. The assumption is that a SnapSet is populated with distinct snaps.