-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supports Tag and Untag APIs for ACL. (#44)
Issue #, if available: Customers cannot modify tags of ACL. Description of changes: Adds functions so that customers can modify tags of ACL after creation. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
1 parent
a6318da
commit 0cd29f3
Showing
9 changed files
with
344 additions
and
60 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
ack_generate_info: | ||
build_date: "2022-12-22T20:12:01Z" | ||
build_date: "2022-12-23T06:27:19Z" | ||
build_hash: 16f0e201b37a06b535370cc69e11adb934a22d33 | ||
go_version: go1.19 | ||
version: v0.20.1-18-g16f0e20 | ||
api_directory_checksum: a1e396caca4bdd1612fa7d09f0ee56f3e4976ff7 | ||
api_version: v1alpha1 | ||
aws_sdk_go_version: v1.44.93 | ||
generator_config_info: | ||
file_checksum: 8aa3940404a0667041e270bce2d86684b9e1df4d | ||
file_checksum: 62ca61f60f6152f6c53f31b6ebbe43b39f86d225 | ||
original_file_name: generator.yaml | ||
last_modification: | ||
reason: API generation |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resourceARN := (*string)(ko.Status.ACKResourceMetadata.ARN) | ||
tags, err := rm.getTags(ctx, *resourceARN) | ||
if err != nil { | ||
return nil, err | ||
} | ||
ko.Spec.Tags = tags |
108 changes: 54 additions & 54 deletions
108
templates/hooks/acl/sdk_update_post_build_request.go.tpl
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 |
---|---|---|
@@ -1,54 +1,54 @@ | ||
createMapForUserNames := func(userIds []*string) map[string]bool { | ||
userIdsMap := make(map[string]bool) | ||
for _, userId := range userIds { | ||
userIdsMap[*userId] = true | ||
} | ||
|
||
return userIdsMap | ||
} | ||
|
||
for _, diff := range delta.Differences { | ||
if diff.Path.Contains("Spec.UserNames") { | ||
existingUserNamesMap := createMapForUserNames(diff.B.([]*string)) | ||
requiredUserNamesMap := createMapForUserNames(diff.A.([]*string)) | ||
// If a user ID is not required to be deleted or added set its value as false | ||
for userName, _ := range existingUserNamesMap { | ||
if _, ok := requiredUserNamesMap[userName]; ok { | ||
requiredUserNamesMap[userName] = false | ||
existingUserNamesMap[userName] = false | ||
} | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// User Ids to add | ||
{ | ||
var userNamesToAdd []*string | ||
for userName, include := range requiredUserNamesMap { | ||
if include { | ||
userNamesToAdd = append(userNamesToAdd, &userName) | ||
} | ||
} | ||
|
||
input.SetUserNamesToAdd(userNamesToAdd) | ||
} | ||
|
||
// User Ids to remove | ||
{ | ||
var userNamesToRemove []*string | ||
for userName, include := range existingUserNamesMap { | ||
if include { | ||
userNamesToRemove = append(userNamesToRemove, &userName) | ||
} | ||
} | ||
|
||
input.SetUserNamesToRemove(userNamesToRemove) | ||
} | ||
} | ||
} | ||
createMapForUserNames := func(userIds []*string) map[string]bool { | ||
userIdsMap := make(map[string]bool) | ||
for _, userId := range userIds { | ||
userIdsMap[*userId] = true | ||
} | ||
|
||
return userIdsMap | ||
} | ||
|
||
for _, diff := range delta.Differences { | ||
if diff.Path.Contains("Spec.UserNames") { | ||
existingUserNamesMap := createMapForUserNames(diff.B.([]*string)) | ||
requiredUserNamesMap := createMapForUserNames(diff.A.([]*string)) | ||
// If a user ID is not required to be deleted or added set its value as false | ||
for userName, _ := range existingUserNamesMap { | ||
if _, ok := requiredUserNamesMap[userName]; ok { | ||
requiredUserNamesMap[userName] = false | ||
existingUserNamesMap[userName] = false | ||
} | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// User Ids to add | ||
{ | ||
var userNamesToAdd []*string | ||
for userName, include := range requiredUserNamesMap { | ||
if include { | ||
userNamesToAdd = append(userNamesToAdd, &userName) | ||
} | ||
} | ||
|
||
input.SetUserNamesToAdd(userNamesToAdd) | ||
} | ||
|
||
// User Ids to remove | ||
{ | ||
var userNamesToRemove []*string | ||
for userName, include := range existingUserNamesMap { | ||
if include { | ||
userNamesToRemove = append(userNamesToRemove, &userName) | ||
} | ||
} | ||
|
||
input.SetUserNamesToRemove(userNamesToRemove) | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,16 @@ | ||
validationErr := rm.validateACLNeedsUpdate(latest) | ||
validationErr := rm.validateACLNeedsUpdate(latest) | ||
|
||
if validationErr != nil { | ||
return nil, err | ||
} | ||
if validationErr != nil { | ||
return nil, err | ||
} | ||
|
||
if delta.DifferentAt("Spec.Tags") { | ||
err = rm.updateTags(ctx, desired, latest) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
if !delta.DifferentExcept("Spec.Tags") { | ||
return desired, nil | ||
} |
Oops, something went wrong.