Просмотр исходного кода

cast json and numerical env var values to strings from Environment panel

jusrhee 5 лет назад
Родитель
Сommit
8fd714af3d
1 измененных файлов с 14 добавлено и 5 удалено
  1. 14 5
      dashboard/src/components/values-form/KeyValueArray.tsx

+ 14 - 5
dashboard/src/components/values-form/KeyValueArray.tsx

@@ -95,6 +95,15 @@ export default class KeyValueArray extends Component<PropsType, StateType> {
     return (
       <>
         {this.state.values.map((entry: any, i: number) => {
+
+          // Preprocess non-string env values set via raw Helm values
+          let { value } = entry;
+          if (typeof value === "object") {
+            value = JSON.stringify(value);
+          } else if (typeof value === "number") {
+            value = value.toString();
+          }
+
           return (
             <InputWrapper key={i}>
               <Input
@@ -108,13 +117,13 @@ export default class KeyValueArray extends Component<PropsType, StateType> {
                   let obj = this.valuesToObject();
                   this.props.setValues(obj);
                 }}
-                disabled={this.props.disabled || entry?.value?.includes("PORTERSECRET") }
+                disabled={this.props.disabled || value.includes("PORTERSECRET") }
               />
               <Spacer />
               <Input
                 placeholder="ex: value"
                 width="270px"
-                value={entry.value}
+                value={value}
                 onChange={(e: any) => {
                   this.state.values[i].value = e.target.value;
                   this.setState({ values: this.state.values });
@@ -122,11 +131,11 @@ export default class KeyValueArray extends Component<PropsType, StateType> {
                   let obj = this.valuesToObject();
                   this.props.setValues(obj);
                 }}
-                disabled={this.props.disabled || entry?.value?.includes("PORTERSECRET") }
-                type={entry?.value?.includes("PORTERSECRET") ? "password" : "text"}
+                disabled={this.props.disabled || value.includes("PORTERSECRET") }
+                type={value.includes("PORTERSECRET") ? "password" : "text"}
               />
               {this.renderDeleteButton(i)}
-              {this.renderHiddenOption(entry?.value?.includes("PORTERSECRET"), i)}
+              {this.renderHiddenOption(value.includes("PORTERSECRET"), i)}
             </InputWrapper>
           );
         })}