Skip to content

Commit 3de7e17

Browse files
Clarified which args are required or not.
1 parent d770b04 commit 3de7e17

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ deployment records to GitHub's artifact metadata API.
4949
| `ORG` | GitHub organization name | (required) |
5050
| `BASE_URL` | API base URL | `api.github.com` |
5151
| `DN_TEMPLATE` | Deployment name template | `{{namespace}}/{{deploymentName}}/{{containerName}}` |
52-
| `LOGICAL_ENVIRONMENT` | Logical environment name | `""` |
52+
| `LOGICAL_ENVIRONMENT` | Logical environment name | (required) |
5353
| `PHYSICAL_ENVIRONMENT` | Physical environment name | `""` |
54-
| `CLUSTER` | Cluster name | `""` |
54+
| `CLUSTER` | Cluster name | (required) |
5555
| `API_TOKEN` | API authentication token | `""` |
5656

5757
> [!NOTE]

cmd/deployment-tracker/main.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,29 @@ func main() {
7575
flag.IntVar(&workers, "workers", 2, "number of worker goroutines")
7676
flag.Parse()
7777

78+
var cfg = Config{
79+
Template: getEnvOrDefault("DN_TEMPLATE", defaultTemplate),
80+
LogicalEnvironment: os.Getenv("LOGICAL_ENVIRONMENT"),
81+
PhysicalEnvironment: os.Getenv("PHYSICAL_ENVIRONMENT"),
82+
Cluster: os.Getenv("CLUSTER"),
83+
APIToken: getEnvOrDefault("API_TOKEN", ""),
84+
BaseURL: getEnvOrDefault("BASE_URL", "api.github.com"),
85+
Org: os.Getenv("ORG"),
86+
}
87+
88+
if cfg.LogicalEnvironment == "" {
89+
fmt.Fprint(os.Stderr, "Logical environment is required\n")
90+
os.Exit(1)
91+
}
92+
if cfg.Cluster == "" {
93+
fmt.Fprint(os.Stderr, "Cluster is required\n")
94+
os.Exit(1)
95+
}
96+
if cfg.Org == "" {
97+
fmt.Fprint(os.Stderr, "Org is required\n")
98+
os.Exit(1)
99+
}
100+
78101
config, err := createConfig(kubeconfig)
79102
if err != nil {
80103
fmt.Fprintf(os.Stderr, "Error creating Kubernetes config: %v\n", err)
@@ -97,15 +120,6 @@ func main() {
97120
cancel()
98121
}()
99122

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-
}
109123
controller := NewController(clientset, namespace, &cfg)
110124

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

0 commit comments

Comments
 (0)