From 979581a4779025bfe81a2292d62edb310542544f Mon Sep 17 00:00:00 2001 From: Arsalan Khan Date: Tue, 22 Oct 2024 15:45:19 +0200 Subject: [PATCH] remove custom metrics authentication details from the binding configs --- .../assets/file/policy/policy-with-configuration.json | 3 --- src/autoscaler/api/broker/broker.go | 4 ++-- src/autoscaler/api/broker/broker_test.go | 2 -- src/autoscaler/models/binding_configs.go | 6 +----- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/acceptance/assets/file/policy/policy-with-configuration.json b/src/acceptance/assets/file/policy/policy-with-configuration.json index 8f3eef9381..94dcf15ae0 100644 --- a/src/acceptance/assets/file/policy/policy-with-configuration.json +++ b/src/acceptance/assets/file/policy/policy-with-configuration.json @@ -1,9 +1,6 @@ { "configuration": { "custom_metrics": { - "auth": { - "credential_type": "" - }, "metric_submission_strategy": { "allow_from": "bound_app" } diff --git a/src/autoscaler/api/broker/broker.go b/src/autoscaler/api/broker/broker.go index 3f24efe847..c1367aa203 100644 --- a/src/autoscaler/api/broker/broker.go +++ b/src/autoscaler/api/broker/broker.go @@ -513,7 +513,7 @@ func (b *Broker) Bind(ctx context.Context, instanceID string, bindingID string, } // set the default custom metrics strategy if not provided if bindingConfiguration.GetCustomMetricsStrategy() == "" { - bindingConfiguration.SetDefaultCustomMetricsStrategy(models.CustomMetricsSameApp) + bindingConfiguration.SetCustomMetricsStrategy(models.CustomMetricsSameApp) } logger.Info("binding-configuration", lager.Data{"bindingConfiguration": bindingConfiguration}) @@ -712,7 +712,7 @@ func (b *Broker) GetBinding(ctx context.Context, instanceID string, bindingID st return result, err } bindingConfig := &models.BindingConfig{} - bindingConfig.SetDefaultCustomMetricsStrategy(serviceBinding.CustomMetricsStrategy) + bindingConfig.SetCustomMetricsStrategy(serviceBinding.CustomMetricsStrategy) policy, err := b.policydb.GetAppPolicy(ctx, serviceBinding.AppID) if err != nil { diff --git a/src/autoscaler/api/broker/broker_test.go b/src/autoscaler/api/broker/broker_test.go index be123e87cc..ea0b98c476 100644 --- a/src/autoscaler/api/broker/broker_test.go +++ b/src/autoscaler/api/broker/broker_test.go @@ -189,7 +189,6 @@ var _ = Describe("Broker", func() { Context("with configuration and policy", func() { BeforeEach(func() { bindingConfig = &models.BindingConfig{Configuration: models.Configuration{CustomMetrics: models.CustomMetricsConfig{ - Auth: models.Auth{}, MetricSubmissionStrategy: models.MetricsSubmissionStrategy{AllowFrom: "bound_app"}, }, }} @@ -210,7 +209,6 @@ var _ = Describe("Broker", func() { Context("with configuration only", func() { BeforeEach(func() { bindingConfig = &models.BindingConfig{Configuration: models.Configuration{CustomMetrics: models.CustomMetricsConfig{ - Auth: models.Auth{}, MetricSubmissionStrategy: models.MetricsSubmissionStrategy{AllowFrom: "bound_app"}, }, }} diff --git a/src/autoscaler/models/binding_configs.go b/src/autoscaler/models/binding_configs.go index d465cb8091..1efc50a693 100644 --- a/src/autoscaler/models/binding_configs.go +++ b/src/autoscaler/models/binding_configs.go @@ -28,13 +28,9 @@ type Configuration struct { } type CustomMetricsConfig struct { - Auth Auth `json:"auth,omitempty"` MetricSubmissionStrategy MetricsSubmissionStrategy `json:"metric_submission_strategy"` } -type Auth struct { - CredentialType string `json:"credential_type"` -} type MetricsSubmissionStrategy struct { AllowFrom string `json:"allow_from"` } @@ -43,6 +39,6 @@ func (b *BindingConfig) GetCustomMetricsStrategy() string { return b.Configuration.CustomMetrics.MetricSubmissionStrategy.AllowFrom } -func (b *BindingConfig) SetDefaultCustomMetricsStrategy(allowFrom string) { +func (b *BindingConfig) SetCustomMetricsStrategy(allowFrom string) { b.Configuration.CustomMetrics.MetricSubmissionStrategy.AllowFrom = allowFrom }