From 2eb4e2b502347c2af173d4b58bb367e64da48529 Mon Sep 17 00:00:00 2001 From: Caio Almeida Date: Tue, 29 Aug 2023 10:23:59 -0300 Subject: [PATCH] fix(cdn-class): remove unused cdn_class var env --- controllers/predicate_test.go | 5 ----- internal/config/config.go | 10 ---------- main.go | 10 +++++----- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/controllers/predicate_test.go b/controllers/predicate_test.go index 4272efe..fc56dc6 100644 --- a/controllers/predicate_test.go +++ b/controllers/predicate_test.go @@ -29,7 +29,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" - "github.com/Gympass/cdn-origin-controller/internal/config" "github.com/Gympass/cdn-origin-controller/internal/k8s" ) @@ -69,10 +68,6 @@ var ( }() ) -func (s *PredicateSuite) SetupTest() { - viper.Set(config.CDNClassKey, "default") -} - func (s *PredicateSuite) TearDownTest() { viper.Reset() } diff --git a/internal/config/config.go b/internal/config/config.go index 393a675..5e6e68a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -27,8 +27,6 @@ import ( ) const ( - // CDNClassKey is the env var key that controls class - CDNClassKey = "cdn_class" logLevelKey = "log_level" devModeKey = "dev_mode" enableDeletionKey = "enable_deletion" @@ -54,7 +52,6 @@ func init() { viper.SetDefault(logLevelKey, "info") viper.SetDefault(devModeKey, "false") viper.SetDefault(enableDeletionKey, "false") - viper.SetDefault(CDNClassKey, "default") viper.SetDefault(cfDefaultOriginDomainKey, "") viper.SetDefault(cfPriceClassKey, awscloudfront.PriceClassPriceClassAll) viper.SetDefault(cfWafArnKey, "") @@ -92,8 +89,6 @@ type Config struct { DeletionEnabled bool // DefaultOriginDomain represents a valid domain to define in default origin. DefaultOriginDomain string - // CDNClass represents the set of resources managed by this deployment of the controller - CDNClass string // CloudFrontPriceClass determines how many edge locations CloudFront will use for your distribution. // ref: https://docs.aws.amazon.com/sdk-for-go/api/service/cloudfront/ CloudFrontPriceClass string @@ -159,11 +154,6 @@ func Parse() Config { } } -// CDNClass returns the configured CDN class -func CDNClass() string { - return viper.GetString(CDNClassKey) -} - func extractTags(customTags string) map[string]string { m := make(map[string]string) if len(customTags) == 0 { diff --git a/main.go b/main.go index b4da4d0..0553fa5 100644 --- a/main.go +++ b/main.go @@ -68,6 +68,10 @@ func init() { _ = godotenv.Load() } +const ( + leaderElectionID = "cdn-origin.gympass.com" +) + func main() { var metricsAddr string var enableLeaderElection bool @@ -96,7 +100,7 @@ func main() { Port: 9443, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, - LeaderElectionID: leaderElectionID(cfg.CDNClass), + LeaderElectionID: leaderElectionID, }) if err != nil { setupLog.Error(err, "unable to start manager") @@ -123,10 +127,6 @@ func main() { } } -func leaderElectionID(cdnClass string) string { - return fmt.Sprintf("%s.cdn-origin.gympass.com", cdnClass) -} - func mustSetupControllers(mgr manager.Manager, cfg config.Config) { s := session.Must(session.NewSession())