Skip to content

Commit

Permalink
Parse address from config if not provided with '--addr' (#419)
Browse files Browse the repository at this point in the history
This fixes a bug where kes would try to split and evaluate the listen
address, before the config file was read. This caused kes to fail if no
`--addr` value was provided.

With this change, the config file is parsed before we try to determine
the listen address. If the `--addr` parameter is provided, we override
the value from the config as expected.

Co-authored-by: Robert Lützner <[email protected]>
  • Loading branch information
rluetzner and Robert Lützner authored Nov 9, 2023
1 parent 2b39c33 commit 07c57a2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/kes/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ func startServer(addrFlag, configFlag string) error {
return err
}

rawConfig, err := kesconf.ReadFile(configFlag)
if err != nil {
return err
}
if addrFlag == "" {
addrFlag = rawConfig.Addr
}
host, port, err := net.SplitHostPort(addrFlag)
if err != nil {
return err
Expand All @@ -157,13 +164,6 @@ func startServer(addrFlag, configFlag string) error {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()

rawConfig, err := kesconf.ReadFile(configFlag)
if err != nil {
return err
}
if addrFlag == "" {
addrFlag = rawConfig.Addr
}
conf, err := rawConfig.Config(ctx)
if err != nil {
return err
Expand Down

0 comments on commit 07c57a2

Please sign in to comment.