Skip to content

Commit

Permalink
fix(ui): Reference secrets in EnvVars. Fixes #3973 (#4419)
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Tejera <aletepe@gmail.com>
  • Loading branch information
aletepe authored and simster7 committed Dec 10, 2020
1 parent 3b35ba2 commit 8ea219b
Showing 1 changed file with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Tabs, Ticker} from 'argo-ui';
import {Tabs, Ticker, Tooltip} from 'argo-ui';
import * as moment from 'moment';
import * as React from 'react';

Expand Down Expand Up @@ -164,6 +164,27 @@ function hasEnv(container: models.kubernetes.Container | models.Sidecar | models
return (container as models.kubernetes.Container | models.Sidecar).env !== undefined;
}

const EnvVar = (props: {env: models.kubernetes.EnvVar}) => {
const {env} = props;
const secret = env.valueFrom?.secretKeyRef;
const secretValue = secret ? (
<>
<Tooltip content={'The value of this environment variable has been hidden for security reasons because it comes from a kubernetes secret.'} arrow={false}>
<i className='fa fa-key' />
</Tooltip>
{secret.name}/{secret.key}
</>
) : (
undefined
);

return (
<pre>
{env.name}={env.value || secretValue}
</pre>
);
};

export const WorkflowNodeContainer = (props: {
nodeId: string;
container: models.kubernetes.Container | models.Sidecar | models.Script;
Expand All @@ -187,7 +208,13 @@ export const WorkflowNodeContainer = (props: {
hasEnv(container)
? {
title: 'ENV',
value: <pre className='workflow-node-info__multi-line'>{(container.env || []).map(e => `${e.name}=${e.value}`).join('\n')}</pre>
value: (
<pre className='workflow-node-info__multi-line'>
{(container.env || []).map(e => (
<EnvVar env={e} />
))}
</pre>
)
}
: {title: 'ENV', value: <pre className='workflow-node-info__multi-line' />}
];
Expand Down

0 comments on commit 8ea219b

Please sign in to comment.