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

decode secret values #1156

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const EnvSecret: React.FC<EnvSecretProps> = ({ env = DEFAULT_ENV, onUpdate }) =>
<EnvUploadField
envVarType={EnvironmentVariableType.SECRET}
onUpdate={(newEnvData) => onUpdate({ ...env, data: newEnvData })}
translateValue={(value) => atob(value)}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import { isConfigMapKind, isSecretKind, isStringKeyValuePairObject } from './uti
type EnvUploadFieldProps = {
onUpdate: (data: EnvVariableDataEntry[]) => void;
envVarType: EnvironmentVariableType;
translateValue?: (value: string) => string;
};

const EnvUploadField: React.FC<EnvUploadFieldProps> = ({ onUpdate, envVarType }) => {
const EnvUploadField: React.FC<EnvUploadFieldProps> = ({
onUpdate,
envVarType,
translateValue,
}) => {
const [fileValue, setFileValue] = React.useState('');
const [filename, setFilename] = React.useState('');
const [isLoading, setLoading] = React.useState(false);
Expand Down Expand Up @@ -61,7 +66,12 @@ const EnvUploadField: React.FC<EnvUploadFieldProps> = ({ onUpdate, envVarType })
setError('Data need to be string key value pairs, please check your file.');
} else {
setError('');
onUpdate(Object.entries(envData).map(([key, value]) => ({ key, value })));
onUpdate(
Object.entries(envData).map(([key, value]) => ({
key,
value: translateValue ? translateValue(value) : value,
})),
);
}
}
} catch (e) {
Expand Down