naming

package
v2.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CaseInsensitive caseSensitivity = 0
	LowerCase       caseSensitivity = 1
	UpperCase       caseSensitivity = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NamingError

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

func NewNamingError

func NewNamingError(message string) *NamingError

func (*NamingError) Error

func (e *NamingError) Error() string

type Service

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

func New

func New(context string, region string, environment string, module string, color string) (*Service, error)

New creates a new naming convention service. Parameters 'context', 'region' and 'environment' are mandatory.

Context should be set to the application name. In case of a complex system with multiple modules / subsystems,
	'module' should be set as well (but it is not required).
Regions should be in form of Azure long regions string, e.g. westeurope or northeurope.
Environment provides you the possibility to isolate your resources per environment, e.g. prod, int, stage, dev, etc.
Color (optional) can be used for blue/green infrastructure deployments, useful in disaster recovery scenarios. For example, if
	you would ever need to recreate infrastructure itself and perform a disaster recovery, you would get naming clashes
	for globally-unique resources. When you set the color property from the beginning, for example to 'b' (as in blue), you
	could change it in the future for 'g' (as in green) to redeploy everything. Keep the color names very short due to limits
	in Azure for the resource name lengths.

Per default, normal naming convention pattern is used. If required, you can override the pattern using the SetPattern() method

func (*Service) GenerateResourceName

func (service *Service) GenerateResourceName(resourceType resources.AzureResourceType, name string) (string, error)

GenerateResourceName generates a full Azure resource name, based on the configured naming convention pattern. Name parameter should be used to uniquely isolate the resource, in cases where multiple resources on same type exist in the same context / module. Name parameter can also be left empty, in which case it will be omitted from the pattern during the generation.

func (*Service) SetPattern

func (service *Service) SetPattern(pattern patterns.Pattern) error

SetPattern changes the naming convention pattern to a user defined value. To set a custom pattern, combine the placeholders in any order you wish, but without spaces, hyphens or any other characters.

Placeholders supported are {context} {module} {color} {name} {region} {environment} and {resource_suffix}.

For example, you can declare a new pattern like this:

var myPattern patterns.Pattern = "{resource_suffix}{environment}{context}{module}{region}{name}{color}"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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