@@ -1,3 +1,19 @@
+/*
+Copyright 2018 The Kubernetes Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 package converters
 
 import (
package converters

import (
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/ec2"
)

// TagsToMap converts a []*ec2.Tag into a map[string]string.
func TagsToMap(src []*ec2.Tag) map[string]string {
	// Create an array of exactly the length we require to hopefully avoid some
	// allocations while looping.
	tags := make(map[string]string)

	for _, t := range src {
		tags[*t.Key] = *t.Value
	}

	return tags
}

// MapToTags converts a map[string]string to a []*ec2.Tag
func MapToTags(src map[string]string) []*ec2.Tag {
	// Create an array of exactly the length we require to hopefully avoid some
	// allocations while looping.
	tags := make([]*ec2.Tag, 0, len(src))

	for k, v := range src {
		tag := &ec2.Tag{
			Key:   aws.String(k),
			Value: aws.String(v),
		}

		tags = append(tags, tag)
	}

	return tags
}

@vincepri need your +1 here