Sfoglia il codice sorgente

replacing encrypted env variables with passwordchar

xetera 4 anni fa
parent
commit
6c8b572e89

+ 7 - 0
dashboard/src/main/home/cluster-dashboard/env-groups/EnvGroup.tsx

@@ -76,6 +76,13 @@ export default class EnvGroup extends Component<PropsType, StateType> {
   }
 }
 
+export function formattedEnvironmentValue(value: string) {
+  if (value.startsWith("PORTERSECRET_")) {
+    return "••••";
+  }
+  return value;
+}
+
 EnvGroup.contextType = Context;
 
 const BottomWrapper = styled.div`

+ 11 - 3
dashboard/src/main/home/modals/LoadEnvGroupModal.tsx

@@ -9,7 +9,10 @@ import { Context } from "shared/Context";
 import Loading from "components/Loading";
 import SaveButton from "components/SaveButton";
 import { KeyValue } from "components/values-form/KeyValueArray";
-import { EnvGroupData } from "../cluster-dashboard/env-groups/EnvGroup";
+import {
+  EnvGroupData,
+  formattedEnvironmentValue,
+} from "../cluster-dashboard/env-groups/EnvGroup";
 
 type PropsType = {
   namespace: string;
@@ -130,7 +133,9 @@ export default class LoadEnvGroupModal extends Component<PropsType, StateType> {
                 {this.props.existingValues[key] || emptyValue}
               </ClashingKeyValue>
               <ClashingKeyLabel>Replaced by</ClashingKeyLabel>
-              <ClashingKeyValue>{value || emptyValue}</ClashingKeyValue>
+              <ClashingKeyValue>
+                {formattedEnvironmentValue(value) || emptyValue}
+              </ClashingKeyValue>
             </ClashingKeyDefinitions>
             {i !== clashingKeys.length - 1 && <ClashingKeyRowDivider />}
           </li>
@@ -164,7 +169,10 @@ export default class LoadEnvGroupModal extends Component<PropsType, StateType> {
             <SidebarSection>
               <GroupEnvPreview>
                 {Object.entries(this.state.selectedEnvGroup.data)
-                  .map(([key, value]) => `${key}=${value}`)
+                  .map(
+                    ([key, value]) =>
+                      `${key}=${formattedEnvironmentValue(value)}`
+                  )
                   .join("\n")}
               </GroupEnvPreview>
               {clashingKeys.length > 0 && (