Merge pull request #1595 from vincent99/master

Settings, CA Certificate
This commit is contained in:
Vincent Fiduccia 2018-01-23 15:19:04 -07:00 committed by GitHub
commit 9bb9bf5ded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 57 additions and 80 deletions

View File

@ -64,7 +64,7 @@ export default Route.extend(Preload, {
this.loadClusters(),
this.loadProjects(),
this.loadPreferences(),
//this.loadPublicSettings(),
this.loadPublicSettings(),
]);
}).catch((err) => {
return this.loadingError(err, transition);
@ -142,13 +142,7 @@ export default Route.extend(Preload, {
},
loadPublicSettings() {
return get(this,'globalStore').find('setting', null, {
url: 'settings',
forceReload: true,
filter: {
all: 'false'
}
});
return get(this,'globalStore').find('setting', null, { url: 'settings' });
},
loadSecrets() {

View File

@ -11,7 +11,6 @@ export default Route.extend({
this._super(...arguments);
return this.get('settings').load([
C.SETTING.API_HOST,
C.SETTING.CATALOG_URL,
C.SETTING.TELEMETRY,
]);
},

View File

@ -12,8 +12,9 @@ export default Route.extend({
model() {
let store = this.get('globalStore');
let def = JSON.parse(this.get(`settings.${C.SETTING.CLUSTER_TEMPLATE}`)) || {};
def.type = 'cluster';
let def ={
type: 'cluster'
};
let cluster = store.createRecord(def);
cluster.set('nodes', []);

View File

@ -16,12 +16,6 @@
<td data-title="Version">{{settings.rancherVersion}}</td>
</tr>
{{/if}}
{{#if settings.cattleVersion}}
<tr>
<td data-title="Component"><a href="https://github.com/rancher/cattle" target="_blank">{{t 'modalAboutComponent.cattle'}}</a></td>
<td data-title="Version">{{settings.cattleVersion}}</td>
</tr>
{{/if}}
{{#if settings.uiVersion}}
<tr>
<td data-title="Component"><a href="https://github.com/rancher/ui" target="_blank">{{t 'modalAboutComponent.ui'}}</a></td>
@ -34,21 +28,16 @@
<td data-title="Version">{{settings.cliVersion}}</td>
</tr>
{{/if}}
{{#if settings.composeVersion}}
{{#if settings.helmVersion}}
<tr>
<td data-title="Component"><a href="https://github.com/rancher/rancher-compose" target="_blank">{{settings.appName}} {{t 'modalAboutComponent.compose'}}</a></td>
<td data-title="Version">{{settings.composeVersion}}</td>
<td data-title="Component"><a href="https://github.com/rancher/rancher-compose" target="_blank">{{t 'modalAboutComponent.helm'}}</a></td>
<td data-title="Version">{{settings.helmVersion}}</td>
</tr>
{{/if}}
{{#if settings.goMachineVersion}}
{{#if settings.dockerMachineVersion}}
<tr>
<td data-title="Component"><a href="https://github.com/rancher/go-machine-service" target="_blank">{{t 'modalAboutComponent.machineService'}}</a></td>
<td data-title="Version">
{{settings.goMachineVersion}}
{{#if settings.dockerMachineVersion}}
(<a href="https://github.com/docker/machine" target="_blank">{{t 'modalAboutComponent.dockerMachine'}}</a> {{settings.dockerMachineVersion}})
{{/if}}
</td>
<td data-title="Component"><a href="https://github.com/rancher/go-machine-service" target="_blank">{{t 'modalAboutComponent.machine'}}</a></td>
<td data-title="Version">{{t 'modalAboutComponent.dockerMachine'}}</td>
</tr>
{{/if}}
</table>

View File

@ -23,11 +23,11 @@ export default Component.extend(ModalBase, NewOrEdit, {
},
displayEndpoint: function() {
return this.get('endpointService.api.display.account.current');
return this.get('endpointService.api.display.current');
}.property(),
linkEndpoint: function() {
return this.get('endpointService.api.auth.account.current');
return this.get('endpointService.api.auth.current');
}.property(),
didInsertElement() {

View File

@ -1,5 +1,6 @@
import { inject as service } from '@ember/service';
import { get, set, computed } from '@ember/object';
import C from 'shared/utils/constants';
import Component from '@ember/component';
import ModalBase from 'shared/mixins/modal-base';
import layout from './template';
@ -9,8 +10,8 @@ kind: Config
clusters:
- name: "%clusterName%"
cluster:
api-version: v1%maybeInsecure%
server: "%baseUrl%/k8s/clusters/%clusterId%"
api-version: v1%maybeCertificate%
users:
- name: "%username%"
@ -35,6 +36,7 @@ export default Component.extend(ModalBase, {
access: service(),
growl: service(),
scope: service(),
settings: service(),
modalService: service('modal'),
token: null,
@ -45,19 +47,31 @@ export default Component.extend(ModalBase, {
replaceVariables(str) {
let base = window.location.origin;
let insecure = false;
if ( base.indexOf('http://') === 0 ) {
base = base.replace(/^http:\/\//,'https://');
if ( ! window.location.port ) {
base += ':80';
}
insecure = true;
}
const me = get(this, 'access.me');
const cluster = get(this, 'scope.currentCluster');
const tokenObj = get(this, 'token');
let cert = get(this, `settings.${C.SETTING.CA_CERTS}`);
let wrapped;
if ( cert && cert.length ) {
let ary = [];
cert = btoa(cert);
let split = 45;
while ( cert.length ) {
ary.push(cert.substr(0,split))
cert = cert.substr(split);
split=72;
}
wrapped = ary.join('\\\n ').trim();
}
let token = '';
if ( tokenObj ) {
token = tokenObj.token;
@ -65,9 +79,9 @@ export default Component.extend(ModalBase, {
return str
.replace(/%baseUrl%/g, base)
.replace(/%maybeInsecure%/g,(insecure ? '\n insecure-skip-tls-verify: true' : ''))
.replace(/%clusterId%/g, get(cluster, 'id'))
.replace(/%clusterName%/g, get(cluster, 'displayName'))
.replace(/%maybeCertificate%/g, (wrapped ? '\n certificate-authority-data: "' + wrapped + '"': ''))
.replace(/%username%/g, get(me, 'username'))
.replace(/%token%/g, token);
},

View File

@ -4,7 +4,7 @@
{{/if}}
{{#if (eq step 2)}}
<p>{{t 'k8sPage.configFile.usage.helpText' htmlSafe=true}}</p>
<pre><code>{{kubeconfig}}</code></pre>
{{code-block language="yaml" code=kubeconfig}}
{{copy-to-clipboard tooltipText="" buttonText="copyToClipboard.tooltip" clipboardText=kubeconfig class="with-clip"}}
<p class="mt-10 mb-0">{{t 'k8sPage.configFile.usage.downloadText' downloadUrl=downloadUrl htmlSafe=true}}</p>
{{/if}}

View File

@ -31,14 +31,8 @@ export default Component.extend({
cli[key.toLowerCase()] = settings.get(C.SETTING.CLI_URL[key]);
});
let compose = {};
Object.keys(C.SETTING.COMPOSE_URL).forEach((key) => {
compose[key.toLowerCase()] = settings.get(C.SETTING.COMPOSE_URL[key]);
});
this.setProperties({
cli: cli,
compose: compose,
cli
});
},

View File

@ -7,11 +7,11 @@ import C from 'shared/utils/constants';
import { minorVersion } from 'shared/utils/parse-version';
export function normalizeName(str) {
return str.replace(/\./g, C.SETTING.DOT_CHAR).toLowerCase();
return str; //.replace(/\./g, C.SETTING.DOT_CHAR).toLowerCase();
}
export function denormalizeName(str) {
return str.replace(new RegExp('['+C.SETTING.DOT_CHAR+']','g'),'.').toLowerCase();
return str; //.replace(new RegExp('['+C.SETTING.DOT_CHAR+']','g'),'.').toLowerCase();
}
export default Service.extend(Evented, {
@ -147,7 +147,6 @@ export default Service.extend(Evented, {
issueUrl: function() {
var str = '*Describe your issue here*\n\n\n---\n| Useful | Info |\n| :-- | :-- |\n' +
`|Versions|Rancher \`${this.get('rancherVersion')||'-'}\` ` +
`Cattle: \`${this.get('cattleVersion')||'-'}\` ` +
`UI: \`${this.get('uiVersion')||'--'}\` |\n`;
if ( this.get('access.enabled') )
@ -164,15 +163,13 @@ export default Service.extend(Evented, {
var url = C.EXT_REFERENCES.GITHUB + '/issues/new?body=' + encodeURIComponent(str);
return url;
}.property('app.currentRouteName','access.{provider,admin}','cattleVersion','rancherVersion','uiVersion'),
}.property('app.currentRouteName','access.{provider,admin}','rancherVersion','uiVersion'),
rancherImage: alias(`asMap.${C.SETTING.IMAGE_RANCHER}.value`),
rancherVersion: alias(`asMap.${C.SETTING.VERSION_RANCHER}.value`),
composeVersion: alias(`asMap.${C.SETTING.VERSION_COMPOSE}.value`),
cattleVersion: alias(`asMap.${C.SETTING.VERSION_CATTLE}.value`),
cliVersion: alias(`asMap.${C.SETTING.VERSION_CLI}.value`),
dockerMachineVersion: alias(`asMap.${C.SETTING.VERSION_MACHINE}.value`),
goMachineVersion: alias(`asMap.${C.SETTING.VERSION_GMS}.value`),
helmVersion: alias(`asMap.${C.SETTING.VERSION_HELM}.value`),
_plValue: function() {
let TRUE=true; // @TODO-2.0

View File

@ -206,7 +206,6 @@ var C = {
CLUSTER_DEFAULT : 'defaultClusterId',
LAST_SCALE_MODE : 'lastScaleMode',
LAST_NAMESPACE : 'lastNamespace',
SHOW_SYSTEM : 'showSystem',
SORT_STACKS_BY : 'sortStacksBy',
TABLE_COUNT : 'tableCount',
THEME : 'theme',
@ -413,37 +412,27 @@ var C = {
},
SETTING: {
// Dots in key names do not mix well with Ember, so we use $ in their place.
DOT_CHAR: '$',
IMAGE_RANCHER: 'rancher$server$image',
VERSION_RANCHER: 'rancher$server$version',
VERSION_COMPOSE: 'rancher$compose$version',
VERSION_CLI: 'rancher$cli$version',
VERSION_CATTLE: 'cattle$version',
VERSION_MACHINE: 'docker$machine$version',
VERSION_GMS: 'go$machine$service$version',
IMAGE_RANCHER: 'server-image',
VERSION_RANCHER: 'server-version',
VERSION_COMPOSE: 'compose-version',
VERSION_CLI: 'cli-version',
VERSION_MACHINE: 'machine-version',
VERSION_HELM: 'helm-version',
CLI_URL: {
DARWIN: 'rancher$cli$darwin$url',
WINDOWS: 'rancher$cli$windows$url',
LINUX: 'rancher$cli$linux$url',
DARWIN: 'cli-url-darwin',
WINDOWS: 'cli-url-windows',
LINUX: 'cli-url-linux',
},
COMPOSE_URL: {
DARWIN: 'rancher$compose$darwin$url',
WINDOWS: 'rancher$compose$windows$url',
LINUX: 'rancher$compose$linux$url',
},
API_HOST: 'api$host',
CATALOG_URL: 'catalog$url',
ENGINE_URL: 'engine$install$url',
SUPPORTED_DOCKER: 'supported$docker$range',
NEWEST_DOCKER: 'newest$docker$version',
TELEMETRY: 'telemetry$opt',
AUTH_LOCAL_VALIDATE_DESC: 'api$auth$local$validate$description',
BALANCER_IMAGE: 'lb$instance$image',
FEEDBACK_FORM: 'ui$feedback$form',
SHOW_SYSTEM: 'ui$show$system',
SHOW_CUSTOM_HOST: 'ui$show$custom$host',
CLUSTER_TEMPLATE: 'default$cluster$template',
CA_CERTS: 'cacerts',
API_HOST: 'api-host',
ENGINE_URL: 'engine-install-url',
SUPPORTED_DOCKER: 'engine-supported-range',
NEWEST_DOCKER: 'engine-newest-version',
TELEMETRY: 'telemetry-opt',
AUTH_LOCAL_VALIDATE_DESC: 'auth-password-requirements-description',
BALANCER_IMAGE: 'balancer-instance-image',
FEEDBACK_FORM: 'ui-feedback-form',
},
TABLES: {
@ -451,7 +440,7 @@ var C = {
},
THEME: {
AUTO_UPDATE_TIMER : 1800000,
AUTO_UPDATE_TIMER : 30*60*1000,
START_HOUR : 7,
END_HOUR : 18,
DEFAULT : 'ui-light',