Skip to content

Commit

Permalink
Update DeploymentConfig controller to use getPreferredVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminapetersen committed Sep 25, 2017
1 parent 7f87b32 commit b06a534
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 100 deletions.
29 changes: 18 additions & 11 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 @@ -46,6 +47,16 @@ angular.module('openshiftConsole')
"DeploymentConfig",
$routeParams.deploymentconfig);

$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');

var mostRecent = $filter('mostRecent');
var orderByDate = $filter('orderObjectsByDate');

Expand All @@ -66,15 +77,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 +109,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 +166,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 +181,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
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)">
<!-- 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

0 comments on commit b06a534

Please sign in to comment.