From 0b28e96a5867a0616b20051a5cf63e03e1b821bf Mon Sep 17 00:00:00 2001 From: Templum Date: Tue, 3 Apr 2018 19:27:47 +0200 Subject: [PATCH] Adjusted code accordingly to feedback Based on the received feedback I updated the documentation of the function. Also replaced variable temp by an more declaritive variable. Signed-off-by: Simon Pelczer --- gateway/plugin/external.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/plugin/external.go b/gateway/plugin/external.go index c53a7743..d1f56cbb 100644 --- a/gateway/plugin/external.go +++ b/gateway/plugin/external.go @@ -95,12 +95,12 @@ func (s ExternalServiceQuery) GetReplicas(serviceName string) (handlers.ServiceQ minReplicas = extractLabelValue(labels[handlers.MinScaleLabel], minReplicas) maxReplicas = extractLabelValue(labels[handlers.MaxScaleLabel], maxReplicas) - temp := extractLabelValue(labels[handlers.ScalingFactorLabel], scalingFactor) + extractedScalingFactor := extractLabelValue(labels[handlers.ScalingFactorLabel], scalingFactor) - if temp >= 0 && temp <= 100 { - scalingFactor = temp + if extractedScalingFactor >= 0 && extractedScalingFactor <= 100 { + scalingFactor = extractedScalingFactor } else { - log.Printf("Bad Scaling Factor: %d, is in range [0 - 100]", temp) + log.Printf("Bad Scaling Factor: %d, is not in range of [0 - 100]. Will fallback to %d", extractedScalingFactor, scalingFactor) } } @@ -147,8 +147,8 @@ func (s ExternalServiceQuery) SetReplicas(serviceName string, count uint64) erro return err } -// This methods tries to parse the provided raw label value and if it fails -// it will return the provided fallback value and log and message +// extractLabelValue will parse the provided raw label value and if it fails +// it will return the provided fallback value and log an message func extractLabelValue(rawLabelValue string, fallback uint64 ) uint64{ if len(rawLabelValue) <= 0 { return fallback