@@ -73,18 +73,36 @@ angular.module('openshiftConsole')
73
73
DataService . unwatchAll ( secretWatchers ) ;
74
74
secretWatchers = [ ] ;
75
75
76
+ $scope . allowParametersReveal = AuthorizationService . canI ( 'secrets' , 'get' , $scope . projectName ) ;
76
77
$scope . parameterData = { } ;
77
- _ . each ( _ . keys ( _ . get ( $scope . parameterSchema , 'properties' ) ) , function ( key ) {
78
- $scope . parameterData [ key ] = $scope . parameterSchema . properties [ key ] . default ;
78
+ $scope . opaqueParameterKeys = [ ] ;
79
+
80
+ // Set defaults for schema values
81
+ var defaultValue = $scope . allowParametersReveal ? '' : '*****' ;
82
+ _ . each ( _ . keys ( _ . get ( $scope . parameterSchema , 'properties' ) ) , function ( key ) {
83
+ $scope . parameterData [ key ] = defaultValue ;
79
84
} ) ;
80
85
81
- $scope . parameterData = angular . extend ( $scope . parameterData , _ . get ( $scope . serviceInstance , 'spec.parameters' , { } ) ) ;
86
+ // Get the current status's parameter values
87
+ var statusParameters = _ . get ( $scope . serviceInstance , 'status.externalProperties.parameters' , { } ) ;
88
+ _ . each ( _ . keys ( statusParameters ) , function ( key ) {
89
+ if ( statusParameters [ key ] === '<redacted>' ) {
90
+ $scope . parameterData [ key ] = '*****' ;
91
+ } else {
92
+ $scope . parameterData [ key ] = statusParameters [ key ] ;
93
+ $scope . opaqueParameterKeys . push ( key ) ;
94
+ }
95
+ } ) ;
82
96
83
- if ( AuthorizationService . canI ( 'secrets' , 'get' , $scope . projectName ) ) {
97
+ // Fill in the secret values if they are available to the user
98
+ if ( $scope . allowParametersReveal ) {
99
+ // Get the data from each secret
84
100
_ . each ( _ . get ( $scope . serviceInstance , 'spec.parametersFrom' ) , function ( parametersSource ) {
85
101
secretWatchers . push ( DataService . watchObject ( "secrets" , _ . get ( parametersSource , 'secretKeyRef.name' ) , $scope . projectContext , function ( secret ) {
86
102
try {
87
- _ . extend ( $scope . parameterData , JSON . parse ( SecretsService . decodeSecretData ( secret . data ) [ parametersSource . secretKeyRef . key ] ) ) ;
103
+ var secretData = JSON . parse ( SecretsService . decodeSecretData ( secret . data ) [ parametersSource . secretKeyRef . key ] ) ;
104
+ // TODO: Only include fields from the secret that are part of the schema
105
+ _ . extend ( $scope . parameterData , secretData ) ;
88
106
} catch ( e ) {
89
107
Logger . warn ( 'Unable to load parameters from secret ' + _ . get ( parametersSource , 'secretKeyRef.name' ) , e ) ;
90
108
}
@@ -107,6 +125,7 @@ angular.module('openshiftConsole')
107
125
var updateParameterSchema = function ( ) {
108
126
$scope . parameterFormDefinition = angular . copy ( _ . get ( $scope . plan , 'spec.externalMetadata.schemas.service_instance.update.openshift_form_definition' ) ) ;
109
127
$scope . parameterSchema = _ . get ( $scope . plan , 'spec.instanceCreateParameterSchema' ) ;
128
+ updateParameterData ( ) ;
110
129
} ;
111
130
112
131
var updateServiceClass = function ( ) {
@@ -132,7 +151,6 @@ angular.module('openshiftConsole')
132
151
$scope . plan = plans [ servicePlanName ] ;
133
152
134
153
updateParameterSchema ( ) ;
135
- updateParameterData ( ) ;
136
154
updateEditable ( ) ;
137
155
} ) ;
138
156
} ) ;
0 commit comments