Skip to content

Commit

Permalink
fix(bake/oracle): Added extendedAttributes (#6627)
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyongzhang authored and anotherchrisberry committed Mar 1, 2019
1 parent 5bf6045 commit 0cdcb1e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 6 deletions.
38 changes: 38 additions & 0 deletions app/scripts/modules/oracle/src/pipeline/stages/bake/bakeStage.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,44 @@
<stage-config-field label="Var File Name" help-key="pipeline.config.bake.varFileName">
<input type="text" class="form-control input-sm" ng-model="stage.varFileName" />
</stage-config-field>
<stage-config-field label="Extended Attributes" help-key="pipeline.config.bake.extendedAttributes">
<table class="table table-condensed packed">
<thead>
<tr>
<th style="width:40%">Key</th>
<th style="width:60%">Value</th>
<th class="text-right">Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(key,value) in stage.extendedAttributes">
<td>
<strong class="small">{{key}}</strong>
</td>
<td>
<input
type="text"
ng-model="stage.extendedAttributes[key]"
value="{{value}}"
class="form-control input-sm"
/>
</td>
<td class="text-right">
<a class="small" href ng-click="bakeStageCtrl.removeExtendedAttribute(key)">Remove</a>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="7">
<button class="btn btn-block btn-sm add-new" ng-click="bakeStageCtrl.addExtendedAttribute()">
<span class="glyphicon glyphicon-plus-sign"></span> Add Extended Attribute
</button>
</td>
</tr>
</tfoot>
</table>
</stage-config-field>
<stage-config-field label="Upgrade" help-key="oracle.pipeline.config.bake.upgrade">
<label class="checkbox-inline">
<input type="checkbox" ng-model="stage.upgrade" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const angular = require('angular');

import { AccountService, AuthenticationService, BakeryReader, Registry } from '@spinnaker/core';
import { AccountService, AuthenticationService, BakeryReader, Registry, PipelineTemplates } from '@spinnaker/core';

module.exports = angular
.module('spinnaker.oracle.pipeline.stage.bakeStage', [require('./bakeExecutionDetails.controller').name])
Expand Down Expand Up @@ -30,7 +30,8 @@ module.exports = angular
.controller('oracleBakeStageCtrl', [
'$scope',
'$q',
function($scope, $q) {
'$uibModal',
function($scope, $q, $uibModal) {
const provider = 'oracle';

if (!$scope.stage.cloudProvider) {
Expand All @@ -41,10 +42,7 @@ module.exports = angular
$scope.stage = {};
}

if (!$scope.stage.extended_attributes) {
// eslint-disable-next-line @typescript-eslint/camelcase
$scope.stage.extended_attributes = {};
}
$scope.stage.extendedAttributes = $scope.stage.extendedAttributes || {};

if (!$scope.stage.user) {
$scope.stage.user = AuthenticationService.getAuthenticatedUser().name;
Expand Down Expand Up @@ -98,6 +96,40 @@ module.exports = angular
});
};

this.addExtendedAttribute = function() {
if (!$scope.stage.extendedAttributes) {
$scope.stage.extendedAttributes = {};
}
$uibModal
.open({
templateUrl: PipelineTemplates.addExtendedAttributes,
controller: 'bakeStageAddExtendedAttributeController',
controllerAs: 'addExtendedAttribute',
resolve: {
extendedAttribute: function() {
return {
key: '',
value: '',
};
},
},
})
.result.then(function(extendedAttribute) {
$scope.stage.extendedAttributes[extendedAttribute.key] = extendedAttribute.value;
})
.catch(() => {});
};

this.removeExtendedAttribute = function(key) {
delete $scope.stage.extendedAttributes[key];
};

this.showExtendedAttributes = function() {
return (
$scope.viewState.roscoMode || ($scope.stage.extendedAttributes && _.size($scope.stage.extendedAttributes) > 0)
);
};

$scope.$watch('stage.accountName', $scope.accountUpdated);

initialize();
Expand Down

0 comments on commit 0cdcb1e

Please sign in to comment.