Skip to content

Commit

Permalink
Fix upgrade assistant warning for optional roles and roleTemplate pro…
Browse files Browse the repository at this point in the history
…perties (#179818)

Closes #177065

## Summary
Upgrade assistant in cloud shows a warning when trying to upgrade due to
mutually exclusive `roles` and `roleTemplates` property in the `Get Role
Mappings` API from ES. This PR fixes that by introducing conditional
checks for where we check for the `roles` property.


## Release notes
Fix warning displayed in Upgrade Assistant regarding `roles` and
`roleTemplate` properties when checking response from Get Role Mappings
API.

---------

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Kurt <[email protected]>
  • Loading branch information
3 people authored Apr 6, 2024
1 parent f04153b commit 597ab88
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async function getRoleMappingsDeprecations(
const roleMappingsWithReportingRole: string[] = Object.entries(roleMappings).reduce(
(roleSet, current) => {
const [roleName, role] = current;
const foundMapping = role.roles.find((roll) => deprecatedRoles.includes(roll));
const foundMapping = role.roles?.find((roll) => deprecatedRoles.includes(roll));
if (foundMapping) {
roleSet.push(`${roleName}[${foundMapping}]`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async function getRoleMappingsDeprecations(
}

const roleMappingsWithKibanaUserRole = Object.entries(roleMappings)
.filter(([, roleMapping]) => roleMapping.roles.includes(KIBANA_USER_ROLE_NAME))
.filter(([, roleMapping]) => roleMapping.roles?.includes(KIBANA_USER_ROLE_NAME))
.map(([mappingName]) => mappingName);
if (roleMappingsWithKibanaUserRole.length === 0) {
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function defineKibanaUserRoleDeprecationRoutes({ router, logger }: RouteD
}

const roleMappingsWithKibanaUserRole = Object.entries(roleMappings).filter(([, mapping]) =>
mapping.roles.includes(KIBANA_USER_ROLE_NAME)
mapping.roles?.includes(KIBANA_USER_ROLE_NAME)
);

if (roleMappingsWithKibanaUserRole.length === 0) {
Expand Down

0 comments on commit 597ab88

Please sign in to comment.