Skip to content

Commit

Permalink
Don't request instances and bindings if the user doesn't have watch r…
Browse files Browse the repository at this point in the history
…ights
  • Loading branch information
jwforres committed Jun 26, 2017
1 parent 733e9f2 commit 85b5d7f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 35 deletions.
9 changes: 6 additions & 3 deletions app/scripts/controllers/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,9 @@ function OverviewController($scope,
updateQuotaWarnings();
}, {poll: true, pollInterval: DEFAULT_POLL_INTERVAL}));

if (SERVICE_CATALOG_ENABLED) {
var canI = $filter('canI');
// The canI check on watch should be temporary until we have a different solution for handling secret parameters
if (SERVICE_CATALOG_ENABLED && canI({resource: 'instances', group: 'servicecatalog.k8s.io'}, 'watch')) {
watches.push(DataService.watch({
group: 'servicecatalog.k8s.io',
resource: 'instances'
Expand All @@ -1365,7 +1367,7 @@ function OverviewController($scope,
}, {poll: limitWatches, pollInterval: DEFAULT_POLL_INTERVAL}));
}

if (SERVICE_CATALOG_ENABLED) {
if (SERVICE_CATALOG_ENABLED && canI({resource: 'bindings', group: 'servicecatalog.k8s.io'}, 'watch')) {
watches.push(DataService.watch({
group: 'servicecatalog.k8s.io',
resource: 'bindings'
Expand All @@ -1383,9 +1385,10 @@ function OverviewController($scope,
state.limitRanges = response.by("metadata.name");
});

if (SERVICE_CATALOG_ENABLED) {
if (SERVICE_CATALOG_ENABLED && canI({resource: 'instances', group: 'servicecatalog.k8s.io'}, 'watch')) {
// TODO: update to behave like ImageStreamResolver
// - we may not even need to list these... perhaps just fetch the ones we need when needed
// If we can't watch instances don't bother getting service classes either
DataService.list({
group: 'servicecatalog.k8s.io',
resource: 'serviceclasses'
Expand Down
75 changes: 43 additions & 32 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,48 +401,48 @@ return _.get(Q.serviceClasses, [ a.spec.serviceClassName, "osbMetadata", "displa
return _.get(a, "metadata.name", "");
}))) :void (Q.bindableServiceInstances = null);
}, ab = [];
v.get(c.project).then(_.spread(function(b, c) {
Q.project = a.project = b, Q.context = c;
var d = function() {
z.pods && m.fetchReferencedImageStreamImages(z.pods, Q.imagesByDockerReference, Q.imageStreamImageRefByDockerReference, c);
};
ab.push(i.watch("pods", c, function(a) {
z.pods = a.by("metadata.name"), Ca(), d(), ya(), Ja(z.monopods), pa(z.monopods), za(z.monopods), ia(), p.log("pods (subscribe)", z.pods);
})), ab.push(i.watch("replicationcontrollers", c, function(a) {
v.get(c.project).then(_.spread(function(c, d) {
Q.project = a.project = c, Q.context = d;
var e = function() {
z.pods && m.fetchReferencedImageStreamImages(z.pods, Q.imagesByDockerReference, Q.imageStreamImageRefByDockerReference, d);
};
ab.push(i.watch("pods", d, function(a) {
z.pods = a.by("metadata.name"), Ca(), e(), ya(), Ja(z.monopods), pa(z.monopods), za(z.monopods), ia(), p.log("pods (subscribe)", z.pods);
})), ab.push(i.watch("replicationcontrollers", d, function(a) {
z.replicationControllers = a.by("metadata.name"), Fa(), Ja(z.vanillaReplicationControllers), Ja(z.monopods), pa(z.vanillaReplicationControllers), za(z.vanillaReplicationControllers), $a(), ia(), p.log("replicationcontrollers (subscribe)", z.replicationControllers);
})), ab.push(i.watch("deploymentconfigs", c, function(a) {
})), ab.push(i.watch("deploymentconfigs", d, function(a) {
z.deploymentConfigs = a.by("metadata.name"), Fa(), Ja(z.deploymentConfigs), Ja(z.vanillaReplicationControllers), za(z.deploymentConfigs), wa(), Va(), Wa(), $a(), ia(), p.log("deploymentconfigs (subscribe)", z.deploymentConfigs);
})), ab.push(i.watch({
group:"extensions",
resource:"replicasets"
}, c, function(a) {
}, d, function(a) {
z.replicaSets = a.by("metadata.name"), Ha(), Ja(z.vanillaReplicaSets), Ja(z.monopods), pa(z.vanillaReplicaSets), za(z.vanillaReplicaSets), $a(), ia(), p.log("replicasets (subscribe)", z.replicaSets);
})), ab.push(i.watch({
group:"extensions",
resource:"deployments"
}, c, function(a) {
}, d, function(a) {
D = a.by("metadata.uid"), z.deployments = _.sortBy(D, "metadata.name"), Ha(), Ja(z.deployments), Ja(z.vanillaReplicaSets), za(z.deployments), $a(), ia(), p.log("deployments (subscribe)", z.deploymentsByUID);
})), ab.push(i.watch("builds", c, function(a) {
})), ab.push(i.watch("builds", d, function(a) {
Q.builds = a.by("metadata.name"), Xa(), p.log("builds (subscribe)", Q.builds);
})), ab.push(i.watch({
group:"apps",
resource:"statefulsets"
}, c, function(a) {
}, d, function(a) {
z.statefulSets = a.by("metadata.name"), Ja(z.statefulSets), Ja(z.monopods), pa(z.statefulSets), za(z.statefulSets), $a(), ia(), p.log("statefulsets (subscribe)", z.statefulSets);
}, {
poll:A,
pollInterval:B
})), ab.push(i.watch("services", c, function(a) {
})), ab.push(i.watch("services", d, function(a) {
Q.allServices = a.by("metadata.name"), Ka(), p.log("services (subscribe)", Q.allServices);
}, {
poll:A,
pollInterval:B
})), ab.push(i.watch("routes", c, function(a) {
})), ab.push(i.watch("routes", d, function(a) {
z.routes = a.by("metadata.name"), La(), p.log("routes (subscribe)", z.routes);
}, {
poll:A,
pollInterval:B
})), ab.push(i.watch("buildConfigs", c, function(a) {
})), ab.push(i.watch("buildConfigs", d, function(a) {
z.buildConfigs = a.by("metadata.name"), Pa(), Va(), Xa(), ia(), p.log("buildconfigs (subscribe)", z.buildConfigs);
}, {
poll:A,
Expand All @@ -451,56 +451,67 @@ pollInterval:B
group:"autoscaling",
resource:"horizontalpodautoscalers",
version:"v1"
}, c, function(a) {
}, d, function(a) {
z.horizontalPodAutoscalers = a.by("metadata.name"), Ma(), p.log("autoscalers (subscribe)", z.horizontalPodAutoscalers);
}, {
poll:A,
pollInterval:B
})), ab.push(i.watch("imagestreams", c, function(a) {
E = a.by("metadata.name"), m.buildDockerRefMapForImageStreams(E, Q.imageStreamImageRefByDockerReference), d(), p.log("imagestreams (subscribe)", E);
})), ab.push(i.watch("imagestreams", d, function(a) {
E = a.by("metadata.name"), m.buildDockerRefMapForImageStreams(E, Q.imageStreamImageRefByDockerReference), e(), p.log("imagestreams (subscribe)", E);
}, {
poll:A,
pollInterval:B
})), ab.push(i.watch("resourcequotas", c, function(a) {
})), ab.push(i.watch("resourcequotas", d, function(a) {
Q.quotas = a.by("metadata.name"), Ya();
}, {
poll:!0,
pollInterval:B
})), ab.push(i.watch("appliedclusterresourcequotas", c, function(a) {
})), ab.push(i.watch("appliedclusterresourcequotas", d, function(a) {
Q.clusterQuotas = a.by("metadata.name"), Ya();
}, {
poll:!0,
pollInterval:B
})), C && ab.push(i.watch({
}));
var f = b("canI");
C && f({
resource:"instances",
group:"servicecatalog.k8s.io"
}, "watch") && ab.push(i.watch({
group:"servicecatalog.k8s.io",
resource:"instances"
}, c, function(a) {
}, d, function(a) {
Q.serviceInstances = a.by("metadata.name"), _.each(Q.serviceInstances, function(a) {
var b = x.getServiceInstanceAlerts(a);
ma(a, b);
}), _a(), za(Q.serviceInstances), ia();
}, {
poll:A,
pollInterval:B
})), C && ab.push(i.watch({
})), C && f({
resource:"bindings",
group:"servicecatalog.k8s.io"
}, "watch") && ab.push(i.watch({
group:"servicecatalog.k8s.io",
resource:"bindings"
}, c, function(a) {
Q.bindings = a.by("metadata.name"), z.bindingsByInstanceRef = _.groupBy(Q.bindings, "spec.instanceRef.name"), $a(), Za(c);
}, d, function(a) {
Q.bindings = a.by("metadata.name"), z.bindingsByInstanceRef = _.groupBy(Q.bindings, "spec.instanceRef.name"), $a(), Za(d);
}, {
poll:A,
pollInterval:B
})), i.list("limitranges", c, function(a) {
})), i.list("limitranges", d, function(a) {
Q.limitRanges = a.by("metadata.name");
}), C && i.list({
}), C && f({
resource:"instances",
group:"servicecatalog.k8s.io"
}, "watch") && i.list({
group:"servicecatalog.k8s.io",
resource:"serviceclasses"
}, c, function(a) {
}, d, function(a) {
Q.serviceClasses = a.by("metadata.name"), _a(), ia();
});
var e = h.SAMPLE_PIPELINE_TEMPLATE;
e && i.get("templates", e.name, {
namespace:e.namespace
var g = h.SAMPLE_PIPELINE_TEMPLATE;
g && i.get("templates", g.name, {
namespace:g.namespace
}, {
errorNotification:!1
}).then(function(b) {
Expand Down

0 comments on commit 85b5d7f

Please sign in to comment.