Skip to content

Commit

Permalink
Merge pull request #97 from gympass/fix-cdnclass-env
Browse files Browse the repository at this point in the history
fix: removes unused cdn_class var env
  • Loading branch information
caiofralmeida authored Aug 29, 2023
2 parents 5fec211 + 2eb4e2b commit 0ae5968
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
5 changes: 0 additions & 5 deletions controllers/predicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -69,10 +68,6 @@ var (
}()
)

func (s *PredicateSuite) SetupTest() {
viper.Set(config.CDNClassKey, "default")
}

func (s *PredicateSuite) TearDownTest() {
viper.Reset()
}
Expand Down
10 changes: 0 additions & 10 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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, "")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func init() {
_ = godotenv.Load()
}

const (
leaderElectionID = "cdn-origin.gympass.com"
)

func main() {
var metricsAddr string
var enableLeaderElection bool
Expand Down Expand Up @@ -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")
Expand All @@ -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())

Expand Down

0 comments on commit 0ae5968

Please sign in to comment.