Documentation ¶
Index ¶
- func SetLogger(logger *logrus.Entry)
- type ErrSanityConfig
- type ErrSanityNoMapping
- type Iface
- type KeyMapper
- type Mapper
- func (m *Mapper) GetFromKey(resourceKey string, existingTags *map[string]string) (*map[string]string, error)
- func (m *Mapper) GetFromTags(existingTags *map[string]string) (*map[string]string, error)
- func (m *Mapper) GetMissingDefaults(existingTags *map[string]string) *map[string]string
- func (m *Mapper) LoadConfig(configReader io.Reader) error
- func (m *Mapper) MergeMaps(mainMap, complementary *map[string]string)
- func (m *Mapper) Retag(resourceID *string, tags *map[string]string, keys []string, setTags PutTagFn)
- func (m *Mapper) StripDefaults(existingTags *map[string]string)
- func (m *Mapper) ValidateTag(tagName, tagValue string) (*TagItem, error)
- type MockMapper
- type PutTagFn
- type TagCopy
- type TagItem
- type TagMapper
- type TagSanity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrSanityConfig ¶
type ErrSanityConfig struct { TagName string // contains filtered or unexported fields }
ErrSanityConfig is returned for the sanity checks in the Mapper
func NewErrSanityConfig ¶
func NewErrSanityConfig(message, tagName string) *ErrSanityConfig
NewErrSanityConfig generates a new ErrSanityNomapping
func (*ErrSanityConfig) Error ¶
func (e *ErrSanityConfig) Error() string
Error just returns the error message, basic error interface implementation
type ErrSanityNoMapping ¶
type ErrSanityNoMapping struct { TagName string TagValue string // contains filtered or unexported fields }
ErrSanityNoMapping is returned for the sanity checks in the Mapper
func NewErrSanityNoMapping ¶
func NewErrSanityNoMapping(message, tagName, tagValue string) *ErrSanityNoMapping
NewErrSanityNoMapping generates a new ErrSanityNomapping
func (*ErrSanityNoMapping) Error ¶
func (e *ErrSanityNoMapping) Error() string
Error just returns the error message, basic error interface implementation
type Iface ¶
type Iface interface { LoadConfig(io.Reader) error StripDefaults(*map[string]string) GetMissingDefaults(*map[string]string) *map[string]string GetFromTags(*map[string]string) (*map[string]string, error) GetFromKey(string, *map[string]string) (*map[string]string, error) ValidateTag(string, string) (*TagItem, error) MergeMaps(*map[string]string, *map[string]string) Retag(*string, *map[string]string, []string, PutTagFn) }
Iface has been created for testing purposes. It allows to create mocks when testing class that depend on the mapper
type KeyMapper ¶
type KeyMapper struct { KeyPattern string `json:"pattern"` Destination []*TagItem `json:"destination"` }
KeyMapper makes the relation between an existing key and a list of tags that should be present on that resource. A key is: - the SSH Key name for an ec2 instance - DBClusterIdentifier, DBInstanceIdentifier, DBName, MasterUsername for RDS instances - DBClusterIdentifier, DBName, MasterUsername for RDS clusters
type Mapper ¶
type Mapper struct { Iface CopyTag []*TagCopy `json:"copy_tags,omitempty"` TagMap []*TagMapper `json:"tags,omitempty"` KeyMap []*KeyMapper `json:"keys,omitempty"` Sanity []*TagSanity `json:"sanity,omitempty"` DefaultTagValues map[string]string `json:"defaults,omitempty"` }
Mapper contains the different mappings between attributes and the list of tags that should be present on that resource
func (*Mapper) GetFromKey ¶
func (m *Mapper) GetFromKey(resourceKey string, existingTags *map[string]string) (*map[string]string, error)
GetFromKey retrieves the tags corresponding to the KeyMap configuration except when the tag is already set in existingTags
func (*Mapper) GetFromTags ¶
GetFromTags returns all the tags to add or update based on a list of existing tag that exist on the resource.
func (*Mapper) GetMissingDefaults ¶
GetMissingDefaults returns the tags and their default values for the ones that are missing from the existing tags
func (*Mapper) LoadConfig ¶
LoadConfig loads a json-formatted config into the current Mapper using the given io.Reader
func (*Mapper) MergeMaps ¶
MergeMaps adds to mainMap the missing elements that are present in complementary
func (*Mapper) Retag ¶
func (m *Mapper) Retag(resourceID *string, tags *map[string]string, keys []string, setTags PutTagFn)
Retag does the different re-tagging operations and calls the given setTags function
func (*Mapper) StripDefaults ¶
StripDefaults removes from the existing tags the ones that are set to the default value
type MockMapper ¶
type MockMapper struct { Iface // ResourceTags is used to record which tags have been pushed to the Retag // function on which resource since the creation of the object ResourceTags map[string]map[string]string // ResourceKeys is used to record which keys have been pushed to the // Retag function on which resource since the creation of the object ResourceKeys map[string][]string }
MockMapper is used to mock the calls to retag during the tests
type TagCopy ¶
TagCopy specify a list of tags you want to copy the value from if they exist before the sanity of the tag is processed
type TagMapper ¶
type TagMapper struct { Source *TagItem `json:"source"` Destination []*TagItem `json:"destination"` }
TagMapper makes the relation between an existing tag on a resource and a list of tags that should be present on that resource
type TagSanity ¶
type TagSanity struct { TagName string `json:"tag_name"` Transform map[string][]string `json:"remap"` }
TagSanity limits the values of a tag to a list of values after remapping the values using the Transform matrix (the key is the acceptable value and the values are the list of values it will be transformed from)