Skip to content

Commit

Permalink
Fix ondemand k8s showing aws icon rather than k8s (#1391)
Browse files Browse the repository at this point in the history
  • Loading branch information
likawind authored May 31, 2023
1 parent c715756 commit 1def56c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ui/common/src/components/resources/cards/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Box from '@mui/material/Box';
import React from 'react';

import {
resolveDisplayService,
resolveLogoService,
Resource,
resourceExecState,
} from '../../../utils/resources';
Expand Down Expand Up @@ -39,7 +39,7 @@ export const ResourceCard: React.FC<ResourceProps> = ({
</TruncatedText>
</Box>
<ResourceLogo
service={resolveDisplayService(resource)}
service={resolveLogoService(resource)}
size="small"
activated
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Typography from '@mui/material/Typography';
import React from 'react';

import {
resolveDisplayService,
resolveLogoService,
Resource,
resourceExecState,
} from '../../../utils/resources';
Expand All @@ -29,7 +29,7 @@ export const ResourceHeaderDetailsCard: React.FC<
>
<Box display="flex" flexDirection="row" alignItems="center">
<ResourceLogo
service={resolveDisplayService(resource)}
service={resolveLogoService(resource)}
size="medium"
activated
/>
Expand Down
13 changes: 10 additions & 3 deletions src/ui/common/src/utils/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,22 @@ export function resourceExecState(resource: Resource): ExecState {
return resource.exec_state || { status: ExecutionStatus.Succeeded };
}

// The only resource that does not necessarily display the same service type as
// on the resource itself is Conda.
export function resolveDisplayService(resource: Resource): Service {
// The resolve the service logo to display.
// This can be different from the actual service. For example:
// Aq with conda should display conda.
// AWS, GCP using on-demand K8s should display K8s.
export function resolveLogoService(resource: Resource): Service {
if (resource.service === 'Aqueduct') {
const aqConfig = resource.config as AqueductComputeConfig;
if (aqConfig.conda_config_serialized) {
return 'Conda';
}
}

if (resource.service === 'AWS' || resource.service === 'GCP') {
return 'Kubernetes';
}

return resource.service;
}

Expand Down

0 comments on commit 1def56c

Please sign in to comment.