mirror of https://github.com/rancher/ui.git
Split/migrate K8s template name for backwards compatibility (#799)
This commit is contained in:
parent
325a394fcb
commit
6c7d90c1ce
|
|
@ -9,15 +9,21 @@ export default Ember.Route.extend({
|
|||
|
||||
model: function(params/*, transition*/) {
|
||||
var store = this.get('store');
|
||||
var version = this.get('settings.rancherVersion');
|
||||
|
||||
let url = this.get('app.catalogEndpoint')+'/templates/'+params.template;
|
||||
if ( version )
|
||||
{
|
||||
url = Util.addQueryParam(url, 'minimumRancherVersion_lte', version);
|
||||
}
|
||||
|
||||
var dependencies = {
|
||||
tpl: store.request({url: this.get('app.catalogEndpoint')+'/templates/'+params.template}),
|
||||
tpl: store.request({url: url}),
|
||||
};
|
||||
|
||||
if ( params.upgrade )
|
||||
{
|
||||
var version = this.get('settings.rancherVersion');
|
||||
var url = this.get('app.catalogEndpoint')+'/templateversions/'+params.upgrade;
|
||||
url = this.get('app.catalogEndpoint')+'/templateversions/'+params.upgrade;
|
||||
if ( version )
|
||||
{
|
||||
url = Util.addQueryParam(url, 'minimumRancherVersion_lte', version);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ import Ember from 'ember';
|
|||
import NewOrEdit from 'ui/mixins/new-or-edit';
|
||||
import ShellQuote from 'npm:shell-quote';
|
||||
import C from 'ui/utils/constants';
|
||||
import Util from 'ui/utils/util';
|
||||
import { compare as compareVersion } from 'ui/utils/parse-version';
|
||||
|
||||
export default Ember.Component.extend(NewOrEdit, {
|
||||
k8s: Ember.inject.service(),
|
||||
projects: Ember.inject.service(),
|
||||
settings: Ember.inject.service(),
|
||||
|
||||
allTemplates: null,
|
||||
templateResource: null,
|
||||
|
|
@ -74,13 +76,18 @@ export default Ember.Component.extend(NewOrEdit, {
|
|||
}.property('versionsArray'),
|
||||
|
||||
templateChanged: function() {
|
||||
var link = this.get('selectedTemplateUrl');
|
||||
if (link) {
|
||||
var url = this.get('selectedTemplateUrl');
|
||||
if (url) {
|
||||
this.set('loading', true);
|
||||
|
||||
var version = this.get('settings.rancherVersion');
|
||||
if ( version ) {
|
||||
url = Util.addQueryParam(url, 'minimumRancherVersion_lte', version);
|
||||
}
|
||||
|
||||
var current = this.get('environmentResource.environment');
|
||||
this.get('store').request({
|
||||
url: link
|
||||
url: url
|
||||
}).then((response) => {
|
||||
if (response.questions) {
|
||||
response.questions.forEach((item) => {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
{{/if}}
|
||||
|
||||
<span>
|
||||
{{t step}}{{#if (and subCount (eq currentStep index))}} {{t 'waitOrchestration.count' sub=subStep count=subCount}}{{/if}}
|
||||
{{t step}}{{#if (and subStep subCount (eq currentStep index))}} {{t 'waitOrchestration.count' sub=subStep count=subCount}}{{/if}}
|
||||
</span>
|
||||
</li>
|
||||
{{/each}}
|
||||
|
|
|
|||
|
|
@ -192,13 +192,35 @@ var Environment = Resource.extend({
|
|||
}.property('services'),
|
||||
|
||||
externalIdInfo: function() {
|
||||
return parseExternalId(this.get('externalId'));
|
||||
let eid = this.get('externalId');
|
||||
let info = parseExternalId(eid);
|
||||
|
||||
// Migrate kubernetes -> k8s
|
||||
// 1.1.x did not send minimumRancherVersion correctly, so the catalog template
|
||||
// was changed from "kubernetes" to "k8s" so that they won't upgrade from 1.2 to 1.3
|
||||
if ( info && info.kind === C.EXTERNAL_ID.KIND_SYSTEM_CATALOG )
|
||||
{
|
||||
const base = C.EXTERNAL_ID.KIND_SYSTEM_CATALOG + C.EXTERNAL_ID.KIND_SEPARATOR + C.CATALOG.LIBRARY_KEY + C.EXTERNAL_ID.GROUP_SEPARATOR;
|
||||
let old_prefix = base + C.EXTERNAL_ID.KIND_LEGACY_KUBERNETES + C.EXTERNAL_ID.GROUP_SEPARATOR;
|
||||
let neu_prefix = base + C.EXTERNAL_ID.KIND_KUBERNETES + C.EXTERNAL_ID.GROUP_SEPARATOR;
|
||||
|
||||
if ( eid.indexOf(old_prefix) === 0 )
|
||||
{
|
||||
let neu = eid.replace(old_prefix,neu_prefix);
|
||||
console.log('Migrating Stack ' + this.get('id') + ' from ' + eid + ' to ' + neu);
|
||||
this.set('externalId', neu);
|
||||
this.save();
|
||||
return parseExternalId(neu);
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}.property('externalId'),
|
||||
|
||||
grouping: function() {
|
||||
var kind = this.get('externalIdInfo.kind');
|
||||
|
||||
if ( kind === C.EXTERNAL_ID.KIND_KUBERNETES )
|
||||
if ( kind === C.EXTERNAL_ID.KIND_KUBERNETES || kind === C.EXTERNAL_ID.KIND_LEGACY_KUBERNETES )
|
||||
{
|
||||
return C.EXTERNAL_ID.KIND_KUBERNETES;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -501,7 +501,7 @@ export default Ember.Service.extend({
|
|||
}.property('version.{minor,major}'),
|
||||
|
||||
filterSystemStack(stacks) {
|
||||
const OLD_STACK_ID = C.EXTERNAL_ID.KIND_SYSTEM + C.EXTERNAL_ID.KIND_SEPARATOR + C.EXTERNAL_ID.KIND_KUBERNETES;
|
||||
const OLD_STACK_ID = C.EXTERNAL_ID.KIND_SYSTEM + C.EXTERNAL_ID.KIND_SEPARATOR + C.EXTERNAL_ID.KIND_LEGACY_KUBERNETES;
|
||||
const NEW_STACK_PREFIX = C.EXTERNAL_ID.KIND_SYSTEM_CATALOG + C.EXTERNAL_ID.KIND_SEPARATOR + C.CATALOG.LIBRARY_KEY + C.EXTERNAL_ID.GROUP_SEPARATOR + C.EXTERNAL_ID.KIND_KUBERNETES + C.EXTERNAL_ID.GROUP_SEPARATOR;
|
||||
|
||||
var stack = (stacks||[]).filter((stack) => {
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@ const KIND_USER = 'user';
|
|||
const KIND_CATALOG = 'catalog';
|
||||
const KIND_SYSTEM = 'system';
|
||||
const KIND_SYSTEM_CATALOG = 'system-catalog';
|
||||
const KIND_KUBERNETES = 'kubernetes';
|
||||
const KIND_LEGACY_KUBERNETES = 'kubernetes';
|
||||
const KIND_KUBERNETES = 'k8s';
|
||||
const KIND_SWARM = 'swarm';
|
||||
const KIND_MESOS = 'mesos';
|
||||
const KIND_NOT_KUBERNETES = `not-${KIND_KUBERNETES}`;
|
||||
const KIND_NOT_SWARM = `not-${KIND_SWARM}`;
|
||||
const KIND_NOT_MESOS = `not-${KIND_MESOS}`;
|
||||
const KIND_NOT_KUBERNETES = `sys-${KIND_KUBERNETES}`;
|
||||
const KIND_NOT_SWARM = `sys-${KIND_SWARM}`;
|
||||
const KIND_NOT_MESOS = `sys-${KIND_MESOS}`;
|
||||
|
||||
var C = {
|
||||
COOKIE: {
|
||||
|
|
@ -25,6 +26,7 @@ var C = {
|
|||
KIND_CATALOG: KIND_CATALOG,
|
||||
KIND_SYSTEM: KIND_SYSTEM,
|
||||
KIND_SYSTEM_CATALOG: KIND_SYSTEM_CATALOG,
|
||||
KIND_LEGACY_KUBERNETES: KIND_LEGACY_KUBERNETES,
|
||||
KIND_KUBERNETES: KIND_KUBERNETES,
|
||||
KIND_SWARM: KIND_SWARM,
|
||||
KIND_MESOS: KIND_MESOS,
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ const navTree = [
|
|||
icon: 'icon icon-network',
|
||||
route: 'environments',
|
||||
ctx: [getProjectId],
|
||||
queryParams: {which: 'not-kubernetes'},
|
||||
queryParams: {which: C.EXTERNAL_ID.KIND_NOT_KUBERNETES},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -160,7 +160,7 @@ const navTree = [
|
|||
icon: 'icon icon-network',
|
||||
route: 'environments',
|
||||
ctx: [getProjectId],
|
||||
queryParams: {which: 'not-swarm'},
|
||||
queryParams: {which: C.EXTERNAL_ID.KIND_NOT_SWARM},
|
||||
},
|
||||
]
|
||||
},
|
||||
|
|
@ -188,7 +188,7 @@ const navTree = [
|
|||
icon: 'icon icon-network',
|
||||
route: 'environments',
|
||||
ctx: [getProjectId],
|
||||
queryParams: {which: 'not-mesos'},
|
||||
queryParams: {which: C.EXTERNAL_ID.KIND_NOT_MESOS},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -198,7 +198,7 @@ const navTree = [
|
|||
id: 'cattle',
|
||||
localizedLabel: 'nav.cattle.tab',
|
||||
route: 'environments',
|
||||
queryParams: {which: 'user'},
|
||||
queryParams: {which: C.EXTERNAL_ID.KIND_USER},
|
||||
ctx: [getProjectId],
|
||||
moreCurrentWhen: ['authenticated.project.waiting'],
|
||||
condition: function() { return this.get('hasProject') && !this.get('hasKubernetes') && !this.get('hasSwarm') && !this.get('hasMesos'); },
|
||||
|
|
@ -209,7 +209,7 @@ const navTree = [
|
|||
icon: 'icon icon-globe',
|
||||
route: 'environments',
|
||||
ctx: [getProjectId],
|
||||
queryParams: {which: 'all'},
|
||||
queryParams: {which: C.EXTERNAL_ID.KIND_ALL},
|
||||
},
|
||||
{divider: true},
|
||||
{
|
||||
|
|
@ -218,7 +218,7 @@ const navTree = [
|
|||
icon: 'icon icon-layers',
|
||||
route: 'environments',
|
||||
ctx: [getProjectId],
|
||||
queryParams: {which: 'user'},
|
||||
queryParams: {which: C.EXTERNAL_ID.KIND_USER},
|
||||
},
|
||||
{
|
||||
id: 'cattle-system',
|
||||
|
|
@ -226,7 +226,7 @@ const navTree = [
|
|||
icon: 'icon icon-network',
|
||||
route: 'environments',
|
||||
ctx: [getProjectId],
|
||||
queryParams: {which: 'system'},
|
||||
queryParams: {which: C.EXTERNAL_ID.KIND_SYSTEM},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export function parseExternalId(externalId) {
|
|||
|
||||
var idx = externalId.indexOf(C.EXTERNAL_ID.KIND_SEPARATOR);
|
||||
if (idx >= 0) {
|
||||
// New style kind://[group:]ido
|
||||
// New style kind://[group:]id
|
||||
out.kind = externalId.substr(0, idx);
|
||||
|
||||
var rest = externalId.substr(idx + C.EXTERNAL_ID.KIND_SEPARATOR.length);
|
||||
|
|
|
|||
Loading…
Reference in New Issue