Skip to content

Commit

Permalink
Merge pull request #966 from jhadvig/dc_details
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Dec 7, 2016
2 parents a9f4523 + 8d402e9 commit 8fd9c66
Show file tree
Hide file tree
Showing 13 changed files with 509 additions and 292 deletions.
10 changes: 5 additions & 5 deletions app/scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ window.OPENSHIFT_CONSTANTS = {
"creating_secrets": "dev_guide/secrets.html#creating-and-using-secrets",
"storage_classes": "install_config/persistent_storage/dynamically_provisioning_pvs.html",
"selector_label": "install_config/persistent_storage/selector_label_binding.html",
"rolling_strategy": "dev_guide/deployments.html#rolling-strategy",
"recreate_strategy": "dev_guide/deployments.html#recreate-strategy",
"custom_strategy": "dev_guide/deployments.html#custom-strategy",
"lifecycle_hooks": "dev_guide/deployments.html#lifecycle-hooks",
"new_pod_exec": "dev_guide/deployments.html#pod-based-lifecycle-hook",
"rolling_strategy": "dev_guide/deployments/deployment_strategies.html#rolling-strategy",
"recreate_strategy": "dev_guide/deployments/deployment_strategies.html#recreate-strategy",
"custom_strategy": "dev_guide/deployments/deployment_strategies.html#custom-strategy",
"lifecycle_hooks": "dev_guide/deployments/deployment_strategies.html#lifecycle-hooks",
"new_pod_exec": "dev_guide/deployments/deployment_strategies.html#pod-based-lifecycle-hook",
"authorization": "architecture/additional_concepts/authorization.html",
"roles": "architecture/additional_concepts/authorization.html#roles",
"service_accounts": "dev_guide/service_accounts.html",
Expand Down
1 change: 1 addition & 0 deletions app/scripts/controllers/deploymentConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ angular.module('openshiftConsole')
function(deploymentConfig) {
$scope.loaded = true;
$scope.deploymentConfig = deploymentConfig;
$scope.strategyParams = $filter('deploymentStrategyParams')(deploymentConfig);
updateHPAWarnings();
copyDeploymentConfigAndEnsureEnv(deploymentConfig);
$scope.saveEnvVars = function() {
Expand Down
19 changes: 17 additions & 2 deletions app/scripts/directives/lifecycleHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

angular.module("openshiftConsole")

.directive("lifecycleHook", function() {
.directive("editLifecycleHook", function() {
return {
restrict: 'E',
scope: {
Expand All @@ -12,7 +12,7 @@ angular.module("openshiftConsole")
availableContainers: "=",
namespace: "="
},
templateUrl: 'views/directives/lifecycle-hook.html',
templateUrl: 'views/directives/edit-lifecycle-hook.html',
controller: function($scope) {
$scope.view = {
isDisabled: false
Expand Down Expand Up @@ -130,4 +130,19 @@ angular.module("openshiftConsole")
});
}
};
})
.directive("lifecycleHook", function($filter) {
return {
restrict: 'E',
scope: {
deploymentConfig: '=',
type: '@' // "pre", "mid", or "post"
},
templateUrl: 'views/directives/lifecycle-hook.html',
link: function($scope) {
$scope.$watch('deploymentConfig', function(deploymentConfig) {
$scope.strategyParams = $filter('deploymentStrategyParams')(deploymentConfig);
});
}
};
});
15 changes: 15 additions & 0 deletions app/scripts/filters/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,21 @@ angular.module('openshiftConsole')
return 'PAUSED_PENDING_INPUT' === stage.status;
};
})
.filter('deploymentStrategyParams', function () {
return function(deploymentConfig) {
var strategy = _.get(deploymentConfig, 'spec.strategy.type');
switch (strategy) {
case 'Recreate':
return _.get(deploymentConfig, 'spec.strategy.recreateParams', {});
case 'Rolling':
return _.get(deploymentConfig, 'spec.strategy.rollingParams', {});
case 'Custom':
return _.get(deploymentConfig, 'spec.strategy.customParams', {});
default:
return null;
}
};
})
.filter('humanizeKind', function (startCaseFilter) {
// Changes "ReplicationController" to "replication controller".
// If useTitleCase, returns "Replication Controller".
Expand Down
2 changes: 1 addition & 1 deletion app/styles/_components.less
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
}
}

code.probe-command {
code.command {
// Use inline-block style to prevent trailing whitespace from being
// highlighted with a background color. The extra whitespace is difficult to
// avoid due to use of `ng-repeat` and `truncate-long-text`.
Expand Down
45 changes: 33 additions & 12 deletions app/views/browse/deployment-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,21 @@ <h3>Configuration</h3>
deployment="deploymentConfig"></replicas>
<span ng-if="autoscalers.length">(autoscaled)</span>
</dd>
<div ng-if="deploymentConfig.spec.strategy.type">
<dt>Strategy:</dt>
<dd>{{deploymentConfig.spec.strategy.type}}</dd>
</div>
<div ng-if="deploymentConfig.spec.strategy.rollingParams">
<dt>Update Period:</dt>
<dd>{{deploymentConfig.spec.strategy.rollingParams.updatePeriodSeconds}} sec</dd>
<dt>Interval:</dt>
<dd>{{deploymentConfig.spec.strategy.rollingParams.intervalSeconds}} sec</dd>

<dt ng-if-start="deploymentConfig.spec.strategy.type">Strategy:</dt>
<dd ng-if-end>{{deploymentConfig.spec.strategy.type}}</dd>

<div ng-if="deploymentConfig.spec.strategy.rollingParams || deploymentConfig.spec.strategy.recreateParams">
<dt>Timeout:</dt>
<dd>{{deploymentConfig.spec.strategy.rollingParams.timeoutSeconds}} sec</dd>
<dd>{{strategyParams.timeoutSeconds}} sec</dd>
<dt ng-if-start="deploymentConfig.spec.strategy.rollingParams">Update Period:</dt>
<dd>{{strategyParams.updatePeriodSeconds}} sec</dd>
<dt>Interval:</dt>
<dd>{{strategyParams.intervalSeconds}} sec</dd>
<dt>Max Unavailable:</dt>
<dd>{{deploymentConfig.spec.strategy.rollingParams.maxUnavailable}}</dd>
<dd>{{strategyParams.maxUnavailable}}</dd>
<dt>Max Surge:</dt>
<dd>{{deploymentConfig.spec.strategy.rollingParams.maxSurge}}</dd>
<dd ng-if-end>{{strategyParams.maxSurge}}</dd>
</div>
<!-- TODO: Surface the parameters for the recreate and custom strategies -->
</dl>
Expand Down Expand Up @@ -198,6 +198,27 @@ <h3>Autoscaling</h3>
</div>
</div>

<div class="col-lg-6" ng-if="deploymentConfig.spec.strategy.type !== 'Custom'">
<h3>
Hooks
<span class="learn-more-inline">
<a ng-href="{{'lifecycle_hooks' | helpLink}}" target="_blank">Learn More&nbsp;<i class="fa fa-external-link" aria-hidden="true"></i></a>
</span>
</h3>
<div ng-if="strategyParams.pre">
<lifecycle-hook deployment-config="deploymentConfig" type="pre"></lifecycle-hook>
</div>
<div ng-if="strategyParams.mid">
<lifecycle-hook deployment-config="deploymentConfig" type="mid"></lifecycle-hook>
</div>
<div ng-if="strategyParams.post">
<lifecycle-hook deployment-config="deploymentConfig" type="post"></lifecycle-hook>
</div>
<div ng-if="!strategyParams.pre && !strategyParams.mid && !strategyParams.post">
none
</div>
</div>

<div class="col-lg-6">
<h3>Triggers</h3>
<dl class="dl-horizontal left">
Expand Down
2 changes: 1 addition & 1 deletion app/views/directives/_probe.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
GET {{probe.httpGet.path || '/'}} on port {{probe.httpGet.port || 'unknown'}}
</span>
<span ng-if="probe.exec.command">
<code class="probe-command">
<code class="command">
<span ng-repeat="arg in probe.exec.command">
<truncate-long-text
content="arg"
Expand Down
133 changes: 133 additions & 0 deletions app/views/directives/edit-lifecycle-hook.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<ng-form name="editForm">
<div ng-switch="type">
<div class="help-block" ng-switch-when="pre">Pre hooks execute before the deployment begins.</div>
<div class="help-block" ng-switch-when="mid">Mid hooks execute after the previous deployment is scaled down to zero and before the first pod of the new deployment is created.</div>
<div class="help-block" ng-switch-when="post">Post hooks execute after the deployment strategy completes.</div>
</div>

<div class="gutter-top" ng-if="hookParams">
<fieldset ng-disabled="view.isDisabled">

<div class="form-group">
<label for="actionType" class="required">Lifecycle Action</label><br/>
<div class="radio">
<label class="radio-inline">
<input type="radio"
name="{{type}}-action-newpod"
ng-model="action.type"
value="execNewPod"
aria-describedby="action-help">
Run a specific command in a new pod
</label>
<label class="radio-inline">
<input type="radio"
name="{{type}}-action-images"
ng-model="action.type"
value="tagImages"
aria-describedby="action-help">
Tag image if the deployment succeeds
</label>
</div>
<div id="action-help" class="help-block">
<span ng-if="action.type === 'execNewPod'">Runs a command in a new pod using the container from the deployment template. You can add additional environment variables and volumes.</span>
<span ng-if="action.type === 'tagImages'">Tags the current image as an image stream tag if the deployment succeeds.</span>
<a href="{{'new_pod_exec' | helpLink}}" aria-hidden="true" target="_blank"><span class="learn-more-inline">Learn More&nbsp;<i class="fa fa-external-link"></i></span></a>
</div>
</div>

<div ng-if="action.type === 'execNewPod'">
<div class="form-group">
<label class="required">Container Name</label>
<ui-select ng-model="hookParams.execNewPod.containerName" required>
<ui-select-match>{{$select.selected}}</ui-select-match>
<ui-select-choices repeat="container in (availableContainers | filter : $select.search)" ng-disabled="view.isDisabled">
<div ng-bind-html="container | highlight : $select.search"></div>
</ui-select-choices>
</ui-select>
</div>

<div class="form-group">
<label class="required">Command</label>
<edit-command args="hookParams.execNewPod.command" is-required="true"></edit-command>
</div>

<div class="form-group">
<label>Environment Variables</label>
<key-value-editor
entries="hookParams.execNewPod.env"
key-validator="[a-zA-Z_][a-zA-Z0-9_]*"
key-validator-error-tooltip="A valid environment variable name is an alphanumeric (a-z and 0-9) string beginning with a letter that may contain underscores."
add-row-link="Add environment variable"></key-value-editor>
<div class="help-block">
Environment variables to supply to the hook pod's container.
</div>
</div>

<div class="form-group">
<label>Volumes</label>
<ui-select multiple placeholder="Select volume" ng-model="hookParams.execNewPod.volumes" ng-disabled="view.isDisabled">
<ui-select-match>{{$item}}</ui-select-match>
<ui-select-choices repeat="volume in availableVolumes | filter : $select.search">
<div ng-bind-html="volume | highlight : $select.search"></div>
</ui-select-choices>
</ui-select>
<div class="help-block">
List of named volumes to copy to the hook pod.
</div>
</div>
</div>

<div ng-if="action.type === 'tagImages'">
<div ng-repeat="tagImage in hookParams.tagImages">
<div ng-if="hookParams.tagImages.length === 1">
<div class="form-group">
<label class="required">Container Name</label>
<ui-select ng-model="tagImage.containerName" ng-disabled="view.isDisabled" required>
<ui-select-match>{{$select.selected}}</ui-select-match>
<ui-select-choices repeat="container in (availableContainers | filter : $select.search)">
<div ng-bind-html="container | highlight : $select.search"></div>
</ui-select-choices>
</ui-select>
<div class="help-block">
Use the image for this container as the source of the tag.
</div>
</div>
<div class="form-group">
<label class="required">Tag As</label>
<istag-select model="istagHook" allow-custom-tag="true" select-disabled="view.isDisabled"></istag-select>
</div>
</div>

<div class="read-only-tag-image" ng-if="hookParams.tagImages.length > 1">
<p class="read-only-info" ng-if="$first">
<span class="pficon pficon-info" aria-hidden="true"></span>
More than one image tag is defined. To change image tags, use the YAML editor.
</p>
{{tagImage.containerName}}&nbsp;&rarr;&nbsp;{{tagImage.to.namespace || namespace}}/{{tagImage.to.name}}
</div>
</div>
</div>

<div class="form-group failure-policy">
<label class="required picker-label">Failure Policy</label>
<ui-select ng-model="hookParams.failurePolicy" search-enabled="false" ng-disabled="view.isDisabled">
<ui-select-match>{{$select.selected}}</ui-select-match>
<ui-select-choices repeat="failurePolicyTypes in lifecycleHookFailurePolicyTypes">
{{failurePolicyTypes}}
</ui-select-choices>
</ui-select>

<div ng-switch="hookParams.failurePolicy">
<div class="help-block" ng-switch-when="Retry">Retry the hook until it succeeds.</div>
<div class="help-block" ng-switch-when="Abort">Fail the deployment if the hook fails.</div>
<div class="help-block" ng-switch-when="Ignore">Ignore hook failures and continue the deployment.</div>
</div>
</div>
</fieldset>
</div>

<span>
<a href="" role="button" ng-if="!hookParams" ng-click="addHook()">Add {{type}} lifecycle hook</a>
<a href="" role="button" ng-if="hookParams" ng-click="removeHook()">Remove {{type}} lifecycle hook</a>
</span>
</ng-form>
Loading

0 comments on commit 8fd9c66

Please sign in to comment.