names

package module
v0.0.0-...-78d295c Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2014 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 (
	// ActionTagKind is used to identify the Tag type
	ActionTagKind = "action"

	// ActionResultTagKind is used to identify the Tag type
	ActionResultTagKind = "actionresult"
)
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 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

This section is empty.

Functions

func IsContainerMachine

func IsContainerMachine(id string) bool

IsContainerMachine returns whether id is a valid container machine id.

func IsValidAction

func IsValidAction(actionId string) bool

IsValidAction returns whether actionId is a valid actionId Valid action ids include the names.actionMarker token that delimits a prefix that can be used for filtering, and a suffix that should be unique. The prefix should match the name rules for units

func IsValidActionResult

func IsValidActionResult(resultId string) bool

IsValidActionResult returns whether resultId is a valid actionResultId Valid action result ids include the names.actionResultMarker token that delimits a prefix that can be used for filtering, and a suffix that should be unique. The prefix should match the name rules for units or services

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

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

Types

type ActionResultTag

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

ActionResultTag represents the actionresult of an action

func NewActionResultTag

func NewActionResultTag(id string) ActionResultTag

NewActionResultTag returns a tag for an actionresult using it's id

func ParseActionResultTag

func ParseActionResultTag(actionResultTag string) (ActionResultTag, error)

ParseActionResultTag parses a action result tag string.

func (ActionResultTag) Id

func (t ActionResultTag) Id() string

Id returns the id of the type this Tag represents

func (ActionResultTag) Kind

func (t ActionResultTag) Kind() string

Kind exposes the value to identify what kind of Tag this is

func (ActionResultTag) Prefix

func (t ActionResultTag) Prefix() string

Prefix returns the string representation of the prefix of the Tag

func (ActionResultTag) PrefixTag

func (t ActionResultTag) PrefixTag() Tag

PrefixTag returns a Tag representing the Entity matching the id prefix

func (ActionResultTag) Sequence

func (t ActionResultTag) Sequence() int

Sequence returns the unique integer suffix of the Tag

func (ActionResultTag) String

func (t ActionResultTag) String() string

String returns a string that shows the type and id of the Tag

type ActionTag

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

ActionTag is a Tag type for representing Action entities, which are records of queued actions for a given unit

func JoinActionTag

func JoinActionTag(prefix string, sequence int) ActionTag

JoinActionTag reconstitutes an ActionTag from it's prefix and sequence

func NewActionTag

func NewActionTag(id string) ActionTag

NewActionTag returns the tag for the action with the given id.

func ParseActionTag

func ParseActionTag(actionTag string) (ActionTag, error)

ParseActionTag parses a action tag string.

func (ActionTag) Id

func (t ActionTag) Id() string

Id returns the id of the type this Tag represents

func (ActionTag) Kind

func (t ActionTag) Kind() string

Kind exposes the value to identify what kind of Tag this is

func (ActionTag) Prefix

func (t ActionTag) Prefix() string

Prefix returns the string representation of the prefix of the Tag

func (ActionTag) PrefixTag

func (t ActionTag) PrefixTag() Tag

PrefixTag returns a Tag representing the Entity matching the id prefix

func (ActionTag) Sequence

func (t ActionTag) Sequence() int

Sequence returns the unique integer suffix of the Tag

func (ActionTag) String

func (t ActionTag) String() string

String returns a string that shows the type and id of the Tag

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 PrefixTag

type PrefixTag interface {
	Tag
	Prefix() string
	Sequence() int
	PrefixTag() Tag
}

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 {
	// contains filtered or unexported fields
}

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