names

package module
v0.0.0-...-eb8acd5 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2015 License: LGPL-3.0 Imports: 4 Imported by: 0

README

juju/names

This package provides helpers for handling Juju entity names.

Documentation

Index

Examples

Constants

View Source
const (
	ContainerTypeSnippet = "[a-z]+"
	ContainerSnippet     = "/" + ContainerTypeSnippet + "/" + NumberSnippet + ""
	MachineSnippet       = NumberSnippet + "(?:" + ContainerSnippet + ")*"
)
View Source
const (
	ServiceSnippet = "(?:[a-z][a-z0-9]*(?:-[a-z0-9]*[a-z][a-z0-9]*)*)"
	NumberSnippet  = "(?:0|[1-9][0-9]*)"
)
View Source
const (
	UserTagKind   = "user"
	LocalProvider = "local"
)
View Source
const ActionTagKind = "action"
View Source
const CharmTagKind = "charm"

CharmTagKind specifies charm tag kind

View Source
const DiskTagKind = "disk"
View Source
const EnvironTagKind = "environment"
View Source
const MachineTagKind = "machine"
View Source
const (
	NetworkSnippet = "(?:[a-z0-9]+(?:-[a-z0-9]+)*)"
)
View Source
const NetworkTagKind = "network"
View Source
const RelationSnippet = "[a-z][a-z0-9]*(?:[_-][a-z0-9]+)*"
View Source
const RelationTagKind = "relation"
View Source
const ServiceTagKind = "service"
View Source
const UnitTagKind = "unit"

Variables

View Source
var (
	// SeriesSnippet is a regular expression representing series
	SeriesSnippet = "[a-z]+([a-z0-9]+)?"

	// CharmNameSnippet is a regular expression representing charm name
	CharmNameSnippet = "[a-z][a-z0-9]*(-[a-z0-9]*[a-z][a-z0-9]*)*"
)

Functions

func IsContainerMachine

func IsContainerMachine(id string) bool

IsContainerMachine returns whether id is a valid container machine id.

func IsValidAction

func IsValidAction(id string) bool

IsValidAction returns whether id is a valid action id (UUID).

func IsValidCharm

func IsValidCharm(url string) bool

IsValidCharm returns whether name is a valid charm url.

func IsValidDisk

func IsValidDisk(name string) bool

IsValidDisk returns whether name is a valid disk name.

func IsValidEnvironment

func IsValidEnvironment(id string) bool

IsValidEnvironment returns whether id is a valid environment UUID.

func IsValidMachine

func IsValidMachine(id string) bool

IsValidMachine returns whether id is a valid machine id.

func IsValidNetwork

func IsValidNetwork(name string) bool

IsValidNetwork reports whether name is a valid network name.

func IsValidRelation

func IsValidRelation(key string) bool

IsValidRelation returns whether key is a valid relation key.

func IsValidService

func IsValidService(name string) bool

IsValidService returns whether name is a valid service name.

func IsValidUnit

func IsValidUnit(name string) bool

IsValidUnit returns whether name is a valid unit name.

func IsValidUser

func IsValidUser(name string) bool

IsValidUser returns whether id is a valid user id.

func IsValidUserName

func IsValidUserName(name string) bool

IsValidUserName returns whether the user's name is a valid.

func TagKind

func TagKind(tag string) (string, error)

TagKind returns one of the *TagKind constants for the given tag, or an error if none matches.

func UnitService

func UnitService(unitName string) (string, error)

UnitService returns the name of the service that the unit is associated with. It returns an error if unitName is not a valid unit name.

Types

type ActionTag

type ActionTag struct {
	// Tags that are serialized need to have fields exported.
	ID utils.UUID
}

func NewActionTag

func NewActionTag(id string) ActionTag

NewActionTag returns the tag of an action with the given id (UUID).

func ParseActionTag

func ParseActionTag(actionTag string) (ActionTag, error)

ParseActionTag parses an action tag string.

func (ActionTag) Id

func (t ActionTag) Id() string

func (ActionTag) Kind

func (t ActionTag) Kind() string

func (ActionTag) String

func (t ActionTag) String() string

type CharmTag

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

CharmTag represents tag for charm using charm's URL

func NewCharmTag

func NewCharmTag(charmURL string) CharmTag

NewCharmTag returns the tag for the charm with the given url. It will panic if the given charm url is not valid.

func ParseCharmTag

func ParseCharmTag(charmTag string) (CharmTag, error)

ParseCharmTag parses a charm tag string.

func (CharmTag) Id

func (t CharmTag) Id() string

Id satisfies Tag interface. Returns charm URL.

func (CharmTag) Kind

func (t CharmTag) Kind() string

Kind satisfies Tag interface. Returns Charm tag kind.

func (CharmTag) String

func (t CharmTag) String() string

String satisfies Tag interface. Produces string representation of charm tag.

type DiskTag

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

func NewDiskTag

func NewDiskTag(diskName string) DiskTag

NewDiskTag returns the tag for the disk with the given name. It will panic if the given disk name is not valid.

func ParseDiskTag

func ParseDiskTag(diskTag string) (DiskTag, error)

ParseDiskTag parses a disk tag string.

func (DiskTag) Id

func (t DiskTag) Id() string

func (DiskTag) Kind

func (t DiskTag) Kind() string

func (DiskTag) String

func (t DiskTag) String() string

type EnvironTag

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

func NewEnvironTag

func NewEnvironTag(uuid string) EnvironTag

NewEnvironTag returns the tag of an environment with the given environment UUID.

func ParseEnvironTag

func ParseEnvironTag(environTag string) (EnvironTag, error)

ParseEnvironTag parses an environ tag string.

func (EnvironTag) Id

func (t EnvironTag) Id() string

func (EnvironTag) Kind

func (t EnvironTag) Kind() string

func (EnvironTag) String

func (t EnvironTag) String() string

type MachineTag

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

func NewMachineTag

func NewMachineTag(id string) MachineTag

NewMachineTag returns the tag for the machine with the given id.

func ParseMachineTag

func ParseMachineTag(machineTag string) (MachineTag, error)

ParseMachineTag parses a machine tag string.

func (MachineTag) Id

func (t MachineTag) Id() string

func (MachineTag) Kind

func (t MachineTag) Kind() string

func (MachineTag) String

func (t MachineTag) String() string

type NetworkTag

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

func NewNetworkTag

func NewNetworkTag(name string) NetworkTag

NewNetworkTag returns the tag of a network with the given name.

func ParseNetworkTag

func ParseNetworkTag(networkTag string) (NetworkTag, error)

ParseNetworkTag parses a network tag string.

func (NetworkTag) Id

func (t NetworkTag) Id() string

func (NetworkTag) Kind

func (t NetworkTag) Kind() string

func (NetworkTag) String

func (t NetworkTag) String() string

type RelationTag

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

func NewRelationTag

func NewRelationTag(relationKey string) RelationTag

NewRelationTag returns the tag for the relation with the given key.

func ParseRelationTag

func ParseRelationTag(relationTag string) (RelationTag, error)

ParseRelationTag parses a relation tag string.

func (RelationTag) Id

func (t RelationTag) Id() string

func (RelationTag) Kind

func (t RelationTag) Kind() string

func (RelationTag) String

func (t RelationTag) String() string

type ServiceTag

type ServiceTag struct {
	Name string
}

func NewServiceTag

func NewServiceTag(serviceName string) ServiceTag

NewServiceTag returns the tag for the service with the given name.

func ParseServiceTag

func ParseServiceTag(serviceTag string) (ServiceTag, error)

ParseServiceTag parses a service tag string.

func (ServiceTag) Id

func (t ServiceTag) Id() string

func (ServiceTag) Kind

func (t ServiceTag) Kind() string

func (ServiceTag) String

func (t ServiceTag) String() string

type Tag

type Tag interface {
	// Kind returns the kind of the tag.
	// This method is for legacy compatibility, callers should
	// use equality or type assertions to verify the Kind, or type
	// of a Tag.
	Kind() string

	// Id returns an identifier for this Tag.
	// The contents and format of the identifier are specific
	// to the implementer of the Tag.
	Id() string

	fmt.Stringer // all Tags should be able to print themselves
}

A Tag tags things that are taggable.

func ActionReceiverTag

func ActionReceiverTag(name string) (Tag, error)

func ParseTag

func ParseTag(tag string) (Tag, error)

ParseTag parses a string representation into a Tag.

Example
tag, err := ParseTag("user-100")
if err != nil {
	panic(err)
}
switch tag := tag.(type) {
case UserTag:
	fmt.Printf("User tag, id: %s\n", tag.Id())
default:
	fmt.Printf("Unknown tag, type %T\n", tag)
}
Output:

type UnitTag

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

func NewUnitTag

func NewUnitTag(unitName string) UnitTag

NewUnitTag returns the tag for the unit with the given name. It will panic if the given unit name is not valid.

func ParseUnitTag

func ParseUnitTag(unitTag string) (UnitTag, error)

ParseUnitTag parses a unit tag string.

func (UnitTag) Id

func (t UnitTag) Id() string

func (UnitTag) Kind

func (t UnitTag) Kind() string

func (UnitTag) String

func (t UnitTag) String() string

type UserTag

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

UserTag represents a user that may be stored in the local database, or provided through some remote identity provider.

func NewLocalUserTag

func NewLocalUserTag(name string) UserTag

NewLocalUserTag returns the tag for a local user with the given name.

func NewUserTag

func NewUserTag(userName string) UserTag

NewUserTag returns the tag for the user with the given name.

func ParseUserTag

func ParseUserTag(tag string) (UserTag, error)

ParseUserTag parser a user tag string.

func (UserTag) Id

func (t UserTag) Id() string

func (UserTag) IsLocal

func (t UserTag) IsLocal() bool

IsLocal returns true if the tag represents a local user.

func (UserTag) Kind

func (t UserTag) Kind() string

func (UserTag) Name

func (t UserTag) Name() string

func (UserTag) Provider

func (t UserTag) Provider() string

Provider returns the name of the user provider. Users in the local database are from the LocalProvider. Other users are considered 'remote' users.

func (UserTag) String

func (t UserTag) String() string

func (UserTag) Username

func (t UserTag) Username() string

Jump to

Keyboard shortcuts

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