mirror of https://github.com/rancher/ui.git
Add CA Certificate to kubeconfig
This commit is contained in:
parent
1b9cd1b2d2
commit
d3a9ca064a
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ clusters:
|
|||
- name: "%clusterName%"
|
||||
cluster:
|
||||
server: "%baseUrl%/k8s/clusters/%clusterId%"
|
||||
api-version: v1%maybeInsecure%%maybeCertificate%
|
||||
certificate-authority-data: %clusterCert%
|
||||
api-version: v1%maybeCertificate%
|
||||
|
||||
users:
|
||||
- name: "%username%"
|
||||
|
|
@ -37,6 +36,7 @@ export default Component.extend(ModalBase, {
|
|||
access: service(),
|
||||
growl: service(),
|
||||
scope: service(),
|
||||
settings: service(),
|
||||
modalService: service('modal'),
|
||||
|
||||
token: null,
|
||||
|
|
@ -47,19 +47,30 @@ 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');
|
||||
const certificate = get(this, `settings.${C.SETTING.CA_CERTS}`);
|
||||
|
||||
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 ) {
|
||||
|
|
@ -68,10 +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, (certificate ? '\n certificate-authority-data: ' + certificate : ''))
|
||||
.replace(/%maybeCertificate%/g, (wrapped ? '\n certificate-authority-data: "' + wrapped + '"': ''))
|
||||
.replace(/%username%/g, get(me, 'username'))
|
||||
.replace(/%token%/g, token);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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}}
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ var C = {
|
|||
WINDOWS: 'cli-url-windows',
|
||||
LINUX: 'cli-url-linux',
|
||||
},
|
||||
CA_CERTS: 'ca-certs',
|
||||
CA_CERTS: 'cacerts',
|
||||
API_HOST: 'api-host',
|
||||
ENGINE_URL: 'engine-install-url',
|
||||
SUPPORTED_DOCKER: 'engine-supported-range',
|
||||
|
|
|
|||
Loading…
Reference in New Issue