naming

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 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) (*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).
Environment provides you the possibility to isolate your resources per environment, e.g. prod, int, stage, dev, etc.
Regions should be in form of Azure long regions string, e.g. westeurope or northeurope.

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} {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}"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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