names.v2: gopkg.in/juju/names.v2 Index | Examples | Files

package names

import "gopkg.in/juju/names.v2"

Index

Examples

Package Files

action.go application.go applicationoffer.go caasmodel.go charm.go cloud.go cloudcredential.go controller.go controlleragent.go environ.go filesystem.go ipaddress.go machine.go model.go payload.go relation.go set.go space.go storage.go subnet.go tag.go unit.go user.go volume.go

Constants

const (
    ApplicationSnippet = "(?:[a-z][a-z0-9]*(?:-[a-z0-9]*[a-z][a-z0-9]*)*)"
    NumberSnippet      = "(?:0|[1-9][0-9]*)"
)
const (
    ContainerTypeSnippet = "[a-z]+"
    ContainerSnippet     = "/" + ContainerTypeSnippet + "/" + NumberSnippet + ""
    MachineSnippet       = NumberSnippet + "(?:" + ContainerSnippet + ")*"
)
const (
    SpaceTagKind = "space"
    SpaceSnippet = "(?:[a-z0-9]+(?:-[a-z0-9]+)*)"
)
const (
    StorageTagKind = "storage"

    // StorageNameSnippet is the regular expression that describes valid
    // storage names (without the storage instance sequence number).
    StorageNameSnippet = "(?:[a-z][a-z0-9]*(?:-[a-z0-9]*[a-z][a-z0-9]*)*)"
)
const (
    UserTagKind     = "user"
    LocalUserDomain = "local"
)
const ActionTagKind = "action"
const (
    ApplicationOfferSnippet = "(?:[a-z][a-z0-9]*(?:-[a-z0-9]*[a-z][a-z0-9]*)*)"
)
const ApplicationOfferTagKind = "applicationoffer"
const ApplicationTagKind = "application"
const CAASModelTagKind = "caasmodel"
const CharmTagKind = "charm"

CharmTagKind specifies charm tag kind

const CloudCredentialTagKind = "cloudcred"
const CloudTagKind = "cloud"
const ControllerAgentTagKind = "controller"

ControllerAgentTagKind indicates that a tag belongs to a controller agent.

const ControllerTagKind = "controller"

ControllerTagKind indicates that a tag belongs to a controller.

const EnvironTagKind = "environment"

EnvironTagKind is DEPRECATED: model tags are used instead.

const FilesystemTagKind = "filesystem"
const IPAddressTagKind = "ipaddress"
const MachineTagKind = "machine"
const ModelTagKind = "model"
const (
    // PayloadTagKind is used as the prefix for the string
    // representation of payload tags.
    PayloadTagKind = "payload"
)
const RelationSnippet = "[a-z][a-z0-9]*(?:[_-][a-z0-9]+)*"
const RelationTagKind = "relation"
const SubnetTagKind = "subnet"
const UnitSnippet = "(" + ApplicationSnippet + ")/" + NumberSnippet

UnitSnippet defines the regexp for a valid Unit Id.

const UnitTagKind = "unit"
const VolumeTagKind = "volume"

Variables

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]*)*"
)

func IsContainerMachine Uses

func IsContainerMachine(id string) bool

IsContainerMachine returns whether id is a valid container machine id.

func IsValidAction Uses

func IsValidAction(id string) bool

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

func IsValidApplication Uses

func IsValidApplication(name string) bool

IsValidApplication returns whether name is a valid application name.

func IsValidApplicationOffer Uses

func IsValidApplicationOffer(name string) bool

IsValidApplicationOffer returns whether name is a valid application offer name.

func IsValidCAASModel Uses

func IsValidCAASModel(id string) bool

IsValidCAASModel returns whether id is a valid CAAS model UUID.

func IsValidCAASModelName Uses

func IsValidCAASModelName(name string) bool

IsValidCAASModelName returns whether name is a valid string safe for a CAAS model name.

func IsValidCharm Uses

func IsValidCharm(url string) bool

IsValidCharm returns whether name is a valid charm url.

func IsValidCloud Uses

func IsValidCloud(id string) bool

IsValidCloud returns whether id is a valid cloud ID.

func IsValidCloudCredential Uses

func IsValidCloudCredential(id string) bool

IsValidCloudCredential returns whether id is a valid cloud credential ID.

func IsValidCloudCredentialName Uses

func IsValidCloudCredentialName(name string) bool

IsValidCloudCredentialName returns whether name is a valid cloud credential name.

func IsValidController Uses

func IsValidController(id string) bool

IsValidController returns whether id is a valid controller UUID.

func IsValidControllerAgent Uses

func IsValidControllerAgent(id string) bool

IsValidControllerAgent returns whether id is a valid controller agent id.

func IsValidControllerName Uses

func IsValidControllerName(name string) bool

IsValidControllerName returns whether name is a valid string safe for a controller name.

func IsValidEnvironment Uses

func IsValidEnvironment(id string) bool

IsValidEnvironment returns whether id is a valid environment UUID.

func IsValidFilesystem Uses

func IsValidFilesystem(id string) bool

IsValidFilesystem returns whether id is a valid filesystem id.

func IsValidIPAddress Uses

func IsValidIPAddress(id string) bool

IsValidIPAddress returns whether id is a valid IP address ID. Here it simply is checked if it is a valid UUID.

func IsValidMachine Uses

func IsValidMachine(id string) bool

IsValidMachine returns whether id is a valid machine id.

func IsValidModel Uses

func IsValidModel(id string) bool

IsValidModel returns whether id is a valid model UUID.

func IsValidModelName Uses

func IsValidModelName(name string) bool

IsValidModelName returns whether name is a valid string safe for a model name.

func IsValidPayload Uses

func IsValidPayload(id string) bool

IsValidPayload returns whether id is a valid Juju ID for a charm payload. The ID must be a valid alpha-numeric (plus hyphens).

func IsValidRelation Uses

func IsValidRelation(key string) bool

IsValidRelation returns whether key is a valid relation key.

func IsValidSpace Uses

func IsValidSpace(name string) bool

IsValidSpace reports whether name is a valid space name.

func IsValidStorage Uses

func IsValidStorage(id string) bool

IsValidStorage returns whether id is a valid storage instance ID.

func IsValidSubnet Uses

func IsValidSubnet(cidr string) bool

IsValidSubnet returns whether cidr is a valid subnet CIDR.

func IsValidUnit Uses

func IsValidUnit(name string) bool

IsValidUnit returns whether name is a valid unit name.

func IsValidUser Uses

func IsValidUser(id string) bool

IsValidUser returns whether id is a valid user id. Valid users may or may not be qualified with an @domain suffix. Examples of valid users include bob, bob@local, bob@somewhere-else, 0-a-f@123.

func IsValidUserDomain Uses

func IsValidUserDomain(domain string) bool

IsValidUserDomain returns whether the given user domain is valid.

func IsValidUserName Uses

func IsValidUserName(name string) bool

IsValidUserName returns whether the given name is a valid name part of a user. That is, usernames with a domain suffix will return false.

func IsValidVolume Uses

func IsValidVolume(id string) bool

IsValidVolume returns whether id is a valid volume ID.

func ReadableString Uses

func ReadableString(tag Tag) string

ReadableString returns a human-readable string from the tag passed in. It currently supports unit and machine tags. Support for additional types can be added in as needed.

func StorageName Uses

func StorageName(id string) (string, error)

StorageName returns the storage name from a storage instance ID. StorageName returns an error if "id" is not a valid storage instance ID.

func TagKind Uses

func TagKind(tag string) (string, error)

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

func UnitApplication Uses

func UnitApplication(unitName string) (string, error)

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

type ActionTag Uses

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

func NewActionTag Uses

func NewActionTag(id string) ActionTag

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

func ParseActionTag Uses

func ParseActionTag(actionTag string) (ActionTag, error)

ParseActionTag parses an action tag string.

func (ActionTag) Id Uses

func (t ActionTag) Id() string

func (ActionTag) Kind Uses

func (t ActionTag) Kind() string

func (ActionTag) String Uses

func (t ActionTag) String() string

type ApplicationOfferTag Uses

type ApplicationOfferTag struct {
    Name string
}

func NewApplicationOfferTag Uses

func NewApplicationOfferTag(applicationOfferName string) ApplicationOfferTag

NewApplicationOfferTag returns the tag for the application with the given name.

func ParseApplicationOfferTag Uses

func ParseApplicationOfferTag(applicationOfferTag string) (ApplicationOfferTag, error)

ParseApplicationOfferTag parses a application tag string.

func (ApplicationOfferTag) Id Uses

func (t ApplicationOfferTag) Id() string

func (ApplicationOfferTag) Kind Uses

func (t ApplicationOfferTag) Kind() string

func (ApplicationOfferTag) String Uses

func (t ApplicationOfferTag) String() string

type ApplicationTag Uses

type ApplicationTag struct {
    Name string
}

func NewApplicationTag Uses

func NewApplicationTag(applicationName string) ApplicationTag

NewApplicationTag returns the tag for the application with the given name.

func ParseApplicationTag Uses

func ParseApplicationTag(applicationTag string) (ApplicationTag, error)

ParseApplicationTag parses a application tag string.

func (ApplicationTag) Id Uses

func (t ApplicationTag) Id() string

func (ApplicationTag) Kind Uses

func (t ApplicationTag) Kind() string

func (ApplicationTag) String Uses

func (t ApplicationTag) String() string

type CAASModelTag Uses

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

CAASModelTag represents a tag used to describe a model.

func NewCAASModelTag Uses

func NewCAASModelTag(uuid string) CAASModelTag

NewCAASModelTag returns the tag of a CAAS model with the given CAAS model UUID.

func ParseCAASModelTag Uses

func ParseCAASModelTag(caasModelTag string) (CAASModelTag, error)

ParseCAASModelTag parses a CAAS model tag string.

func (CAASModelTag) Id Uses

func (t CAASModelTag) Id() string

func (CAASModelTag) Kind Uses

func (t CAASModelTag) Kind() string

func (CAASModelTag) String Uses

func (t CAASModelTag) String() string

type CharmTag Uses

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

CharmTag represents tag for charm using charm's URL

func NewCharmTag Uses

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 Uses

func ParseCharmTag(charmTag string) (CharmTag, error)

ParseCharmTag parses a charm tag string.

func (CharmTag) Id Uses

func (t CharmTag) Id() string

Id satisfies Tag interface. Returns charm URL.

func (CharmTag) Kind Uses

func (t CharmTag) Kind() string

Kind satisfies Tag interface. Returns Charm tag kind.

func (CharmTag) String Uses

func (t CharmTag) String() string

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

type CloudCredentialTag Uses

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

func NewCloudCredentialTag Uses

func NewCloudCredentialTag(id string) CloudCredentialTag

NewCloudCredentialTag returns the tag for the cloud with the given ID. It will panic if the given cloud ID is not valid.

func ParseCloudCredentialTag Uses

func ParseCloudCredentialTag(s string) (CloudCredentialTag, error)

ParseCloudCredentialTag parses a cloud tag string.

func (CloudCredentialTag) Cloud Uses

func (t CloudCredentialTag) Cloud() CloudTag

Cloud returns the tag of the cloud to which the credential pertains.

func (CloudCredentialTag) Id Uses

func (t CloudCredentialTag) Id() string

Id implements Tag.Id. It returns the empty string if t is zero.

func (CloudCredentialTag) IsZero Uses

func (t CloudCredentialTag) IsZero() bool

IsZero reports whether t is zero.

func (CloudCredentialTag) Kind Uses

func (t CloudCredentialTag) Kind() string

Kind is part of the Tag interface.

func (CloudCredentialTag) Name Uses

func (t CloudCredentialTag) Name() string

Name returns the cloud credential name, excluding the cloud and owner qualifiers.

func (CloudCredentialTag) Owner Uses

func (t CloudCredentialTag) Owner() UserTag

Owner returns the tag of the user that owns the credential.

func (CloudCredentialTag) String Uses

func (t CloudCredentialTag) String() string

String implements Tag.String. It returns the empty string if t is zero.

type CloudTag Uses

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

func NewCloudTag Uses

func NewCloudTag(id string) CloudTag

NewCloudTag returns the tag for the cloud with the given ID. It will panic if the given cloud ID is not valid.

func ParseCloudTag Uses

func ParseCloudTag(cloudTag string) (CloudTag, error)

ParseCloudTag parses a cloud tag string.

func (CloudTag) Id Uses

func (t CloudTag) Id() string

func (CloudTag) Kind Uses

func (t CloudTag) Kind() string

func (CloudTag) String Uses

func (t CloudTag) String() string

type ControllerAgentTag Uses

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

ControllerAgentTag represents a tag used to describe a controller.

func NewControllerAgentTag Uses

func NewControllerAgentTag(id string) ControllerAgentTag

NewControllerAgentTag returns the tag of an controller agent with the given id.

func ParseControllerAgentTag Uses

func ParseControllerAgentTag(controllerAgentTag string) (ControllerAgentTag, error)

ParseControllerAgentTag parses a controller agent tag string.

func (ControllerAgentTag) Id Uses

func (t ControllerAgentTag) Id() string

Id implements Tag.

func (ControllerAgentTag) Kind Uses

func (t ControllerAgentTag) Kind() string

Kind implements Tag.

func (ControllerAgentTag) Number Uses

func (t ControllerAgentTag) Number() int

Number returns the controller agent number.

func (ControllerAgentTag) String Uses

func (t ControllerAgentTag) String() string

String implements Tag.

type ControllerTag Uses

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

ControllerTag represents a tag used to describe a controller.

func NewControllerTag Uses

func NewControllerTag(uuid string) ControllerTag

NewControllerTag returns the tag of an controller with the given controller UUID.

func ParseControllerTag Uses

func ParseControllerTag(controllerTag string) (ControllerTag, error)

ParseControllerTag parses an environ tag string.

func (ControllerTag) Id Uses

func (t ControllerTag) Id() string

Id implements Tag.

func (ControllerTag) Kind Uses

func (t ControllerTag) Kind() string

Kind implements Tag.

func (ControllerTag) String Uses

func (t ControllerTag) String() string

String implements Tag.

type EnvironTag Uses

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

func NewEnvironTag Uses

func NewEnvironTag(uuid string) EnvironTag

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

func ParseEnvironTag Uses

func ParseEnvironTag(environTag string) (EnvironTag, error)

ParseEnvironTag parses an environ tag string.

func (EnvironTag) Id Uses

func (t EnvironTag) Id() string

func (EnvironTag) Kind Uses

func (t EnvironTag) Kind() string

func (EnvironTag) String Uses

func (t EnvironTag) String() string

type FilesystemTag Uses

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

func NewFilesystemTag Uses

func NewFilesystemTag(id string) FilesystemTag

NewFilesystemTag returns the tag for the filesystem with the given name. It will panic if the given filesystem name is not valid.

func ParseFilesystemTag Uses

func ParseFilesystemTag(filesystemTag string) (FilesystemTag, error)

ParseFilesystemTag parses a filesystem tag string.

func (FilesystemTag) Id Uses

func (t FilesystemTag) Id() string

func (FilesystemTag) Kind Uses

func (t FilesystemTag) Kind() string

func (FilesystemTag) String Uses

func (t FilesystemTag) String() string

type IPAddressTag Uses

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

func NewIPAddressTag Uses

func NewIPAddressTag(id string) IPAddressTag

NewIPAddressTag returns the tag for the IP address with the given ID (UUID).

func ParseIPAddressTag Uses

func ParseIPAddressTag(ipAddressTag string) (IPAddressTag, error)

ParseIPAddressTag parses an IP address tag string.

func (IPAddressTag) Id Uses

func (t IPAddressTag) Id() string

func (IPAddressTag) Kind Uses

func (t IPAddressTag) Kind() string

func (IPAddressTag) String Uses

func (t IPAddressTag) String() string

type MachineTag Uses

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

func FilesystemMachine Uses

func FilesystemMachine(tag FilesystemTag) (MachineTag, bool)

FilesystemMachine returns the machine component of the filesystem tag, and a boolean indicating whether or not there is a machine component.

func NewMachineTag Uses

func NewMachineTag(id string) MachineTag

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

func ParseMachineTag Uses

func ParseMachineTag(machineTag string) (MachineTag, error)

ParseMachineTag parses a machine tag string.

func VolumeMachine Uses

func VolumeMachine(tag VolumeTag) (MachineTag, bool)

VolumeMachine returns the machine component of the volume tag, and a boolean indicating whether or not there is a machine component.

func (MachineTag) ChildId Uses

func (t MachineTag) ChildId() string

ChildId returns just the last segment of the ID.

func (MachineTag) ContainerType Uses

func (t MachineTag) ContainerType() string

ContainerType returns the type of container for this machine. If the machine isn't a container, then the empty string is returned.

func (MachineTag) Id Uses

func (t MachineTag) Id() string

func (MachineTag) Kind Uses

func (t MachineTag) Kind() string

func (MachineTag) Parent Uses

func (t MachineTag) Parent() Tag

Parent returns the machineTag for the host of the container if the machineTag is a container, otherwise it returns nil.

func (MachineTag) String Uses

func (t MachineTag) String() string

type ModelTag Uses

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

ModelTag represents a tag used to describe a model.

func NewModelTag Uses

func NewModelTag(uuid string) ModelTag

NewModelTag returns the tag of an model with the given model UUID.

func ParseModelTag Uses

func ParseModelTag(modelTag string) (ModelTag, error)

ParseModelTag parses an environ tag string.

func (ModelTag) Id Uses

func (t ModelTag) Id() string

func (ModelTag) Kind Uses

func (t ModelTag) Kind() string

func (ModelTag) String Uses

func (t ModelTag) String() string

type PayloadTag Uses

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

PayloadTag represents a charm payload.

func NewPayloadTag Uses

func NewPayloadTag(id string) PayloadTag

NewPayloadTag returns the tag for a charm's payload with the given id.

func ParsePayloadTag Uses

func ParsePayloadTag(tag string) (PayloadTag, error)

ParsePayloadTag parses a payload tag string. So ParsePayloadTag(tag.String()) === tag.

func (PayloadTag) Id Uses

func (t PayloadTag) Id() string

Id implements Tag.Id. It always returns the same ID with which it was created. So NewPayloadTag(x).Id() == x for all valid x.

func (PayloadTag) Kind Uses

func (t PayloadTag) Kind() string

Kind implements Tag.

func (PayloadTag) String Uses

func (t PayloadTag) String() string

String implements Tag.

type RelationTag Uses

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

func NewRelationTag Uses

func NewRelationTag(relationKey string) RelationTag

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

func ParseRelationTag Uses

func ParseRelationTag(relationTag string) (RelationTag, error)

ParseRelationTag parses a relation tag string.

func (RelationTag) Id Uses

func (t RelationTag) Id() string

func (RelationTag) Kind Uses

func (t RelationTag) Kind() string

func (RelationTag) String Uses

func (t RelationTag) String() string

type Set Uses

type Set map[Tag]bool

Set represents the Set data structure, and contains Tags.

func NewSet Uses

func NewSet(initial ...Tag) Set

NewSet creates and initializes a Set and populates it with inital values as specified in the parameters.

func NewSetFromStrings Uses

func NewSetFromStrings(initial ...string) (Set, error)

NewSetFromStrings creates and initializes a Set and populates it by using names.ParseTag on the initial values specified in the parameters.

func (Set) Add Uses

func (t Set) Add(value Tag)

Add puts a value into the set.

func (Set) Contains Uses

func (t Set) Contains(value Tag) bool

Contains returns true if the value is in the set, and false otherwise.

func (Set) Difference Uses

func (t Set) Difference(other Set) Set

Difference returns a new Tags representing all the values in the target that are not in the parameter.

func (Set) Intersection Uses

func (t Set) Intersection(other Set) Set

Intersection returns a new Set representing a intersection of the elments in the method target and the parameter.

func (Set) IsEmpty Uses

func (t Set) IsEmpty() bool

IsEmpty is true for empty or uninitialized sets.

func (Set) Remove Uses

func (t Set) Remove(value Tag)

Remove takes a value out of the set. If value wasn't in the set to start with, this method silently succeeds.

func (Set) Size Uses

func (t Set) Size() int

Size returns the number of elements in the set.

func (Set) SortedValues Uses

func (t Set) SortedValues() []Tag

SortedValues returns an ordered slice containing all the values in the set.

func (Set) Union Uses

func (t Set) Union(other Set) Set

Union returns a new Set representing a union of the elments in the method target and the parameter.

func (Set) Values Uses

func (t Set) Values() []Tag

Values returns an unordered slice containing all the values in the set.

type SpaceTag Uses

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

func NewSpaceTag Uses

func NewSpaceTag(name string) SpaceTag

NewSpaceTag returns the tag of a space with the given name.

func ParseSpaceTag Uses

func ParseSpaceTag(spaceTag string) (SpaceTag, error)

ParseSpaceTag parses a space tag string.

func (SpaceTag) Id Uses

func (t SpaceTag) Id() string

func (SpaceTag) Kind Uses

func (t SpaceTag) Kind() string

func (SpaceTag) String Uses

func (t SpaceTag) String() string

type StorageTag Uses

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

func NewStorageTag Uses

func NewStorageTag(id string) StorageTag

NewStorageTag returns the tag for the storage instance with the given ID. It will panic if the given string is not a valid storage instance Id.

func ParseStorageTag Uses

func ParseStorageTag(s string) (StorageTag, error)

ParseStorageTag parses a storage tag string.

func (StorageTag) Id Uses

func (t StorageTag) Id() string

func (StorageTag) Kind Uses

func (t StorageTag) Kind() string

func (StorageTag) String Uses

func (t StorageTag) String() string

type SubnetTag Uses

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

func NewSubnetTag Uses

func NewSubnetTag(cidr string) SubnetTag

NewSubnetTag returns the tag for subnet with the given CIDR.

func ParseSubnetTag Uses

func ParseSubnetTag(subnetTag string) (SubnetTag, error)

ParseSubnetTag parses a subnet tag string.

func (SubnetTag) Id Uses

func (t SubnetTag) Id() string

func (SubnetTag) Kind Uses

func (t SubnetTag) Kind() string

func (SubnetTag) String Uses

func (t SubnetTag) String() string

type Tag Uses

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. Its purpose is to uniquely identify some resource and provide a consistent representation of that identity in both a human-readable and a machine-friendly format. The latter benefits use of the tag in over-the-wire transmission (e.g. in HTTP RPC calls) and in filename paths. The human-readable tag "name" is available through the Id method. The machine-friendly representation is provided by the String method.

The ParseTag function may be used to build a tag from the machine- formatted string. As well each kind of tag has its own Parse* method. Each kind also has a New* method (e.g. NewMachineTag) which produces a tag from the human-readable tag "ID".

In the context of juju, the API *must* use tags to represent the various juju entities. This contrasts with user-facing code, where tags *must not* be used. Internal to juju the use of tags is a judgement call based on the situation.

func ActionReceiverFromTag Uses

func ActionReceiverFromTag(tag string) (Tag, error)

ActionReceiverFrom Tag returns an ActionReceiver tag from a machine or unit tag.

func ActionReceiverTag Uses

func ActionReceiverTag(name string) (Tag, error)

ActionReceiverTag returns an ActionReceiver Tag from a machine or unit name.

func ParseTag Uses

func ParseTag(tag string) (Tag, error)

ParseTag parses a string representation into a Tag.

Code:

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

type UnitTag Uses

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

func FilesystemUnit Uses

func FilesystemUnit(tag FilesystemTag) (UnitTag, bool)

FilesystemUnit returns the unit component of the filesystem tag, and a boolean indicating whether or not there is a unit component.

func NewUnitTag Uses

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 Uses

func ParseUnitTag(unitTag string) (UnitTag, error)

ParseUnitTag parses a unit tag string.

func VolumeUnit Uses

func VolumeUnit(tag VolumeTag) (UnitTag, bool)

VolumeUnit returns the unit component of the volume tag, and a boolean indicating whether or not there is a unit component.

func (UnitTag) Id Uses

func (t UnitTag) Id() string

func (UnitTag) Kind Uses

func (t UnitTag) Kind() string

func (UnitTag) Number Uses

func (t UnitTag) Number() int

Number returns the unit number from the tag, effectively the NumberSnippet from the validUnit regular expression.

func (UnitTag) ShortenedString Uses

func (t UnitTag) ShortenedString(maxLength int) (string, error)

ShortenedString returns the length-limited string for the tag. It can be used in places where there are strict length requirements, e.g. for a service name. It uses a hash so the resulting name should be unique. It will panic if maxLength is less than minShortenedLength.

func (UnitTag) String Uses

func (t UnitTag) String() string

type UserTag Uses

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

UserTag represents a user that may be stored locally or associated with some external domain.

func NewLocalUserTag Uses

func NewLocalUserTag(name string) UserTag

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

func NewUserTag Uses

func NewUserTag(userName string) UserTag

NewUserTag returns the tag for the user with the given name. It panics if the user name does not satisfy IsValidUser.

func ParseUserTag Uses

func ParseUserTag(tag string) (UserTag, error)

ParseUserTag parses a user tag string.

func (UserTag) Domain Uses

func (t UserTag) Domain() string

Domain returns the user domain. Users in the local database are from the LocalDomain. Other users are considered 'remote' users.

func (UserTag) Id Uses

func (t UserTag) Id() string

Id implements Tag.Id. Local users will always have an Id value without any domain.

func (UserTag) IsLocal Uses

func (t UserTag) IsLocal() bool

IsLocal returns true if the tag represents a local user. Users without an explicit domain are considered local.

func (UserTag) Kind Uses

func (t UserTag) Kind() string

func (UserTag) Name Uses

func (t UserTag) Name() string

Name returns the name part of the user name without its associated domain.

func (UserTag) String Uses

func (t UserTag) String() string

func (UserTag) WithDomain Uses

func (t UserTag) WithDomain(domain string) UserTag

WithDomain returns a copy of the user tag with the domain changed to the given argument. The domain must satisfy IsValidUserDomain or this function will panic.

type VolumeTag Uses

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

func NewVolumeTag Uses

func NewVolumeTag(id string) VolumeTag

NewVolumeTag returns the tag for the volume with the given ID. It will panic if the given volume ID is not valid.

func ParseVolumeTag Uses

func ParseVolumeTag(volumeTag string) (VolumeTag, error)

ParseVolumeTag parses a volume tag string.

func (VolumeTag) Id Uses

func (t VolumeTag) Id() string

func (VolumeTag) Kind Uses

func (t VolumeTag) Kind() string

func (VolumeTag) String Uses

func (t VolumeTag) String() string

Package names imports 10 packages (graph) and is imported by 3684 packages. Updated 2019-08-15. Refresh now. Tools for package owners.