Documentation
¶
Index ¶
Constants ¶
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 ¶
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 ¶
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}"