Skip to content

Commit 58d1eeb

Browse files
author
OpenShift Bot
authored
Merge pull request #2164 from benjaminapetersen/bpetersen/trello/api-groups/deployment-configs
Merged by openshift-bot
2 parents 36bd0fb + 4428773 commit 58d1eeb

File tree

5 files changed

+112
-110
lines changed

5 files changed

+112
-110
lines changed

app/scripts/controllers/deploymentConfig.js

+20-12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ angular.module('openshiftConsole')
1111
function ($scope,
1212
$filter,
1313
$routeParams,
14+
APIService,
1415
BreadcrumbsService,
1516
DataService,
1617
DeploymentsService,
@@ -42,9 +43,20 @@ angular.module('openshiftConsole')
4243
namespace: $routeParams.project
4344
});
4445
$scope.emptyMessage = "Loading...";
46+
$scope.deploymentConfigsInstantiateVersion = APIService.getPreferredVersion('deploymentconfigs/instantiate');
47+
$scope.deploymentConfigsVersion = APIService.getPreferredVersion('deploymentconfigs');
48+
$scope.eventsVersion = APIService.getPreferredVersion('events');
49+
$scope.horizontalPodAutoscalersVersion = APIService.getPreferredVersion('horizontalpodautoscalers');
50+
51+
var buildsVersion = APIService.getPreferredVersion('builds');
52+
var imageStreamsVersion = APIService.getPreferredVersion('imagestreams');
53+
var limitRangesVersion = APIService.getPreferredVersion('limitranges');
54+
var replicationControllersVersion = APIService.getPreferredVersion('replicationcontrollers');
55+
4556
$scope.healthCheckURL = Navigate.healthCheckURL($routeParams.project,
4657
"DeploymentConfig",
47-
$routeParams.deploymentconfig);
58+
$routeParams.deploymentconfig,
59+
$scope.deploymentConfigsVersion.group);
4860

4961
var mostRecent = $filter('mostRecent');
5062
var orderByDate = $filter('orderObjectsByDate');
@@ -66,15 +78,15 @@ angular.module('openshiftConsole')
6678
});
6779
};
6880

69-
DataService.get("deploymentconfigs", $routeParams.deploymentconfig, context, { errorNotification: false }).then(
81+
DataService.get($scope.deploymentConfigsVersion, $routeParams.deploymentconfig, context, { errorNotification: false }).then(
7082
// success
7183
function(deploymentConfig) {
7284
$scope.loaded = true;
7385
$scope.deploymentConfig = deploymentConfig;
7486
$scope.strategyParams = $filter('deploymentStrategyParams')(deploymentConfig);
7587
updateHPAWarnings();
7688
// If we found the item successfully, watch for changes on it
77-
watches.push(DataService.watchObject("deploymentconfigs", $routeParams.deploymentconfig, context, function(deploymentConfig, action) {
89+
watches.push(DataService.watchObject($scope.deploymentConfigsVersion, $routeParams.deploymentconfig, context, function(deploymentConfig, action) {
7890
if (action === "DELETED") {
7991
$scope.alerts["deleted"] = {
8092
type: "warning",
@@ -98,7 +110,7 @@ angular.module('openshiftConsole')
98110
}
99111
);
100112

101-
watches.push(DataService.watch("replicationcontrollers", context, function(deployments, action, deployment) {
113+
watches.push(DataService.watch(replicationControllersVersion, context, function(deployments, action, deployment) {
102114
var deploymentConfigName = $routeParams.deploymentconfig;
103115
$scope.emptyMessage = "No deployments to show";
104116
if (!action) {
@@ -155,12 +167,12 @@ angular.module('openshiftConsole')
155167

156168
// List limit ranges in this project to determine if there is a default
157169
// CPU request for autoscaling.
158-
DataService.list("limitranges", context).then(function(resp) {
170+
DataService.list(limitRangesVersion, context).then(function(resp) {
159171
limitRanges = resp.by("metadata.name");
160172
updateHPAWarnings();
161173
});
162174

163-
watches.push(DataService.watch("imagestreams", context, function(imageStreamData) {
175+
watches.push(DataService.watch(imageStreamsVersion, context, function(imageStreamData) {
164176
var imageStreams = imageStreamData.by("metadata.name");
165177
ImageStreamResolver.buildDockerRefMapForImageStreams(imageStreams, imageStreamImageRefByDockerReference);
166178
// If the dep config has been loaded already
@@ -170,16 +182,12 @@ angular.module('openshiftConsole')
170182
Logger.log("imagestreams (subscribe)", $scope.imageStreams);
171183
}));
172184

173-
watches.push(DataService.watch("builds", context, function(builds) {
185+
watches.push(DataService.watch(buildsVersion, context, function(builds) {
174186
$scope.builds = builds.by("metadata.name");
175187
Logger.log("builds (subscribe)", $scope.builds);
176188
}));
177189

178-
watches.push(DataService.watch({
179-
group: "autoscaling",
180-
resource: "horizontalpodautoscalers",
181-
version: "v1"
182-
}, context, function(hpa) {
190+
watches.push(DataService.watch($scope.horizontalPodAutoscalersVersion, context, function(hpa) {
183191
$scope.autoscalers =
184192
HPAService.filterHPA(hpa.by("metadata.name"), 'DeploymentConfig', $routeParams.deploymentconfig);
185193
updateHPAWarnings();

app/scripts/filters/canI.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ angular
2424
_.assign({}, APIService.getPreferredVersion('deployments'), {verbs: ['update', 'delete']})
2525
],
2626
'deploymentConfigs': [
27-
{group: 'autoscaling', resource: 'horizontalpodautoscalers', verbs: ['create', 'update']},
28-
{group: '', resource: 'deploymentconfigs', verbs: ['create', 'update']}
27+
_.assign({}, APIService.getPreferredVersion('horizontalpodautoscalers'), {verbs: ['create', 'update']}),
28+
_.assign({}, APIService.getPreferredVersion('deploymentconfigs'), {verbs: ['create', 'update']})
2929
],
3030
'horizontalPodAutoscalers': [
3131
{group: 'autoscaling', resource: 'horizontalpodautoscalers', verbs: ['update', 'delete']}

app/views/browse/deployment-config.html

+23-23
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h1 class="contains-actions">
88
<div class="pull-right dropdown" ng-if="deploymentConfig" ng-hide="!('deploymentConfigs' | canIDoAny)">
99
<!-- Primary Actions -->
1010
<button
11-
ng-if="'deploymentconfigs/instantiate' | canI : 'create'"
11+
ng-if="deploymentConfigsInstantiateVersion | canI : 'create'"
1212
class="btn btn-default hidden-xs"
1313
ng-click="startLatestDeployment()"
1414
ng-disabled="!canDeploy()">
@@ -24,49 +24,49 @@ <h1 class="contains-actions">
2424
class="dropdown-toggle actions-dropdown-kebab visible-xs-inline"
2525
data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i><span class="sr-only">Actions</span></a>
2626
<ul class="dropdown-menu dropdown-menu-right actions action-button">
27-
<li class="visible-xs-inline" ng-class="{ disabled: !canDeploy() }" ng-if="'deploymentconfigs/instantiate' | canI : 'create'">
27+
<li class="visible-xs-inline" ng-class="{ disabled: !canDeploy() }" ng-if="deploymentConfigsInstantiateVersion | canI : 'create'">
2828
<a href=""
2929
role="button"
3030
ng-attr-aria-disabled="{{canDeploy() ? undefined : 'true'}}"
3131
ng-class="{ 'disabled-link': !canDeploy() }"
3232
ng-click="startLatestDeployment()">Deploy</a>
3333
</li>
34-
<li ng-if="'deploymentconfigs' | canI : 'update'">
34+
<li ng-if="deploymentConfigsVersion | canI : 'update'">
3535
<a ng-href="{{deploymentConfig | editResourceURL}}" role="button">Edit</a>
3636
</li>
37-
<li class="divider" ng-if="'deploymentconfigs' | canI : 'update'"></li>
38-
<li ng-if="!deploymentConfig.spec.paused && !updatingPausedState && ('deploymentconfigs' | canI : 'update')">
37+
<li class="divider" ng-if="deploymentConfigsVersion | canI : 'update'"></li>
38+
<li ng-if="!deploymentConfig.spec.paused && !updatingPausedState && (deploymentConfigsVersion | canI : 'update')">
3939
<a href="" ng-click="setPaused(true)" role="button">Pause Rollouts</a>
4040
</li>
41-
<li ng-if="deploymentConfig.spec.paused && !updatingPausedState && ('deploymentconfigs' | canI : 'update')">
41+
<li ng-if="deploymentConfig.spec.paused && !updatingPausedState && (deploymentConfigsVersion | canI : 'update')">
4242
<a href="" ng-click="setPaused(false)" role="button">Resume Rollouts</a>
4343
</li>
44-
<li ng-if="'deploymentconfigs' | canI : 'update'">
44+
<li ng-if="deploymentConfigsVersion | canI : 'update'">
4545
<a ng-href="project/{{project.metadata.name}}/attach-pvc?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}"
4646
role="button">Add Storage</a>
4747
</li>
48-
<li ng-if="!autoscalers.length && ({resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'create')">
48+
<li ng-if="!autoscalers.length && (horizontalPodAutoscalersVersion | canI : 'create')">
4949
<!-- Create a new HPA. -->
5050
<a ng-href="project/{{projectName}}/edit/autoscaler?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}"
5151
role="button">Add Autoscaler</a>
5252
</li>
53-
<li ng-if="autoscalers.length === 1 && ({resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'update')">
53+
<li ng-if="autoscalers.length === 1 && (horizontalPodAutoscalersVersion | canI : 'update')">
5454
<!-- Edit an existing HPA. -->
5555
<a ng-href="project/{{projectName}}/edit/autoscaler?kind=HorizontalPodAutoscaler&group=autoscaling&name={{autoscalers[0].metadata.name}}"
5656
role="button">Edit Autoscaler</a>
5757
</li>
58-
<li ng-if="'deploymentconfigs' | canI : 'update'">
58+
<li ng-if="deploymentConfigsVersion | canI : 'update'">
5959
<a ng-href="project/{{projectName}}/set-limits?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}"
6060
role="button">Edit Resource Limits</a>
6161
</li>
62-
<li ng-if="'deploymentconfigs' | canI : 'update'">
62+
<li ng-if="deploymentConfigsVersion | canI : 'update'">
6363
<a ng-href="{{healthCheckURL}}" role="button">Edit Health Checks</a>
6464
</li>
65-
<li ng-if="'deploymentconfigs' | canI : 'update'">
65+
<li ng-if="deploymentConfigsVersion | canI : 'update'">
6666
<a ng-href="{{deploymentConfig | editYamlURL}}" role="button">Edit YAML</a>
6767
</li>
68-
<li class="divider" ng-if="'deploymentconfigs' | canI : 'update'"></li>
69-
<li ng-if="'deploymentconfigs' | canI : 'delete'">
68+
<li class="divider" ng-if="deploymentConfigsVersion | canI : 'update'"></li>
69+
<li ng-if="deploymentConfigsVersion | canI : 'delete'">
7070
<delete-link
7171
kind="DeploymentConfig"
7272
resource-name="{{deploymentConfig.metadata.name}}"
@@ -94,7 +94,7 @@ <h1 class="contains-actions">
9494
<span class="pficon pficon-info" aria-hidden="true"></span>
9595
<strong>{{deploymentConfig.metadata.name}} is paused.</strong>
9696
This will stop any new rollouts or triggers from running until resumed.
97-
<span ng-if="!updatingPausedState && ('deploymentconfigs' | canI : 'update')" class="nowrap">
97+
<span ng-if="!updatingPausedState && (deploymentConfigsVersion | canI : 'update')" class="nowrap">
9898
<a href="" ng-click="setPaused(false)" role="button">Resume Rollouts</a>
9999
</span>
100100
</div>
@@ -230,19 +230,19 @@ <h3>Template</h3>
230230
images-by-docker-reference="imagesByDockerReference"
231231
builds="builds"
232232
detailed="true"
233-
add-health-check-url="{{('deploymentconfigs' | canI : 'update') ? healthCheckURL : ''}}">
233+
add-health-check-url="{{(deploymentConfigsVersion | canI : 'update') ? healthCheckURL : ''}}">
234234
</pod-template>
235235
<h3>Volumes</h3>
236-
<p ng-if="!deploymentConfig.spec.template.spec.volumes.length && !('deploymentconfigs' | canI : 'update')">
236+
<p ng-if="!deploymentConfig.spec.template.spec.volumes.length && !(deploymentConfigsVersion | canI : 'update')">
237237
none
238238
</p>
239239
<volumes
240240
volumes="deploymentConfig.spec.template.spec.volumes"
241241
namespace="project.metadata.name"
242-
can-remove="'deploymentconfigs' | canI : 'update'"
242+
can-remove="deploymentConfigsVersion | canI : 'update'"
243243
remove-fn="removeVolume(volume)">
244244
</volumes>
245-
<p ng-if="'deploymentconfigs' | canI : 'update'">
245+
<p ng-if="deploymentConfigsVersion | canI : 'update'">
246246
<a ng-href="project/{{project.metadata.name}}/attach-pvc?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}">Add Storage</a>
247247
<span class="action-divider" aria-hidden="true">|</span>
248248
<a ng-href="project/{{project.metadata.name}}/add-config-volume?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}">Add Config Files</a>
@@ -261,16 +261,16 @@ <h3>Autoscaling</h3>
261261

262262
<!-- If the CPU request is missing, add an action to set one. -->
263263
<a ng-href="project/{{projectName}}/set-limits?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}"
264-
ng-if="warning.reason === 'NoCPURequest' && ('deploymentconfigs' | canI : 'update')"
264+
ng-if="warning.reason === 'NoCPURequest' && (deploymentConfigsVersion | canI : 'update')"
265265
role="button">Edit Resource
266266
<span ng-if="!('cpu' | isRequestCalculated : project)">Requests and</span> Limits</a>
267267
</div>
268268

269269
<!-- Create autoscaler -->
270270
<div ng-if="!autoscalers.length">
271-
<a ng-if="{resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'create'" ng-href="project/{{projectName}}/edit/autoscaler?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}"
271+
<a ng-if="horizontalPodAutoscalersVersion | canI : 'create'" ng-href="project/{{projectName}}/edit/autoscaler?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}"
272272
role="button">Add Autoscaler</a>
273-
<span ng-if="!({resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'create')">Autoscaling is not enabled. There are no autoscalers for this deployment config.</span>
273+
<span ng-if="!(horizontalPodAutoscalersVersion | canI : 'create')">Autoscaling is not enabled. There are no autoscalers for this deployment config.</span>
274274
</div>
275275

276276
<!-- HPA details -->
@@ -347,7 +347,7 @@ <h3>Triggers</h3>
347347
<uib-tab-heading>Environment</uib-tab-heading>
348348
<edit-environment-variables api-object="deploymentConfig"></edit-environment-variables>
349349
</uib-tab>
350-
<uib-tab active="selectedTab.events" ng-if="'events' | canI : 'watch'">
350+
<uib-tab active="selectedTab.events" ng-if="eventsVersion | canI : 'watch'">
351351
<uib-tab-heading>Events</uib-tab-heading>
352352
<events api-objects="[ deploymentConfig ]" project-context="projectContext" ng-if="selectedTab.events"></events>
353353
</uib-tab>

0 commit comments

Comments
 (0)