Skip to content

Commit

Permalink
fix(aws/k8s): specify protocol on load balancer links based on ports/…
Browse files Browse the repository at this point in the history
…listeners
  • Loading branch information
anotherchrisberry committed Feb 27, 2017
1 parent c81b6d5 commit dddd6fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,32 @@ module.exports = angular.module('spinnaker.loadBalancer.aws.details.controller',

this.application = app;

function extractLoadBalancer() {
let extractLoadBalancer = () => {
let appLoadBalancer = app.loadBalancers.data.find(function (test) {
return test.name === loadBalancer.name && test.region === loadBalancer.region && test.account === loadBalancer.accountId;
});

if (appLoadBalancer) {
var detailsLoader = loadBalancerReader.getLoadBalancerDetails('aws', loadBalancer.accountId, loadBalancer.region, loadBalancer.name);
return detailsLoader.then(function(details) {
return detailsLoader.then((details) => {
$scope.loadBalancer = appLoadBalancer;
$scope.state.loading = false;
var securityGroups = [];
if (details.length) {
$scope.loadBalancer.elb = details[0];
$scope.loadBalancer.account = loadBalancer.accountId;
if (details[0].listenerDescriptions) {
this.elbProtocol = 'http:';
if (details[0].listenerDescriptions.some(l => l.listener.protocol === 'HTTPS')) {
this.elbProtocol = 'https:';
}
}

if ($scope.loadBalancer.elb.availabilityZones) {
$scope.loadBalancer.elb.availabilityZones.sort();
}

$scope.loadBalancer.elb.securityGroups.forEach(function (securityGroupId) {
$scope.loadBalancer.elb.securityGroups.forEach((securityGroupId) => {
var match = securityGroupReader.getApplicationSecurityGroup(app, loadBalancer.accountId, loadBalancer.region, securityGroupId);
if (match) {
securityGroups.push(match);
Expand Down Expand Up @@ -78,7 +84,7 @@ module.exports = angular.module('spinnaker.loadBalancer.aws.details.controller',
}

return $q.when(null);
}
};

function autoClose() {
if ($scope.$$destroyed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h3 select-on-dbl-click>
<dl class="horizontal-when-filters-collapsed">
<dt ng-if="loadBalancer.elb.dnsname">DNS Name</dt>
<dd>
<a target=_blank href="//{{loadBalancer.elb.dnsname}}">{{loadBalancer.elb.dnsname}}</a>
<a target=_blank href="{{ctrl.elbProtocol}}//{{loadBalancer.elb.dnsname}}">{{loadBalancer.elb.dnsname}}</a>
<copy-to-clipboard
class="copy-to-clipboard copy-to-clipboard-sm"
text="{{loadBalancer.elb.dnsname}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {CONFIRMATION_MODAL_SERVICE} from 'core/confirmationModal/confirmationMod
import {LOAD_BALANCER_WRITE_SERVICE} from 'core/loadBalancer/loadBalancer.write.service';

let angular = require('angular');
import _ from 'lodash';

module.exports = angular.module('spinnaker.loadBalancer.kubernetes.details.controller', [
require('angular-ui-router'),
Expand All @@ -23,22 +24,26 @@ module.exports = angular.module('spinnaker.loadBalancer.kubernetes.details.contr
loading: true
};

function extractLoadBalancer() {
let extractLoadBalancer = () => {
return application.loadBalancers.ready()
.then(() => {
$scope.loadBalancer = application.loadBalancers.data.filter(function (test) {
$scope.loadBalancer = application.loadBalancers.data.find((test) => {
return test.name === loadBalancer.name &&
(test.namespace === loadBalancer.region || test.namespace === loadBalancer.namespace) &&
test.account === loadBalancer.accountId;
})[0];
});

if ($scope.loadBalancer) {
this.ingressProtocol = 'http:';
if (_.get($scope.loadBalancer, 'service.spec.ports', []).some(p => p.port === 443)) {
this.ingressProtocol = 'https:';
}
$scope.state.loading = false;
} else {
autoClose();
}
});
}
};

this.uiLink = function uiLink() {
return kubernetesProxyUiService.buildLink($scope.loadBalancer.account, 'service', $scope.loadBalancer.region, $scope.loadBalancer.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h3 select-on-dbl-click>
<dl ng-if="loadBalancer.service.status.loadBalancer.ingress.length">
<dt>Ingress</dt>
<dd ng-repeat="ingress in loadBalancer.service.status.loadBalancer.ingress">
<a ng-if="ingress.hostname" target="_blank" href="//{{ingress.hostname}}">
<a ng-if="ingress.hostname" target="_blank" href="{{ctrl.ingressProtocol}}//{{ingress.hostname}}">
{{ingress.hostname}}
</a>
<copy-to-clipboard
Expand Down

0 comments on commit dddd6fa

Please sign in to comment.