Add new RKE Defaults Setting

rancher/rancher#15111
This commit is contained in:
Westly Wright 2018-08-27 16:43:28 -07:00
parent fa099a3efc
commit cb1b2b2e78
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
11 changed files with 53 additions and 8 deletions

View File

@ -10,7 +10,7 @@ export default Component.extend(ModalBase, {
settings: service(),
growl: service(),
layout,
classNames: ['span-8', 'offset-2'],
classNames: ['modal-edit-setting', 'span-8', 'offset-2'],
value: null,
removing: false,
@ -19,7 +19,12 @@ export default Component.extend(ModalBase, {
init() {
this._super(...arguments);
this.set('value', this.get('model.obj.value') || '');
if (this.get('model.kind') === 'json') {
this.set('value', JSON.stringify(JSON.parse(this.get('model.obj.value')), undefined, 2));
} else {
this.set('value', this.get('model.obj.value') || '');
}
},
didInsertElement() {

View File

@ -15,6 +15,8 @@
{{textarea class="form-control" value=value rows=10}}
{{else if (eq model.kind 'int')}}
{{input-integer value=value class="form-control"}}
{{else if (eq model.kind 'json')}}
{{ivy-codemirror value=value}}
{{else if (eq model.kind 'boolean')}}
<div class="radio">
<label>{{radio-button selection=value value="true"}} True</label>

View File

@ -83,6 +83,7 @@ module.exports = function(defaults) {
app.import('node_modules/prismjs/prism.js');
app.import('node_modules/prismjs/components/prism-bash.js');
app.import('node_modules/prismjs/components/prism-yaml.js');
app.import('node_modules/prismjs/components/prism-json.js');
app.import('node_modules/ember-source/dist/ember-template-compiler.js')
// app.import('vendor/aws-sdk-ec2.js');

View File

@ -65,6 +65,11 @@ export default Component.extend({
out.set('hide', true);
}
if (get(details, 'kind') === 'json') {
out.set('hide', true);
out.set('parsedJSON', JSON.stringify(JSON.parse(out.get('obj.value')), undefined, 2))
}
(Object.keys(details) || []).forEach((key2) => {
out.set(key2, details[key2]);
});

View File

@ -26,15 +26,19 @@
</div>
{{else}}
<div class="">
<pre class="bg-setting m-0">
{{#if (eq row.kind "json" )}}
{{code-block code=row.parsedJSON language="json"}}
{{else}}
<pre class="bg-setting m-0">
{{~#if row.obj.value~}}
{{~row.obj.value~}}
{{~else~}}
<span class="text-muted">&lt;none&gt;</span>
{{~/if~}}
</pre>
</pre>
{{/if}}
<div class="row mt-5">
{{#if (eq row.kind 'multiline')}}
{{#if (or (eq row.kind 'multiline') (eq row.kind 'json'))}}
<div class="btn bg-info btn-sm" {{action "showNode" row}}>Hide {{row.key}}</div>
{{/if}}
</div>

View File

@ -0,0 +1,7 @@
import Helper from '@ember/component/helper';
export default Helper.extend({
compute(params/* , options*/) {
return JSON.parse(params[0]);
},
});

View File

@ -2,6 +2,6 @@ import Helper from '@ember/component/helper';
export default Helper.extend({
compute(params/* , options*/) {
return JSON.stringify(params[0]);
return JSON.stringify(params[0], undefined, 2);
},
});

View File

@ -479,6 +479,7 @@ var C = {
API_HOST: 'api-host',
CA_CERTS: 'cacerts',
CLUSTER_DEFAULTS: 'cluster-defaults',
ENGINE_URL: 'engine-install-url',
ENGINE_ISO_URL: 'engine-iso-url',
FIRST_LOGIN: 'first-login',
@ -512,6 +513,7 @@ var C = {
C.SETTING.ALLOWED = {
[C.SETTING.CA_CERTS]: { kind: 'multiline' },
[C.SETTING.CLUSTER_DEFAULTS]: { kind: 'json' },
[C.SETTING.ENGINE_URL]: {},
[C.SETTING.ENGINE_ISO_URL]: {},
[C.SETTING.PL]: {},
@ -519,8 +521,8 @@ C.SETTING.ALLOWED = {
[C.SETTING.SERVER_URL]: {},
'system-default-registry': {},
[C.SETTING.TELEMETRY]: {
kind: 'enum',
options: ['prompt', 'in', 'out']
kind: 'enum',
options: ['prompt', 'in', 'out']
},
'ui-index': {},
};

View File

@ -0,0 +1 @@
export { default, fromJson } from 'shared/helpers/from-json';

View File

@ -0,0 +1,17 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
module('Integration | Helper | from-json', function(hooks) {
setupRenderingTest(hooks);
// Replace this with your real tests.
test('it renders', async function(assert) {
this.set('inputValue', '1234');
await render(hbs`{{from-json inputValue}}`);
assert.equal(this.element.textContent.trim(), '1234');
});
});

View File

@ -2896,6 +2896,7 @@ dangerZone:
showLabel: I understand that I can break things by changing advanced settings.
description:
'cacerts': "CA Certificates needed to verify the server's certificate"
'cluster-defaults': 'Override RKE Defaults when creating new clusters.'
'engine-install-url': 'Default Docker engine installation URL (for most node drivers)'
'engine-iso-url': 'Default OS installation URL (for vSphere driver)'
'engine-newest-version': 'The newest supported version of Docker at the time of this release. A Docker version that does not satisfy supported docker range but is newer than this will be marked as untested'