Explorar o código

fixed dotted keys

jusrhee %!s(int64=5) %!d(string=hai) anos
pai
achega
0f4ecf41ab

+ 5 - 0
dashboard/package-lock.json

@@ -418,6 +418,11 @@
       "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==",
       "dev": true
     },
+    "@types/lodash": {
+      "version": "4.14.165",
+      "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.165.tgz",
+      "integrity": "sha512-tjSSOTHhI5mCHTy/OOXYIhi2Wt1qcbHmuXD1Ha7q70CgI/I71afO4XtLb/cVexki1oVYchpul/TOuu3Arcdxrg=="
+    },
     "@types/markdown-to-jsx": {
       "version": "6.11.3",
       "resolved": "https://registry.npmjs.org/@types/markdown-to-jsx/-/markdown-to-jsx-6.11.3.tgz",

+ 2 - 0
dashboard/package.json

@@ -5,6 +5,7 @@
   "dependencies": {
     "@fullstory/browser": "^1.4.5",
     "@types/js-yaml": "^3.12.5",
+    "@types/lodash": "^4.14.165",
     "@types/markdown-to-jsx": "^6.11.3",
     "@types/qs": "^6.9.5",
     "ace-builds": "^1.4.12",
@@ -12,6 +13,7 @@
     "dotenv": "^8.2.0",
     "js-base64": "^3.6.0",
     "js-yaml": "^3.14.0",
+    "lodash": "^4.17.20",
     "markdown-to-jsx": "^7.0.1",
     "posthog-node": "^1.0.6",
     "qs": "^6.9.4",

+ 11 - 4
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -3,6 +3,7 @@ import styled from 'styled-components';
 import yaml from 'js-yaml';
 import { Base64 } from 'js-base64';
 import close from '../../../../assets/close.png';
+import _ from 'lodash';
 
 import { ResourceType, ChartType, StorageType, ChoiceType } from '../../../../shared/types';
 import { Context } from '../../../../shared/Context';
@@ -102,18 +103,24 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
     return null;
   }
 
-  upgradeValues = (values: any) => {
+  upgradeValues = (rawValues: any) => {
     let { currentProject, currentCluster, setCurrentError } = this.context;
 
-    // Weave in pre-existing values and convert to yaml
-    values = yaml.dump({ ...(this.props.currentChart.config as Object), ...values });
+    // Convert dotted keys to nested objects
+    let values = {};
+    for (let key in rawValues) {
+      _.set(values, key, rawValues[key]);
+    }
+
+    // Weave in preexisting values and convert to yaml
+    let valuesYaml = yaml.dump({ ...(this.props.currentChart.config as Object), ...values });
     
     this.setState({ saveValuesStatus: 'loading' });
     this.props.refreshChart();
     api.upgradeChartValues('<token>', {
       namespace: this.props.currentChart.namespace,
       storage: StorageType.Secret,
-      values,
+      values: valuesYaml,
     }, {
       id: currentProject.id, 
       name: this.props.currentChart.name,