Skip to content

Commit 0bddaa3

Browse files
remove global state
1 parent 1c82181 commit 0bddaa3

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

cmd/deployment-tracker/main.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,6 @@ type Controller struct {
5555
cfg *Config
5656
}
5757

58-
// cfg is the global configuration instance
59-
var cfg Config
60-
61-
func initConfig() {
62-
cfg = Config{
63-
Template: getEnvOrDefault("DN_TEMPLATE", defaultTemplate),
64-
LogicalEnvironment: os.Getenv("LOGICAL_ENVIRONMENT"),
65-
PhysicalEnvironment: os.Getenv("PHYSICAL_ENVIRONMENT"),
66-
Cluster: os.Getenv("CLUSTER"),
67-
APIToken: getEnvOrDefault("API_TOKEN", ""),
68-
BaseURL: getEnvOrDefault("BASE_URL", "api.github.com"),
69-
Org: os.Getenv("ORG"),
70-
}
71-
}
72-
7358
func getEnvOrDefault(key, defaultValue string) string {
7459
if value := os.Getenv(key); value != "" {
7560
return value
@@ -78,8 +63,6 @@ func getEnvOrDefault(key, defaultValue string) string {
7863
}
7964

8065
func main() {
81-
initConfig()
82-
8366
var (
8467
kubeconfig string
8568
namespace string
@@ -114,6 +97,15 @@ func main() {
11497
cancel()
11598
}()
11699

100+
var cfg = Config{
101+
Template: getEnvOrDefault("DN_TEMPLATE", defaultTemplate),
102+
LogicalEnvironment: os.Getenv("LOGICAL_ENVIRONMENT"),
103+
PhysicalEnvironment: os.Getenv("PHYSICAL_ENVIRONMENT"),
104+
Cluster: os.Getenv("CLUSTER"),
105+
APIToken: getEnvOrDefault("API_TOKEN", ""),
106+
BaseURL: getEnvOrDefault("BASE_URL", "api.github.com"),
107+
Org: os.Getenv("ORG"),
108+
}
117109
controller := NewController(clientset, namespace, &cfg)
118110

119111
fmt.Println("Starting deployment-tracker controller")

0 commit comments

Comments
 (0)