-
Notifications
You must be signed in to change notification settings - Fork 232
Service instance details configuration and edit #2237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
jeff-phillips-18:parameters
Oct 19, 2017
+1,053
−459
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,19 @@ angular.module('openshiftConsole') | |
$routeParams, | ||
APIService, | ||
BindingService, | ||
AuthorizationService, | ||
Catalog, | ||
DataService, | ||
Logger, | ||
ProjectsService, | ||
SecretsService, | ||
ServiceInstancesService) { | ||
$scope.alerts = {}; | ||
$scope.projectName = $routeParams.project; | ||
$scope.serviceInstance = null; | ||
$scope.serviceClass = null; | ||
$scope.serviceClasses = null; | ||
$scope.editDialogShown = false; | ||
|
||
$scope.breadcrumbs = [ | ||
{ | ||
|
@@ -28,9 +34,26 @@ angular.module('openshiftConsole') | |
ServiceInstancesService.deprovision($scope.serviceInstance, $scope.bindings); | ||
}; | ||
|
||
$scope.showEditDialog = function() { | ||
$scope.editDialogShown = true; | ||
}; | ||
|
||
$scope.showParameterValues = false; | ||
|
||
$scope.toggleShowParameterValues = function() { | ||
$scope.showParameterValues = !$scope.showParameterValues; | ||
}; | ||
|
||
$scope.closeEditDialog = function() { | ||
$scope.editDialogShown = false; | ||
}; | ||
|
||
var watches = []; | ||
var secretWatchers = []; | ||
var serviceClassPromise; | ||
|
||
var serviceInstanceDisplayName = $filter('serviceInstanceDisplayName'); | ||
var serviceInstanceReady = $filter('isServiceInstanceReady'); | ||
|
||
// API Versions | ||
var serviceBindingsVersion = APIService.getPreferredVersion('servicebindings'); | ||
|
@@ -42,28 +65,76 @@ angular.module('openshiftConsole') | |
}); | ||
}; | ||
|
||
var serviceClassPromise; | ||
var updateParameterData = function() { | ||
if (!$scope.serviceInstance || !$scope.parameterSchema) { | ||
return; | ||
} | ||
|
||
DataService.unwatchAll(secretWatchers); | ||
secretWatchers = []; | ||
|
||
$scope.parameterData = {}; | ||
_.each(_.keys(_.get($scope.parameterSchema, 'properties')), function(key) { | ||
$scope.parameterData[key] = $scope.parameterSchema.properties[key].default; | ||
}); | ||
|
||
$scope.parameterData = angular.extend($scope.parameterData, _.get($scope.serviceInstance, 'spec.parameters', {})); | ||
|
||
if (AuthorizationService.canI('secrets', 'get', $scope.projectName)) { | ||
_.each(_.get($scope.serviceInstance, 'spec.parametersFrom'), function (parametersSource) { | ||
secretWatchers.push(DataService.watchObject("secrets", _.get(parametersSource, 'secretKeyRef.name'), $scope.projectContext, function (secret) { | ||
try { | ||
_.extend($scope.parameterData, JSON.parse(SecretsService.decodeSecretData(secret.data)[parametersSource.secretKeyRef.key])); | ||
} catch (e) { | ||
Logger.warn('Unable to load parameters from secret ' + _.get(parametersSource, 'secretKeyRef.name'), e); | ||
} | ||
})); | ||
}); | ||
} | ||
}; | ||
|
||
var updateEditable = function() { | ||
if (!$scope.plan || !$scope.serviceClass || !$scope.serviceInstance) { | ||
return; | ||
} | ||
|
||
var updateSchema = _.get($scope.plan, 'spec.instanceUpdateParameterSchema'); | ||
var planUpdatable = (_.size(_.get(updateSchema, 'properties')) > 0) || (_.get($scope.serviceClass, 'spec.planUpdatable') && (_.size($scope.servicePlans) > 1)); | ||
|
||
$scope.editAvailable = planUpdatable && serviceInstanceReady($scope.serviceInstance) && !_.get($scope.serviceInstance, 'metadata.deletionTimestamp'); | ||
}; | ||
|
||
var updateParameterSchema = function() { | ||
$scope.parameterFormDefinition = angular.copy(_.get($scope.plan, 'spec.externalMetadata.schemas.service_instance.update.openshift_form_definition')); | ||
$scope.parameterSchema = _.get($scope.plan, 'spec.instanceCreateParameterSchema'); | ||
}; | ||
|
||
var updateServiceClass = function() { | ||
// If we've previously loaded the service class or a request is in flight, don't do anything. | ||
if ($scope.serviceClass || serviceClassPromise) { | ||
if (!$scope.serviceInstance || $scope.serviceClass || serviceClassPromise) { | ||
return; | ||
} | ||
|
||
serviceClassPromise = ServiceInstancesService.fetchServiceClassForInstance($scope.serviceInstance).then(function(serviceClass) { | ||
serviceClassPromise = ServiceInstancesService.fetchServiceClassForInstance($scope.serviceInstance).then(function (serviceClass) { | ||
$scope.serviceClass = serviceClass; | ||
$scope.displayName = serviceInstanceDisplayName($scope.serviceInstance, serviceClass); | ||
$scope.displayName = serviceInstanceDisplayName($scope.serviceInstance, $scope.serviceClass); | ||
|
||
updateBreadcrumbs(); | ||
serviceClassPromise = null; | ||
}); | ||
}; | ||
|
||
var updatePlan = function() { | ||
if (ServiceInstancesService.isCurrentPlan($scope.serviceInstance, $scope.plan)) { | ||
return; | ||
} | ||
Catalog.getServicePlans().then(function (plans) { | ||
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. When we fix the removed plans, let's use a field filter on list to get just the plans for this service class and filter removed plans client side (follow on) |
||
plans = plans.by('metadata.name'); | ||
|
||
var plansByServiceClassName = Catalog.groupPlansByServiceClassName(plans); | ||
$scope.servicePlans = plansByServiceClassName[$scope.serviceClass.metadata.name]; | ||
|
||
ServiceInstancesService.fetchServicePlanForInstance($scope.serviceInstance).then(function(plan) { | ||
$scope.plan = plan; | ||
var servicePlanName = _.get($scope.serviceInstance, 'spec.clusterServicePlanRef.name'); | ||
$scope.plan = plans[servicePlanName]; | ||
|
||
updateParameterSchema(); | ||
updateParameterData(); | ||
updateEditable(); | ||
}); | ||
}); | ||
}; | ||
|
||
|
@@ -79,7 +150,8 @@ angular.module('openshiftConsole') | |
} | ||
|
||
updateServiceClass(); | ||
updatePlan(); | ||
updateParameterData(); | ||
updateEditable(); | ||
}; | ||
|
||
ProjectsService | ||
|
@@ -106,9 +178,17 @@ angular.module('openshiftConsole') | |
details: $filter('getErrorDetails')(error) | ||
}; | ||
}); | ||
}, function(error) { | ||
$scope.loaded = true; | ||
$scope.alerts["load"] = { | ||
type: "error", | ||
message: "The service details could not be loaded.", | ||
details: $filter('getErrorDetails')(error) | ||
}; | ||
})); | ||
|
||
$scope.$on('$destroy', function(){ | ||
DataService.unwatchAll(watches); | ||
}); | ||
})); | ||
$scope.$on('$destroy', function(){ | ||
DataService.unwatchAll(watches); | ||
DataService.unwatchAll(secretWatchers); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This means that you will not be able to see that there's a parameter at all when it comes from a secret and you can't get the secret, correct?
We could possibly fill in the redacted values using
status.externalProperties.parameters
when users can't list secrets (without letting them reveal). I'm OK handling this as a follow on, however.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.
@spadgett What should we do when the user does reveal and we have redacted values for some of the parameters? Continue to show ***** for those parameters?
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 remove the "reveal" action?
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.
I think we're close enough here it should be a follow-on anyway.