Skip to content

Commit

Permalink
fix envconfig default (#505)
Browse files Browse the repository at this point in the history
Signed-off-by: Kenny Leung <kleung@chainguard.dev>
  • Loading branch information
k4leung4 authored Aug 21, 2024
1 parent abb622b commit ef196e0
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions modules/bucket-events/cmd/trampoline/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
)

var env = envconfig.MustProcess(context.Background(), &struct {
Port int `env:"PORT" default:"8080" required:"true"`
IngressURI string `env:"INGRESS_URI" required:"true"`
Port int `env:"PORT, default=8080"`
IngressURI string `env:"INGRESS_URI, required"`
}{})

var eventTypes = map[string]string{
Expand Down
4 changes: 2 additions & 2 deletions modules/cloudevent-broker/cmd/ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const (
)

var env = envconfig.MustProcess(context.Background(), &struct {
Port int `env:"PORT" default:"8080" required:"true"`
Topic string `env:"PUBSUB_TOPIC" required:"true"`
Port int `env:"PORT, default:8080"`
Topic string `env:"PUBSUB_TOPIC, required"`
}{})

func main() {
Expand Down
8 changes: 4 additions & 4 deletions modules/cloudevent-recorder/cmd/dejavu-bq/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const (
)

var env = envconfig.MustProcess(context.Background(), &struct {
Host string `env:"HOST" default:"http://0.0.0.0" required:"true"`
Port int `env:"PORT" default:"8080" required:"true"`
Host string `env:"HOST, default=http://0.0.0.0"`
Port int `env:"PORT, default=8080"`

EventType string `env:"EVENT_TYPE" default:"dev.chainguard.not_specified.not_specified" required:"true"`
EventSource string `env:"EVENT_SOURCE" default:"github.com" required:"true"`
EventType string `env:"EVENT_TYPE, default=dev.chainguard.not_specified.not_specified"`
EventSource string `env:"EVENT_SOURCE, default=github.com"`

// Project is the GCP project where the dataset lives
Project string `env:"PROJECT" required:"true"`
Expand Down
6 changes: 3 additions & 3 deletions modules/cloudevent-recorder/cmd/logrotate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
)

var env = envconfig.MustProcess(context.Background(), &struct {
Bucket string `env:"BUCKET" required:"true"`
FlushInterval time.Duration `env:"FLUSH_INTERVAL" default:"3m"`
LogPath string `env:"LOG_PATH" required:"true"`
Bucket string `env:"BUCKET, required"`
FlushInterval time.Duration `env:"FLUSH_INTERVAL, default=3m"`
LogPath string `env:"LOG_PATH, required"`
}{})

func main() {
Expand Down
4 changes: 2 additions & 2 deletions modules/cloudevent-recorder/cmd/recorder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
)

var env = envconfig.MustProcess(context.Background(), &struct {
Port int `env:"PORT" default:"8080" required:"true"`
LogPath string `env:"LOG_PATH" required:"true"`
Port int `env:"PORT, default=8080"`
LogPath string `env:"LOG_PATH, required"`
}{})

func main() {
Expand Down
2 changes: 1 addition & 1 deletion modules/github-bots/sdk/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (b *Bot) RegisterHandler(handler EventHandlerFunc) {
}

var env = envconfig.MustProcess(context.Background(), &struct {
Port int `env:"PORT" default:"8080" required:"true"`
Port int `env:"PORT, default=8080"`
}{})

func Serve(b Bot) {
Expand Down
6 changes: 3 additions & 3 deletions modules/github-events/cmd/trampoline/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
)

var env = envconfig.MustProcess(context.Background(), &struct {
Port int `env:"PORT" default:"8080" required:"true"`
IngressURI string `env:"EVENT_INGRESS_URI" required:"true"`
WebhookSecret string `env:"WEBHOOK_SECRET" required:"true"`
Port int `env:"PORT, default=8080"`
IngressURI string `env:"EVENT_INGRESS_URI, required"`
WebhookSecret string `env:"WEBHOOK_SECRET, required"`
}{})

func main() {
Expand Down
6 changes: 3 additions & 3 deletions pkg/httpmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
)

var env = envconfig.MustProcess(context.Background(), &struct {
MetricsPort int `env:"METRICS_PORT" default:"2112"`
MetricsPort int `env:"METRICS_PORT, default=2112"`

// https://cloud.google.com/run/docs/container-contract#services-env-vars
KnativeServiceName string `env:"K_SERVICE" default:"unknown"`
KnativeRevisionName string `env:"K_REVISION" default:"unknown"`
KnativeServiceName string `env:"K_SERVICE, default=unknown"`
KnativeRevisionName string `env:"K_REVISION, default=unknown"`
}{})

// ServeMetrics serves the metrics endpoint if the METRICS_PORT env var is set.
Expand Down
2 changes: 1 addition & 1 deletion pkg/profiler/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

var env = envconfig.MustProcess(context.Background(), &struct {
EnableProfiler bool `env:"ENABLE_PROFILER" default:"false" required:"false"`
EnableProfiler bool `env:"ENABLE_PROFILER, default=false"`
}{})

func SetupProfiler() {
Expand Down

0 comments on commit ef196e0

Please sign in to comment.