urn

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package urn implements the Uniform Resource Name (URN) specification, as defined in RFC 2141 with a focus on cloud computing.

Index

Constants

View Source
const (
	// DefaultSeparator is the separator used to separate the segments of a URN.
	DefaultSeparator = ":"
	// DefaultNamespace is the default namespace used for URNs.
	DefaultNamespace = "urn"
)

Variables

View Source
var ErrorInvalid = errors.New("urn: invalid format")

ErrorInvalid is returned when parsing an URN with an invalid format.

Functions

This section is empty.

Types

type Match added in v0.5.1

type Match string

Match is a string that can be used to match a URN segment.

var (
	// Wildcard is the wildcard used to match any value.
	Wildcard Match = "*"
	// Empty is the empty string
	Empty Match
)

func (Match) String added in v0.5.1

func (m Match) String() string

String returns the string representation of the match.

type URN

type URN struct {
	// Namespace is the namespace segment of the URN.
	Namespace Match `validate:"required"`
	// Partition is the partition segment of the URN.
	Partition Match `validate:"max=256"`
	// Service is the service segment of the URN.
	Service Match `validate:"max=256"`
	// Region is the region segment of the URN.
	Region Match `validate:"max=256"`
	// Identifier is the identifier segment of the URN.
	Identifier Match `validate:"max=64"`
	// Resource is the resource segment of the URN.
	Resource Match `validate:"required,max=256"`
}

URN represents a unique, uniform identifier for a resource

func FromProto

func FromProto(r *pb.ResourceURN) (*URN, error)

FromProto returns the URN representation from a proto.ResourceURN representation.

func New

func New(namespace, partition, service, region, identifier, resource Match) (*URN, error)

New takes a namespace, partition, service, region, identifier and resource and returns a URN.

func Parse

func Parse(s string) (*URN, error)

Parse takes a string and parses it to a URN.

func (*URN) ExactMatch added in v0.5.1

func (u *URN) ExactMatch(urn *URN) bool

ExactMatch returns true if the URN matches the given URN exactly.

func (*URN) Match added in v0.5.1

func (u *URN) Match(urn *URN) bool

Match returns true if the right-hand side URN matches the left-hand side URN. The left-hand side URN is assumed to be specific and the right-hand side URN is assumed to be generic.

func (*URN) ProtoMessage

func (u *URN) ProtoMessage() *pb.ResourceURN

ProtoMessage returns the proto.ResourceURN representation of the URN.

func (*URN) String

func (u *URN) String() string

String returns the string representation of the URN.

Jump to

Keyboard shortcuts

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