Skip to content
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

Update DeploymentConfig controller to use getPreferredVersion #2164

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 20 additions & 12 deletions app/scripts/controllers/deploymentConfig.js
Expand Up @@ -11,6 +11,7 @@ angular.module('openshiftConsole')
function ($scope,
$filter,
$routeParams,
APIService,
BreadcrumbsService,
DataService,
DeploymentsService,
Expand Down Expand Up @@ -42,9 +43,20 @@ angular.module('openshiftConsole')
namespace: $routeParams.project
});
$scope.emptyMessage = "Loading...";
$scope.deploymentConfigsInstantiateVersion = APIService.getPreferredVersion('deploymentconfigs/instantiate');
$scope.deploymentConfigsVersion = APIService.getPreferredVersion('deploymentconfigs');
$scope.eventsVersion = APIService.getPreferredVersion('events');
$scope.horizontalPodAutoscalersVersion = APIService.getPreferredVersion('horizontalpodautoscalers');

var buildsVersion = APIService.getPreferredVersion('builds');
var imageStreamsVersion = APIService.getPreferredVersion('imagestreams');
var limitRangesVersion = APIService.getPreferredVersion('limitranges');
var replicationControllersVersion = APIService.getPreferredVersion('replicationcontrollers');

$scope.healthCheckURL = Navigate.healthCheckURL($routeParams.project,
"DeploymentConfig",
$routeParams.deploymentconfig);
$routeParams.deploymentconfig,
$scope.deploymentConfigsVersion.group);

var mostRecent = $filter('mostRecent');
var orderByDate = $filter('orderObjectsByDate');
Expand All @@ -66,15 +78,15 @@ angular.module('openshiftConsole')
});
};

DataService.get("deploymentconfigs", $routeParams.deploymentconfig, context, { errorNotification: false }).then(
DataService.get($scope.deploymentConfigsVersion, $routeParams.deploymentconfig, context, { errorNotification: false }).then(
// success
function(deploymentConfig) {
$scope.loaded = true;
$scope.deploymentConfig = deploymentConfig;
$scope.strategyParams = $filter('deploymentStrategyParams')(deploymentConfig);
updateHPAWarnings();
// If we found the item successfully, watch for changes on it
watches.push(DataService.watchObject("deploymentconfigs", $routeParams.deploymentconfig, context, function(deploymentConfig, action) {
watches.push(DataService.watchObject($scope.deploymentConfigsVersion, $routeParams.deploymentconfig, context, function(deploymentConfig, action) {
if (action === "DELETED") {
$scope.alerts["deleted"] = {
type: "warning",
Expand All @@ -98,7 +110,7 @@ angular.module('openshiftConsole')
}
);

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

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

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

watches.push(DataService.watch("builds", context, function(builds) {
watches.push(DataService.watch(buildsVersion, context, function(builds) {
$scope.builds = builds.by("metadata.name");
Logger.log("builds (subscribe)", $scope.builds);
}));

watches.push(DataService.watch({
group: "autoscaling",
resource: "horizontalpodautoscalers",
version: "v1"
}, context, function(hpa) {
watches.push(DataService.watch($scope.horizontalPodAutoscalersVersion, context, function(hpa) {
$scope.autoscalers =
HPAService.filterHPA(hpa.by("metadata.name"), 'DeploymentConfig', $routeParams.deploymentconfig);
updateHPAWarnings();
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/filters/canI.js
Expand Up @@ -24,8 +24,8 @@ angular
_.assign({}, APIService.getPreferredVersion('deployments'), {verbs: ['update', 'delete']})
],
'deploymentConfigs': [
{group: 'autoscaling', resource: 'horizontalpodautoscalers', verbs: ['create', 'update']},
{group: '', resource: 'deploymentconfigs', verbs: ['create', 'update']}
_.assign({}, APIService.getPreferredVersion('horizontalpodautoscalers'), {verbs: ['create', 'update']}),
_.assign({}, APIService.getPreferredVersion('deploymentconfigs'), {verbs: ['create', 'update']})
],
'horizontalPodAutoscalers': [
{group: 'autoscaling', resource: 'horizontalpodautoscalers', verbs: ['update', 'delete']}
Expand Down
46 changes: 23 additions & 23 deletions app/views/browse/deployment-config.html
Expand Up @@ -8,7 +8,7 @@ <h1 class="contains-actions">
<div class="pull-right dropdown" ng-if="deploymentConfig" ng-hide="!('deploymentConfigs' | canIDoAny)">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be updating the canIDoAny checks to use the same resource versions as the actions

<!-- Primary Actions -->
<button
ng-if="'deploymentconfigs/instantiate' | canI : 'create'"
ng-if="deploymentConfigsInstantiateVersion | canI : 'create'"
class="btn btn-default hidden-xs"
ng-click="startLatestDeployment()"
ng-disabled="!canDeploy()">
Expand All @@ -24,49 +24,49 @@ <h1 class="contains-actions">
class="dropdown-toggle actions-dropdown-kebab visible-xs-inline"
data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i><span class="sr-only">Actions</span></a>
<ul class="dropdown-menu dropdown-menu-right actions action-button">
<li class="visible-xs-inline" ng-class="{ disabled: !canDeploy() }" ng-if="'deploymentconfigs/instantiate' | canI : 'create'">
<li class="visible-xs-inline" ng-class="{ disabled: !canDeploy() }" ng-if="deploymentConfigsInstantiateVersion | canI : 'create'">
<a href=""
role="button"
ng-attr-aria-disabled="{{canDeploy() ? undefined : 'true'}}"
ng-class="{ 'disabled-link': !canDeploy() }"
ng-click="startLatestDeployment()">Deploy</a>
</li>
<li ng-if="'deploymentconfigs' | canI : 'update'">
<li ng-if="deploymentConfigsVersion | canI : 'update'">
<a ng-href="{{deploymentConfig | editResourceURL}}" role="button">Edit</a>
</li>
<li class="divider" ng-if="'deploymentconfigs' | canI : 'update'"></li>
<li ng-if="!deploymentConfig.spec.paused && !updatingPausedState && ('deploymentconfigs' | canI : 'update')">
<li class="divider" ng-if="deploymentConfigsVersion | canI : 'update'"></li>
<li ng-if="!deploymentConfig.spec.paused && !updatingPausedState && (deploymentConfigsVersion | canI : 'update')">
<a href="" ng-click="setPaused(true)" role="button">Pause Rollouts</a>
</li>
<li ng-if="deploymentConfig.spec.paused && !updatingPausedState && ('deploymentconfigs' | canI : 'update')">
<li ng-if="deploymentConfig.spec.paused && !updatingPausedState && (deploymentConfigsVersion | canI : 'update')">
<a href="" ng-click="setPaused(false)" role="button">Resume Rollouts</a>
</li>
<li ng-if="'deploymentconfigs' | canI : 'update'">
<li ng-if="deploymentConfigsVersion | canI : 'update'">
<a ng-href="project/{{project.metadata.name}}/attach-pvc?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}"
role="button">Add Storage</a>
</li>
<li ng-if="!autoscalers.length && ({resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'create')">
<li ng-if="!autoscalers.length && (horizontalPodAutoscalersVersion | canI : 'create')">
<!-- Create a new HPA. -->
<a ng-href="project/{{projectName}}/edit/autoscaler?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}"
role="button">Add Autoscaler</a>
</li>
<li ng-if="autoscalers.length === 1 && ({resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'update')">
<li ng-if="autoscalers.length === 1 && (horizontalPodAutoscalersVersion | canI : 'update')">
<!-- Edit an existing HPA. -->
<a ng-href="project/{{projectName}}/edit/autoscaler?kind=HorizontalPodAutoscaler&group=autoscaling&name={{autoscalers[0].metadata.name}}"
role="button">Edit Autoscaler</a>
</li>
<li ng-if="'deploymentconfigs' | canI : 'update'">
<li ng-if="deploymentConfigsVersion | canI : 'update'">
<a ng-href="project/{{projectName}}/set-limits?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}"
role="button">Edit Resource Limits</a>
</li>
<li ng-if="'deploymentconfigs' | canI : 'update'">
<li ng-if="deploymentConfigsVersion | canI : 'update'">
<a ng-href="{{healthCheckURL}}" role="button">Edit Health Checks</a>
</li>
<li ng-if="'deploymentconfigs' | canI : 'update'">
<li ng-if="deploymentConfigsVersion | canI : 'update'">
<a ng-href="{{deploymentConfig | editYamlURL}}" role="button">Edit YAML</a>
</li>
<li class="divider" ng-if="'deploymentconfigs' | canI : 'update'"></li>
<li ng-if="'deploymentconfigs' | canI : 'delete'">
<li class="divider" ng-if="deploymentConfigsVersion | canI : 'update'"></li>
<li ng-if="deploymentConfigsVersion | canI : 'delete'">
<delete-link
kind="DeploymentConfig"
resource-name="{{deploymentConfig.metadata.name}}"
Expand Down Expand Up @@ -94,7 +94,7 @@ <h1 class="contains-actions">
<span class="pficon pficon-info" aria-hidden="true"></span>
<strong>{{deploymentConfig.metadata.name}} is paused.</strong>
This will stop any new rollouts or triggers from running until resumed.
<span ng-if="!updatingPausedState && ('deploymentconfigs' | canI : 'update')" class="nowrap">
<span ng-if="!updatingPausedState && (deploymentConfigsVersion | canI : 'update')" class="nowrap">
<a href="" ng-click="setPaused(false)" role="button">Resume Rollouts</a>
</span>
</div>
Expand Down Expand Up @@ -230,19 +230,19 @@ <h3>Template</h3>
images-by-docker-reference="imagesByDockerReference"
builds="builds"
detailed="true"
add-health-check-url="{{('deploymentconfigs' | canI : 'update') ? healthCheckURL : ''}}">
add-health-check-url="{{(deploymentConfigsVersion | canI : 'update') ? healthCheckURL : ''}}">
</pod-template>
<h3>Volumes</h3>
<p ng-if="!deploymentConfig.spec.template.spec.volumes.length && !('deploymentconfigs' | canI : 'update')">
<p ng-if="!deploymentConfig.spec.template.spec.volumes.length && !(deploymentConfigsVersion | canI : 'update')">
none
</p>
<volumes
volumes="deploymentConfig.spec.template.spec.volumes"
namespace="project.metadata.name"
can-remove="'deploymentconfigs' | canI : 'update'"
can-remove="deploymentConfigsVersion | canI : 'update'"
remove-fn="removeVolume(volume)">
</volumes>
<p ng-if="'deploymentconfigs' | canI : 'update'">
<p ng-if="deploymentConfigsVersion | canI : 'update'">
<a ng-href="project/{{project.metadata.name}}/attach-pvc?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}">Add Storage</a>
<span class="action-divider" aria-hidden="true">|</span>
<a ng-href="project/{{project.metadata.name}}/add-config-volume?kind=DeploymentConfig&name={{deploymentConfig.metadata.name}}">Add Config Files</a>
Expand All @@ -261,16 +261,16 @@ <h3>Autoscaling</h3>

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

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

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