Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eks): add tag update support for eks cluster #30123

Merged
merged 13 commits into from
May 31, 2024
Prev Previous commit
Next Next commit
change names
  • Loading branch information
mrlikl committed May 10, 2024
commit 5596b253713aeec5a85adff07ad05189f470e259
Original file line number Diff line number Diff line change
Expand Up @@ -393,27 +393,27 @@ function setsEqual(first: Set<string>, second: Set<string>) {
return first.size === second.size && [...first].every((e: string) => second.has(e));
}

function getTagsToUpdate<T extends Record<string, string>>(obj1: T, obj2: T): T {
function getTagsToUpdate<T extends Record<string, string>>(oldTags: T, newTags: T): T {
const diff: T = {} as T;
// Get all tag keys that are newly added and keys whose value have changed
for (const key in obj2) {
if (obj2.hasOwnProperty(key)) {
if (!obj1.hasOwnProperty(key)) {
diff[key] = obj2[key];
} else if (obj1[key] !== obj2[key]) {
diff[key] = obj2[key];
for (const key in newTags) {
if (newTags.hasOwnProperty(key)) {
if (!oldTags.hasOwnProperty(key)) {
diff[key] = newTags[key];
} else if (oldTags[key] !== newTags[key]) {
diff[key] = newTags[key];
}
}
}

return diff;
}

function getTagsToRemove<T extends Record<string, string>>(obj1: T, obj2: T): string[] {
function getTagsToRemove<T extends Record<string, string>>(oldTags: T, newTags: T): string[] {
const missingKeys: string[] = [];
//Get all tag keys to remove
for (const key in obj1) {
if (obj1.hasOwnProperty(key) && !obj2.hasOwnProperty(key)) {
for (const key in oldTags) {
if (oldTags.hasOwnProperty(key) && !newTags.hasOwnProperty(key)) {
missingKeys.push(key);
}
}
Expand Down