-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new AWSResourceManager.EnsureControllerTags() method (#90)
Issue #, if available: aws-controllers-k8s/community#1261 Description of changes: * Adds new `AWSResourceManager.EnsureTags()` method * `EnsureTags` method will be called before invoking `reconcile` method to update the desired resource with the ACK controller tags * This change also introduces a new `Tags` shape, which will be used as mediator/hub to merge AWS tags represented using different go types. * code-generator will generate the logic of conversion to/from `Tags` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
Showing
6 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
// not use this file except in compliance with the License. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file 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 tags | ||
|
||
// Tags represents the AWS tags which will be added to the AWS resource. | ||
// Inside aws-sdk-go, Tags are represented using multiple types, Ex: map of | ||
// string, list of structs etc... | ||
// Tags type will be used as a hub/mediator to merge tags represented | ||
// using different types. | ||
type Tags map[string]string | ||
|
||
// NewTags returns Tags with empty tags | ||
func NewTags() Tags { | ||
return map[string]string{} | ||
} | ||
|
||
// Merge merges two set of Tags and returns the merge result. | ||
// In case of collision precedence is given to tags present in the first | ||
// parameter 'a'. | ||
func Merge(a Tags, b Tags) Tags { | ||
var result Tags | ||
// Initialize result with the first set of tags 'a'. | ||
// If first set is nil, initialize result with empty set of tags. | ||
if a == nil { | ||
result = NewTags() | ||
} else { | ||
result = a | ||
} | ||
if b != nil && len(b) > 0 { | ||
// Add all the tags which are not already present in result | ||
for tk, tv := range b { | ||
if _, found := result[tk]; !found { | ||
result[tk] = tv | ||
} | ||
} | ||
} | ||
return result | ||
} |
Oops, something went wrong.