mirror of https://github.com/portainer/portainer
fix(kube-owner): owner labels from resources created via manifest [EE-6647] (#11102)
Co-authored-by: testa113 <testa113>pull/10001/head^2
parent
80b1cd19cb
commit
901549e8dd
|
@ -1,6 +1,8 @@
|
||||||
import { formatDate } from '@/portainer/filters/filters';
|
import { formatDate } from '@/portainer/filters/filters';
|
||||||
|
import { appOwnerLabel } from '@/react/kubernetes/applications/constants';
|
||||||
|
|
||||||
import { ConfigMapRowData } from '../types';
|
import { ConfigMapRowData } from '../types';
|
||||||
|
import { configurationOwnerUsernameLabel } from '../../../constants';
|
||||||
|
|
||||||
import { columnHelper } from './helper';
|
import { columnHelper } from './helper';
|
||||||
|
|
||||||
|
@ -12,7 +14,8 @@ export const created = columnHelper.accessor((row) => getCreatedAtText(row), {
|
||||||
|
|
||||||
function getCreatedAtText(row: ConfigMapRowData) {
|
function getCreatedAtText(row: ConfigMapRowData) {
|
||||||
const owner =
|
const owner =
|
||||||
row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner'];
|
row.metadata?.labels?.[configurationOwnerUsernameLabel] ||
|
||||||
|
row.metadata?.labels?.[appOwnerLabel];
|
||||||
const date = formatDate(row.metadata?.creationTimestamp);
|
const date = formatDate(row.metadata?.creationTimestamp);
|
||||||
return owner ? `${date} by ${owner}` : date;
|
return owner ? `${date} by ${owner}` : date;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import { CellContext } from '@tanstack/react-table';
|
import { CellContext } from '@tanstack/react-table';
|
||||||
|
|
||||||
import { Authorized } from '@/react/hooks/useUser';
|
import { Authorized } from '@/react/hooks/useUser';
|
||||||
|
import { appOwnerLabel } from '@/react/kubernetes/applications/constants';
|
||||||
|
|
||||||
import { Link } from '@@/Link';
|
import { Link } from '@@/Link';
|
||||||
import { Badge } from '@@/Badge';
|
import { Badge } from '@@/Badge';
|
||||||
|
|
||||||
import { ConfigMapRowData } from '../types';
|
import { ConfigMapRowData } from '../types';
|
||||||
|
import { configurationOwnerUsernameLabel } from '../../../constants';
|
||||||
|
|
||||||
import { columnHelper } from './helper';
|
import { columnHelper } from './helper';
|
||||||
|
|
||||||
|
@ -16,8 +18,11 @@ export const name = columnHelper.accessor(
|
||||||
const isSystemToken = name?.includes('default-token-');
|
const isSystemToken = name?.includes('default-token-');
|
||||||
const isSystemConfigMap = isSystemToken || row.isSystem;
|
const isSystemConfigMap = isSystemToken || row.isSystem;
|
||||||
|
|
||||||
const hasConfigurationOwner =
|
const hasConfigurationOwner = !!(
|
||||||
!!row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner'];
|
row.metadata?.labels?.[configurationOwnerUsernameLabel] ||
|
||||||
|
row.metadata?.labels?.[appOwnerLabel]
|
||||||
|
);
|
||||||
|
|
||||||
return `${name} ${isSystemConfigMap ? 'system' : ''} ${
|
return `${name} ${isSystemConfigMap ? 'system' : ''} ${
|
||||||
!isSystemToken && !hasConfigurationOwner ? 'external' : ''
|
!isSystemToken && !hasConfigurationOwner ? 'external' : ''
|
||||||
} ${!row.inUse && !isSystemConfigMap ? 'unused' : ''}`;
|
} ${!row.inUse && !isSystemConfigMap ? 'unused' : ''}`;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { formatDate } from '@/portainer/filters/filters';
|
import { formatDate } from '@/portainer/filters/filters';
|
||||||
|
import { appOwnerLabel } from '@/react/kubernetes/applications/constants';
|
||||||
|
|
||||||
import { SecretRowData } from '../types';
|
import { SecretRowData } from '../types';
|
||||||
|
import { configurationOwnerUsernameLabel } from '../../../constants';
|
||||||
|
|
||||||
import { columnHelper } from './helper';
|
import { columnHelper } from './helper';
|
||||||
|
|
||||||
|
@ -12,7 +14,8 @@ export const created = columnHelper.accessor((row) => getCreatedAtText(row), {
|
||||||
|
|
||||||
function getCreatedAtText(row: SecretRowData) {
|
function getCreatedAtText(row: SecretRowData) {
|
||||||
const owner =
|
const owner =
|
||||||
row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner'];
|
row.metadata?.labels?.[configurationOwnerUsernameLabel] ||
|
||||||
|
row.metadata?.labels?.[appOwnerLabel];
|
||||||
const date = formatDate(row.metadata?.creationTimestamp);
|
const date = formatDate(row.metadata?.creationTimestamp);
|
||||||
return owner ? `${date} by ${owner}` : date;
|
return owner ? `${date} by ${owner}` : date;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import { CellContext } from '@tanstack/react-table';
|
import { CellContext } from '@tanstack/react-table';
|
||||||
|
|
||||||
import { Authorized } from '@/react/hooks/useUser';
|
import { Authorized } from '@/react/hooks/useUser';
|
||||||
|
import { appOwnerLabel } from '@/react/kubernetes/applications/constants';
|
||||||
|
|
||||||
import { Link } from '@@/Link';
|
import { Link } from '@@/Link';
|
||||||
import { Badge } from '@@/Badge';
|
import { Badge } from '@@/Badge';
|
||||||
|
|
||||||
import { SecretRowData } from '../types';
|
import { SecretRowData } from '../types';
|
||||||
|
import { configurationOwnerUsernameLabel } from '../../../constants';
|
||||||
|
|
||||||
import { columnHelper } from './helper';
|
import { columnHelper } from './helper';
|
||||||
|
|
||||||
|
@ -18,8 +20,10 @@ export const name = columnHelper.accessor(
|
||||||
row.metadata?.annotations?.['portainer.io/registry.id'];
|
row.metadata?.annotations?.['portainer.io/registry.id'];
|
||||||
const isSystemSecret = isSystemToken || row.isSystem || isRegistrySecret;
|
const isSystemSecret = isSystemToken || row.isSystem || isRegistrySecret;
|
||||||
|
|
||||||
const hasConfigurationOwner =
|
const hasConfigurationOwner = !!(
|
||||||
!!row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner'];
|
row.metadata?.labels?.[configurationOwnerUsernameLabel] ||
|
||||||
|
row.metadata?.labels?.[appOwnerLabel]
|
||||||
|
);
|
||||||
return `${name} ${isSystemSecret ? 'system' : ''} ${
|
return `${name} ${isSystemSecret ? 'system' : ''} ${
|
||||||
!isSystemToken && !hasConfigurationOwner ? 'external' : ''
|
!isSystemToken && !hasConfigurationOwner ? 'external' : ''
|
||||||
} ${!row.inUse && !isSystemSecret ? 'unused' : ''}`;
|
} ${!row.inUse && !isSystemSecret ? 'unused' : ''}`;
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
export const configurationOwnerUsernameLabel =
|
||||||
|
'io.portainer.kubernetes.configuration.owner';
|
|
@ -1,4 +1,5 @@
|
||||||
import { formatDate } from '@/portainer/filters/filters';
|
import { formatDate } from '@/portainer/filters/filters';
|
||||||
|
import { appOwnerLabel } from '@/react/kubernetes/applications/constants';
|
||||||
|
|
||||||
import { columnHelper } from './helper';
|
import { columnHelper } from './helper';
|
||||||
|
|
||||||
|
@ -13,7 +14,8 @@ export const created = columnHelper.accessor(
|
||||||
cell: ({ row, getValue }) => {
|
cell: ({ row, getValue }) => {
|
||||||
const date = formatDate(getValue());
|
const date = formatDate(getValue());
|
||||||
const owner =
|
const owner =
|
||||||
row.original.Labels?.['io.portainer.kubernetes.ingress.owner'];
|
row.original.Labels?.['io.portainer.kubernetes.ingress.owner'] ||
|
||||||
|
row.original.Labels?.[appOwnerLabel];
|
||||||
|
|
||||||
return owner ? `${date} by ${owner}` : date;
|
return owner ? `${date} by ${owner}` : date;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue