resources

package
v0.34.0-rc1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SegmentSeparator is the separator between segments in a resource ID.
	SegmentSeparator = "/"

	// ProvidersSegment is the segment that separates the scope from the resource type.
	ProvidersSegment = "providers"

	// PlanesSegment is the segment the planes delimiter that distinguishes between UCP and ARM resource IDs.
	PlanesSegment = "planes"

	ResourceGroupType = "System.Resources/resourceGroups"
)

Variables

This section is empty.

Functions

func ExtractPlanesPrefixFromURLPath

func ExtractPlanesPrefixFromURLPath(path string) (planeType string, planeName string, remainder string, err error)

ExtractPlanesPrefixFromURLPath splits a URL path into segments and checks if the first two segments are valid, returning

the first two segments and the remainder of the URL path if valid, or an error if not.

func IDEquals

func IDEquals(x ID, y ID) bool

IDEquals compares two IDs for equality.

func MakeRelativeID

func MakeRelativeID(scopes []ScopeSegment, resourceTypes []TypeSegment, extensionTypes []TypeSegment) string

MakeRelativeID makes a plane-relative resource ID (ARM style) from a slice of ScopeSegment and a variadic of TypeSegment..

func MakeUCPID

func MakeUCPID(scopes []ScopeSegment, resourceTypes []TypeSegment, extensionTypes []TypeSegment) string

MakeUCPID creates a fully-qualified UCP resource ID, from the given scopes and resource types.

Types

type ID

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

ID represents an ARM or UCP resource id. ID is immutable once created. Use Parse() or ParseXyz() to create IDs and use String() to convert back to strings.

func MustParse

func MustParse(id string) ID

MustParse parses a resource ID. MustParse will panic if the ID is not valid. This should only be used in tests and other circumstances where the ID is known to be valid.

func Parse

func Parse(id string) (ID, error)

Parse parses a resource ID. Parse will parse ALL valid resource IDs in the most permissive way. Most code should use a more specific function like ParseResource to parse the specific kind of ID they want to handle.

func ParseByMethod

func ParseByMethod(id string, method string) (ID, error)

ParseByMethod is a helper function to extract the custom actions from the id. If there is a custom action in the request, then the method will be POST. To be able to get the proper type, we need to remove the custom action from the id.

func ParseResource

func ParseResource(id string) (ID, error)

ParseResource returns a parsed resource ID if the ID represents a named resource (not a collection or custom action).

Example:

/planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app

func ParseScope

func ParseScope(id string) (ID, error)

ParseScope returns a parsed resource ID if the ID represents a named scope (not a collection or custom action).

Example:

/planes/radius/local/resourceGroups/rg1

func (ID) Append

func (ri ID) Append(resourceType TypeSegment) ID

Append appends a resource type segment to the ID and returns the resulting ID. If the ID is UCP qualified, it will return a UCP qualified ID, otherwise it will return a relative ID.

func (ID) ExtensionSegments

func (ri ID) ExtensionSegments() []TypeSegment

ExtensionSegments gets the slice of extension segments.

func (ID) FindScope

func (ri ID) FindScope(scopeType string) string

Method FindScope searches through the scopeSegments of the ID instance and returns the Name of the scopeType if found.

func (ID) IsEmpty

func (ri ID) IsEmpty() bool

IsEmpty checks if the ID is empty.

func (ID) IsExtensionCollection

func (ri ID) IsExtensionCollection() bool

IsExtensionCollection returns true if the ID represents a collection or custom action on an extension resource.

Example:

/planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app/providers/Some.Other/type

func (ID) IsExtensionResource

func (ri ID) IsExtensionResource() bool

IsExtensionResource returns true if the ID represents an extension resource.

Example:

/planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app/providers/Some.Other/type/my-extension

func (ID) IsResource

func (ri ID) IsResource() bool

IsResource returns true if the ID represents a named resource (not a collection or custom action).

Example:

/planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app
/planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app/providers/Some.Other/type/my-extension

func (ID) IsResourceCollection

func (ri ID) IsResourceCollection() bool

IsResourceCollection returns true if the ID represents a collection or custom action on a resource.

Example:

/planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications
/planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app/providers/Some.Other/type

func (ID) IsScope

func (ri ID) IsScope() bool

IsScope returns true if the ID represents a named scope (not a collection or custom action).

Example:

/planes/radius/local

func (ID) IsScopeCollection

func (ri ID) IsScopeCollection() bool

IsScopeCollection returns true if the ID represents a collection or custom action on a scope.

Example:

/planes/radius/local/resourceGroups/resources

func (ID) IsUCPQualified added in v0.28.0

func (ri ID) IsUCPQualified() bool

IsUCPQualified checks if the ID has a prefix of SegmentSeparator and PlanesSegment.

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON marshalling support for Resource IDs.

func (ID) MarshalText

func (id ID) MarshalText() ([]byte, error)

MarshalText implements text marshalling support for Resource IDs.

func (ID) Name

func (ri ID) Name() string

Name gets the resource or scope name.

func (ID) ParentResource

func (ri ID) ParentResource() string

ParentResource returns the parent resource of the resource ID, or an empty string if the ID is a scope or non-extension resource.

Example:

/planes/radius/local/resourceGroups/cool-group/providers/Applications.Core/application/my-app/providers/Applications.Core/someExtensionType/my-extension
=> /planes/radius/local/resourceGroups/cool-group/providers/Applications.Core/application/my-app

func (ID) PlaneNamespace

func (ri ID) PlaneNamespace() string

PlaneNamespace returns the plane part of the UCP ID, or an empty string if the ID is not UCP qualified.

Examples:

radius/local

func (ID) PlaneScope

func (ri ID) PlaneScope() string

PlaneScope returns plane or subscription scope without resourceGroup

Examples:

/subscriptions/{guid}
/planes/radius/local

func (ID) ProviderNamespace

func (ri ID) ProviderNamespace() string

ProviderNamespace returns the namespace of the resource provider. Will be empty if the resource ID is empty or refers to a scope.

Examples:

Applications.Core

func (ID) QualifiedName

func (ri ID) QualifiedName() string

QualifiedName gets the fully-qualified resource name (eg. `radiusv3/myapp/mycontainer`) by joining the type segments with the SegmentSeparator.

func (ID) RootScope

func (ri ID) RootScope() string

RootScope returns the root-scope (the part before the first 'providers'), taking into account whether the ID is qualified for UCP or not.

For an exension resource the root scope is the same as its parent resource's root scope.

Examples:

/subscriptions/{guid}/resourceGroups/cool-group
/planes/radius/local/resourceGroups/cool-group

func (ID) RoutingScope

func (ri ID) RoutingScope() string

RoutingScope returns the routing-scope (the part after 'providers') - it is composed of the type and name segments of the ID instance.

Examples:

Applications.Core/applications/my-app

func (ID) ScopeSegments

func (ri ID) ScopeSegments() []ScopeSegment

ScopeSegments gets the slice of root-scope segments.

func (ID) String

func (ri ID) String() string

This function returns the "id" field of the given ID instance.

func (ID) Truncate

func (ri ID) Truncate() ID

Truncate removes the last type/name pair for a resource id or scope id. Calling truncate on a top level resource or scope has no effect.

func (ID) Type

func (ri ID) Type() string

Type returns the fully-qualified resource type of a ResourceID, or an empty string if the type cannot be determined.

func (ID) TypeSegments

func (ri ID) TypeSegments() []TypeSegment

TypeSegments gets the slice of type segments.

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements JSON unmarshalling support for Resource IDs.

func (*ID) UnmarshalText

func (id *ID) UnmarshalText(data []byte) error

UnmarshalText implements text unmarshalling support for Resource IDs.

func (ID) ValidateResourceType

func (ri ID) ValidateResourceType(t KnownType) error

ValidateResourceType validates that the resource ID type segment matches the expected type.

type KnownType

type KnownType struct {
	// Types is the set of TypeSegments that make up the type.
	Types []TypeSegment
}

KnownType represents a known resource type. Since resource types can have child types, this includes multiple segments.

type ScopeSegment

type ScopeSegment struct {
	// Type is the type of the scope.
	//
	// Example:
	//	resourceGroup
	//	subscription
	//
	Type string

	// Name is the name of the scope.
	Name string
}

ScopeSegment represents one of the root-scope pairs of a resource ID.

type TypeSegment

type TypeSegment struct {
	// Type one of the segments of a resource type. This will be a namespace/type combo for the first
	// segment, and a simple name for subsequent ones.
	//
	// Example:
	//	Microsoft.Resources/deployment
	//  database
	//
	Type string

	// Name is the name of the resource.
	Name string
}

TypeSegment represents one of the type/name pairs of a resource ID.

Directories

Path Synopsis
package aws defines utility functions and constants for working with AWS types and UCP resource IDs.
package aws defines utility functions and constants for working with AWS types and UCP resource IDs.
package azure defines utility functions and constants for working with Azure types and UCP resource IDs.
package azure defines utility functions and constants for working with Azure types and UCP resource IDs.
package kubernetes defines utility functions and constants for working with Kubernetes types and UCP resource IDs.
package kubernetes defines utility functions and constants for working with Kubernetes types and UCP resource IDs.
package radius defines utility functions and constants for working with Radius types and UCP resource IDs.
package radius defines utility functions and constants for working with Radius types and UCP resource IDs.

Jump to

Keyboard shortcuts

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