From 34664b235b39b6802edc52f9db190991c4e5bc33 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Thu, 18 Oct 2018 10:16:06 -0700 Subject: [PATCH] Add private registry to cluster create rancher/rancher#15554 --- .../cluster-driver/driver-rke/template.hbs | 176 +++++++++++------- .../cru-private-registry/component.js | 88 +++++++++ .../cru-private-registry/template.hbs | 71 +++++++ .../cru-private-registry/component.js | 1 + translations/en-us.yaml | 19 ++ 5 files changed, 283 insertions(+), 72 deletions(-) create mode 100644 lib/shared/addon/components/cru-private-registry/component.js create mode 100644 lib/shared/addon/components/cru-private-registry/template.hbs create mode 100644 lib/shared/app/components/cru-private-registry/component.js diff --git a/lib/shared/addon/components/cluster-driver/driver-rke/template.hbs b/lib/shared/addon/components/cluster-driver/driver-rke/template.hbs index 39788cdab..0713fc6da 100644 --- a/lib/shared/addon/components/cluster-driver/driver-rke/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-rke/template.hbs @@ -1,5 +1,75 @@ {{#if (or isEdit (eq step 1))}} {{#accordion-list showExpandAll=false as |al expandFn|}} + {{#unless pasteOrUpload}} + {{#accordion-list-item + title=(t 'clusterNew.rke.network.title') + detail=(t 'clusterNew.rke.network.detail') + expandOnInit=(eq mode "edit" true false) + expandAll=al.expandAll + expand=(action expandFn) + }} +
+
+ + {{new-select + classNames="form-control" + content=networkContent + localizedLabel=true + value=cluster.rancherKubernetesEngineConfig.network.plugin + disabled=isEdit + }} +
+
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ + {{input + type="text" + value=cluster.rancherKubernetesEngineConfig.services.kubeApi.serviceNodePortRange + className="form-control" + placeholder=(t 'clusterNew.rke.serviceNodePortRange.placeholder') + }} +
+
+ {{/accordion-list-item}} + {{/unless}} + {{#accordion-list-item title=(t 'clusterNew.rke.customize.label') detail=(t 'clusterNew.rke.customize.detail') @@ -43,54 +113,8 @@ value=cluster.rancherKubernetesEngineConfig.kubernetesVersion }} -
- - {{new-select - classNames="form-control" - content=networkContent - localizedLabel=true - value=cluster.rancherKubernetesEngineConfig.network.plugin - disabled=isEdit - }} -
-
- -
- -
-
- -
-
-
- -
- -
-
- -
-
@@ -136,6 +160,23 @@
+
+ {{#if cluster.rancherKubernetesEngineConfig.services.kubeApi.podSecurityPolicy}} + + {{new-select + content=model.psps + optionLabelPath='displayName' + optionValuePath='id' + prompt='clusterNew.psp.prompt' + localizedPrompt=true + value=cluster.defaultPodSecurityPolicyTemplateId + disabled=(not cluster.rancherKubernetesEngineConfig.services.kubeApi.podSecurityPolicy) + }} + {{else}} + +
{{t 'generic.none'}}
+ {{/if}} +
@@ -164,34 +205,8 @@ }}
-
- {{#if cluster.rancherKubernetesEngineConfig.services.kubeApi.podSecurityPolicy}} - - {{new-select - content=model.psps - optionLabelPath='displayName' - optionValuePath='id' - prompt='clusterNew.psp.prompt' - localizedPrompt=true - value=cluster.defaultPodSecurityPolicyTemplateId - disabled=(not cluster.rancherKubernetesEngineConfig.services.kubeApi.podSecurityPolicy) - }} - {{else}} - -
{{t 'generic.none'}}
- {{/if}} -
-
- - {{input - type="text" - value=cluster.rancherKubernetesEngineConfig.services.kubeApi.serviceNodePortRange - className="form-control" - placeholder=(t 'clusterNew.rke.serviceNodePortRange.placeholder') - }} -
{{#if (and (eq nodeWhich 'custom') (eq mode 'new'))}}
@@ -220,6 +235,22 @@
{{/if}} {{/accordion-list-item}} + + {{#if isCustom }} + {{#unless pasteOrUpload}} + {{#accordion-list-item + title=(t 'cruPrivateRegistry.title.label') + detail=(t 'cruPrivateRegistry.title.detail') + expandOnInit=(eq mode "edit" true false) + expandAll=al.expandAll + expand=(action expandFn) + }} + {{cru-private-registry + cluster=cluster + }} + {{/accordion-list-item}} + {{/unless}} + {{/if}} {{/accordion-list}} {{#unless isCustom}} @@ -426,6 +457,7 @@ {{/accordion-list-item}} + {{/accordion-list}} {{#if newNodeCount}} diff --git a/lib/shared/addon/components/cru-private-registry/component.js b/lib/shared/addon/components/cru-private-registry/component.js new file mode 100644 index 000000000..07856cbba --- /dev/null +++ b/lib/shared/addon/components/cru-private-registry/component.js @@ -0,0 +1,88 @@ +import Component from '@ember/component'; +import layout from './template'; +import { get, set, observer } from '@ember/object'; +import { alias } from '@ember/object/computed'; +import { inject as service } from '@ember/service'; +import { on } from '@ember/object/evented'; + + +const headers = [ + { + name: 'user', + classNames: ['text-center'], + translationKey: 'cruPrivateRegistry.registry.user.label', + }, + { + name: 'password', + classNames: ['text-center'], + sort: false, + translationKey: 'cruPrivateRegistry.registry.password.label', + }, + { + name: 'url', + classNames: ['text-center'], + translationKey: 'cruPrivateRegistry.registry.url.label', + }, + { + name: 'default', + classNames: ['text-center'], + translationKey: 'cruPrivateRegistry.registry.default.label', + width: 250, + }, + { + name: 'remove', + sort: false, + classNames: ['text-center'], + width: 50, + } +]; + +export default Component.extend({ + globalStore: service(), + + layout, + headers, + + configName: 'rancherKubernetesEngineConfig', + cluster: null, + config: null, + editing: true, + urlInvalid: null, + urlWarning: null, + urlError: null, + + privateRegistries: alias('config.privateRegistries'), + + init() { + this._super(...arguments); + + const config = set(this, 'config', get(this, `cluster.${ get(this, 'configName') }`)); + + if (( config.privateRegistries || [] ).length <= 0) { + set(config, 'privateRegistries', [this.newPrivateRegistry()]); + } + }, + + actions: { + addRegistry() { + get(this, 'privateRegistries').pushObject(this.newPrivateRegistry()); + }, + removeRegistry(registry) { + get(this, 'privateRegistries').removeObject(registry); + }, + }, + + defaultSet: on('init', observer('privateRegistries.@each.{isDefault}', function() { + const { privateRegistries } = this; + + if (privateRegistries.findBy('isDefault', true)) { + set(this, 'hasDefault', true); + } else { + set(this, 'hasDefault', false); + } + })), + + newPrivateRegistry(registryType = 'privateRegistry') { + return get(this, 'globalStore').createRecord({ type: registryType }); + } +}); diff --git a/lib/shared/addon/components/cru-private-registry/template.hbs b/lib/shared/addon/components/cru-private-registry/template.hbs new file mode 100644 index 000000000..e9d89ccde --- /dev/null +++ b/lib/shared/addon/components/cru-private-registry/template.hbs @@ -0,0 +1,71 @@ +{{#sortable-table + body=privateRegistries + bulkActions=false + classNames="grid sortable-table" + descending=false + headers=headers + pagingLabel="pagination.nodePool" + rowActions=false + search=false + as |sortable kind reg dt| +}} + {{#if (eq kind "row")}} + + + {{#input-or-display + editable=editing + value=reg.user + }} + {{input + class="input-sm" + type="text" + value=reg.user + }} + {{/input-or-display}} + + + {{#input-or-display + editable=editing + obfuscate=true + value=reg.password + }} + {{input + class="conceal input-sm" + type="password" + value=reg.password + }} + {{/input-or-display}} + + + {{#input-or-display + editable=editing + value=reg.url + }} + {{input-url + classNames="form-control input-sm" + isInvalid=(action (mut urlInvalid)) + urlWarning=(action (mut urlWarning)) + urlError=(action (mut urlError)) + value=reg.url + }} + {{/input-or-display}} + + + + + + + + + {{else if (eq kind "norows")}} + {{t 'cruPrivateRegistry.noData'}} + {{/if}} +{{/sortable-table}} + + \ No newline at end of file diff --git a/lib/shared/app/components/cru-private-registry/component.js b/lib/shared/app/components/cru-private-registry/component.js new file mode 100644 index 000000000..acd698ce9 --- /dev/null +++ b/lib/shared/app/components/cru-private-registry/component.js @@ -0,0 +1 @@ +export { default } from 'shared/components/cru-private-registry/component'; diff --git a/translations/en-us.yaml b/translations/en-us.yaml index 37014466b..6951cbbf5 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -927,6 +927,23 @@ cruPersistentVolumeClaim: label: Storage Class prompt: Use the default class +cruPrivateRegistry: + title: + label: Private Registries + detail: Add private registries to this cluster + noData: This cluster does not have any private registries defined + add: + label: Add Private Registry + registry: + user: + label: User + password: + label: Password + url: + label: URL + default: + label: Default Registry + cruVolume: sourcePrompt: Choose a Volume Source above... title: @@ -2108,6 +2125,8 @@ clusterNew: label: Node Port Range placeholder: e.g. 30000-32767 network: + title: Networking + detail: Configure the networking for the cluster label: Network Provider flannel: Flannel calico: Calico