tags

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ElasticbeanstalkTagKeyPrefix                = `elasticbeanstalk:`
	NameTagKey                                  = `Name`
	RDSTagKeyPrefix                             = `rds:`
	ServerlessApplicationRepositoryTagKeyPrefix = `serverlessrepo:`
)

Variables

This section is empty.

Functions

func GetResourceID

func GetResourceID(resourceID string) (string, string, error)

GetResourceID parses a given resource identifier for tag identifier and tag key.

func SetResourceID

func SetResourceID(identifier string, key string) string

SetResourceID creates a resource identifier given a tag identifier and a tag key.

func TagsSchema

func TagsSchema() *schema.Schema

TagsSchema returns the schema to use for tags.

func TagsSchemaComputed

func TagsSchemaComputed() *schema.Schema

func TagsSchemaComputedDeprecated

func TagsSchemaComputedDeprecated(message string) *schema.Schema

func TagsSchemaForceNew

func TagsSchemaForceNew() *schema.Schema

func ToSnakeCase

func ToSnakeCase(str string) string

ToSnakeCase converts a string to snake case.

For example, AWS Go SDK field names are in PascalCase, while Terraform schema attribute names are in snake_case.

Types

type DefaultConfig

type DefaultConfig struct {
	Tags KeyValueTags
}

DefaultConfig contains tags to default across all resources.

func (*DefaultConfig) GetTags

func (dc *DefaultConfig) GetTags() KeyValueTags

GetTags is convenience method that returns the DefaultConfig's Tags, if any

func (*DefaultConfig) MergeTags

func (dc *DefaultConfig) MergeTags(tags KeyValueTags) KeyValueTags

MergeTags returns the result of keyvaluetags.Merge() on the given DefaultConfig.Tags with KeyValueTags provided as an argument, overriding the value of any tag with a matching key.

func (*DefaultConfig) TagsEqual

func (dc *DefaultConfig) TagsEqual(tags KeyValueTags) bool

TagsEqual returns true if the given configuration's Tags are equal to those passed in as an argument; otherwise returns false

type IgnoreConfig

type IgnoreConfig struct {
	Keys        KeyValueTags
	KeyPrefixes KeyValueTags
}

IgnoreConfig contains various options for removing resource tags.

type KeyValueTags

type KeyValueTags map[string]*TagData

KeyValueTags is a standard implementation for AWS key-value resource tags. The AWS Go SDK is split into multiple service packages, each service with its own Go struct type representing a resource tag. To standardize logic across all these Go types, we convert them into this Go type.

func New

func New(i interface{}) KeyValueTags

New creates KeyValueTags from common types or returns an empty KeyValueTags.

Supports various Terraform Plugin SDK types including map[string]string, map[string]*string, map[string]interface{}, and []interface{}. When passed []interface{}, all elements are treated as keys and assigned nil values. When passed KeyValueTags or its underlying type implementation, returns itself.

func (KeyValueTags) Chunks

func (tags KeyValueTags) Chunks(size int) []KeyValueTags

Chunks returns a slice of KeyValueTags, each of the specified size.

func (KeyValueTags) ContainsAll

func (tags KeyValueTags) ContainsAll(target KeyValueTags) bool

ContainsAll returns whether or not all the target tags are contained.

func (KeyValueTags) Equal

func (tags KeyValueTags) Equal(other KeyValueTags) bool

Equal returns whether or two sets of key-value tags are equal.

func (KeyValueTags) Hash

func (tags KeyValueTags) Hash() int

Hash returns a stable hash value. The returned value may be negative (i.e. not suitable for a 'Set' function).

func (KeyValueTags) Ignore

func (tags KeyValueTags) Ignore(ignoreTags KeyValueTags) KeyValueTags

Ignore returns non-matching tag keys.

func (KeyValueTags) IgnoreAWS

func (tags KeyValueTags) IgnoreAWS() KeyValueTags

IgnoreAWS returns non-AWS tag keys.

func (KeyValueTags) IgnoreConfig

func (tags KeyValueTags) IgnoreConfig(config *IgnoreConfig) KeyValueTags

IgnoreConfig returns any tags not removed by a given configuration.

func (KeyValueTags) IgnoreElasticbeanstalk

func (tags KeyValueTags) IgnoreElasticbeanstalk() KeyValueTags

IgnoreElasticbeanstalk returns non-AWS and non-Elasticbeanstalk tag keys.

func (KeyValueTags) IgnorePrefixes

func (tags KeyValueTags) IgnorePrefixes(ignoreTagPrefixes KeyValueTags) KeyValueTags

IgnorePrefixes returns non-matching tag key prefixes.

func (KeyValueTags) IgnoreRDS

func (tags KeyValueTags) IgnoreRDS() KeyValueTags

IgnoreRDS returns non-AWS and non-RDS tag keys.

func (KeyValueTags) IgnoreServerlessApplicationRepository

func (tags KeyValueTags) IgnoreServerlessApplicationRepository() KeyValueTags

IgnoreServerlessApplicationRepository returns non-AWS and non-ServerlessApplicationRepository tag keys.

func (KeyValueTags) KeyAdditionalBoolValue

func (tags KeyValueTags) KeyAdditionalBoolValue(key string, fieldName string) *bool

KeyAdditionalBoolValue returns the boolean value of an additional tag field. If the key or additional field is not found, returns nil.

func (KeyValueTags) KeyAdditionalStringValue

func (tags KeyValueTags) KeyAdditionalStringValue(key string, fieldName string) *string

KeyAdditionalStringValue returns the string value of an additional tag field. If the key or additional field is not found, returns nil.

func (KeyValueTags) KeyExists

func (tags KeyValueTags) KeyExists(key string) bool

KeyExists returns true if a tag key exists. If the key is not found, returns nil.

func (KeyValueTags) KeyTagData

func (tags KeyValueTags) KeyTagData(key string) *TagData

KeyTagData returns all tag key data. If the key is not found, returns nil. Use KeyExists to determine if key is present.

func (KeyValueTags) KeyValue

func (tags KeyValueTags) KeyValue(key string) *string

KeyValue returns a tag key value. If the key is not found, returns nil. Use KeyExists to determine if key is present.

func (KeyValueTags) Keys

func (tags KeyValueTags) Keys() []string

Keys returns tag keys.

func (KeyValueTags) ListofMap

func (tags KeyValueTags) ListofMap() []map[string]interface{}

ListofMap returns a list of flattened tags. Compatible with setting Terraform state for strongly typed configuration blocks.

func (KeyValueTags) Map

func (tags KeyValueTags) Map() map[string]string

Map returns tag keys mapped to their values.

func (KeyValueTags) Merge

func (tags KeyValueTags) Merge(mergeTags KeyValueTags) KeyValueTags

Merge adds missing and updates existing tags.

func (KeyValueTags) Only

func (tags KeyValueTags) Only(onlyTags KeyValueTags) KeyValueTags

Only returns matching tag keys.

func (KeyValueTags) RemoveDefaultConfig

func (tags KeyValueTags) RemoveDefaultConfig(dc *DefaultConfig) KeyValueTags

RemoveDefaultConfig returns tags not present in a DefaultConfig object in addition to tags with key/value pairs that override those in a DefaultConfig; however, if all tags present in the DefaultConfig object are equivalent to those in the given KeyValueTags, then the KeyValueTags are returned, effectively bypassing the need to remove differing tags.

func (KeyValueTags) Removed

func (tags KeyValueTags) Removed(newTags KeyValueTags) KeyValueTags

Removed returns tags removed.

func (KeyValueTags) String

func (tags KeyValueTags) String() string

String returns the default string representation of the KeyValueTags.

func (KeyValueTags) URLEncode

func (tags KeyValueTags) URLEncode() string

URLEncode returns the KeyValueTags encoded as URL Query parameters.

func (KeyValueTags) URLQueryString

func (tags KeyValueTags) URLQueryString() string

URLQueryString returns the KeyValueTags formatted as URL Query parameters without encoding.

func (KeyValueTags) Updated

func (tags KeyValueTags) Updated(newTags KeyValueTags) KeyValueTags

Updated returns tags added and updated.

type TagData

type TagData struct {
	// Additional boolean field names and values associated with this tag.
	// Each service is responsible for properly handling this data.
	AdditionalBoolFields map[string]*bool

	// Additional string field names and values associated with this tag.
	// Each service is responsible for properly handling this data.
	AdditionalStringFields map[string]*string

	// Tag value.
	Value *string
}

TagData represents the data associated with a resource tag key. Almost exclusively for AWS services, this is just a tag value, however there are services that attach additional data to tags. An example is autoscaling with the PropagateAtLaunch field.

func (*TagData) Equal

func (td *TagData) Equal(other *TagData) bool

func (*TagData) String

func (td *TagData) String() string

Jump to

Keyboard shortcuts

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