-
Notifications
You must be signed in to change notification settings - Fork 48
Catalog handling to filter plans/services in case of cross consumption #207
Changes from all commits
80615d7
13f961e
0cbc78d
51dadf9
f0eb52e
cad8ee2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,8 +180,14 @@ module.exports = Object.freeze({ | |
| K8S: 'kubernetes' | ||
| }, | ||
|
|
||
| PLATFORM_ALIAS_MAPPINGS: { | ||
| 'cf': 'cloudfoundry', | ||
| 'k8s': 'kubernetes' | ||
| }, | ||
|
|
||
| PLATFORM_MANAGER: { | ||
| 'cloudfoundry': 'CfPlatformManager' | ||
| 'cloudfoundry': 'CfPlatformManager', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of duping, would it rather make sense to set PLATFORM_ALIAS in context at the top of broker processing? that way we always access the manager class via the alias?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have change this and removed the duped ones. Have handled that in the |
||
| 'kubernetes': 'K8sPlatformManager' | ||
| }, | ||
|
|
||
| AGENT: { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,6 @@ class ServiceBrokerApiController extends BaseController { | |
| apiVersion(req, res) { | ||
| /* jshint unused:false */ | ||
| const minVersion = CONST.SF_BROKER_API_VERSION_MIN; | ||
| const minCloudControllerApiVersion = '2.57.0'; | ||
| const version = _.get(req.headers, 'x-broker-api-version', '1.0'); | ||
| return Promise | ||
| .try(() => { | ||
|
|
@@ -34,20 +33,13 @@ class ServiceBrokerApiController extends BaseController { | |
| } else { | ||
| throw new PreconditionFailed(`At least Broker API version ${minVersion} is required.`); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The below ensures that if the calls from CF are coming in, then for the dependencies of SF on CF are checked via this. This might be true always, but nevertheless a check that could help in rarest of scenarios. Obviously if we are never going to increase the version of minCloudControllerApiVersion & we for sure know CF is already upgraded above this version then this check is unnecessary. Nevertheless worth a discussion before removal.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Post discussion, this is not needed. Keeping this comment for history.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure. |
||
| return this.cloudController | ||
| .getApiVersion() | ||
| .then(apiVersion => { | ||
| if (utils.compareVersions(apiVersion, minCloudControllerApiVersion) < 0) { | ||
| throw new PreconditionFailed(`At least Cloud Controller API version ${minCloudControllerApiVersion} is required.`); | ||
| } | ||
| }); | ||
| }) | ||
| .throw(new ContinueWithNext()); | ||
| } | ||
|
|
||
| getCatalog(req, res) { | ||
| /* jshint unused:false */ | ||
| res.status(200).json(catalog); | ||
| res.status(200).json(this.fabrik.getPlatformManager(req.params.platform).getCatalog(catalog)); | ||
| } | ||
|
|
||
| putInstance(req, res) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| 'use strict'; | ||
|
|
||
| const BasePlatformManager = require('./BasePlatformManager'); | ||
| const _ = require('lodash'); | ||
|
|
||
| class K8sPlatformManager extends BasePlatformManager { | ||
| constructor(platform) { | ||
| super(platform); | ||
| this.platform = platform; | ||
| } | ||
|
|
||
| getCatalog(catalog) { | ||
| const modifiedCatalog = _.cloneDeep(catalog); | ||
| const platform = this.platform; | ||
| _.remove(modifiedCatalog.services, function (service) { | ||
| _.remove(service.plans, function (plan) { | ||
| return !_.includes(_.get(plan, 'supported_platform'), platform); | ||
| }); | ||
| return !_.includes(_.get(service, 'supported_platform'), platform); | ||
| }); | ||
| return modifiedCatalog; | ||
| } | ||
|
|
||
| postInstanceProvisionOperations(options) { | ||
| /* jshint unused:false */ | ||
| } | ||
|
|
||
| preInstanceDeleteOperations(options) { | ||
| /* jshint unused:false */ | ||
| } | ||
|
|
||
| postInstanceUpdateOperations(options) { | ||
| /* jshint unused:false */ | ||
| } | ||
|
|
||
| ensureTenantId(options) { | ||
| /* jshint unused:false */ | ||
| } | ||
|
|
||
| } | ||
| module.exports = K8sPlatformManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe its better to have a new plan to have support for k8s and leave the current one's for cf as the plan name in k8s has to be in different format ?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will not be any new plan. The same existing BOSH plans will be shown for K8S as well.