Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env vars aren't validated #85

Open
jacobweinstock opened this issue Jun 24, 2021 · 0 comments
Open

Env vars aren't validated #85

jacobweinstock opened this issue Jun 24, 2021 · 0 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@jacobweinstock
Copy link
Member

Env vars are not validated like cli flags are.

Expected Behaviour

Env vars should be validated just like cli flags are.

Current Behaviour

A bad env var that wouldn't pass the cli flag validation could cause unexpected behavior.

For example:

# cli flag validation
❯ go run main.go server --bmcTimeout 60 
Error: invalid argument "60" for "--bmcTimeout" flag: time: missing unit in duration "60"
Usage:
  pbnj server [flags]

Flags:
      --bmcTimeout duration        Timeout for BMC calls (default 15s)
      --enableAuthz                enable Authz middleware. Configure with configuration file details
      --enableHTTP                 enable the HTTP server
  -h, --help                       help for server
      --hsKey string               HS key
      --metricsListenAddr string   metrics server listen address (default ":8080")
      --port string                grpc server port (default "50051")
      --rsPubKey string            RS public key

Global Flags:
      --config string     config file (default is pbnj.yaml)
      --logLevel string   log level (default is info (default "info")

invalid argument "60" for "--bmcTimeout" flag: time: missing unit in duration "60"
exit status 1
# no validation for env var. The server starts up with the bmc timeout set to 0
PBNJ_BMCTIMEOUT=60 go run main.go server
{"level":"info","ts":1624559879.264104,"caller":"cmd/server.go:97","msg":"debugging","service":"github.com/tinkerbell/pbnj","timeout":0,"timeout_string":"0s"}
{"level":"info","ts":1624559879.2745972,"caller":"grpcsvr/server.go:129","msg":"starting PBnJ gRPC server","service":"github.com/tinkerbell/pbnj"}

Possible Solution

Steps to Reproduce (for bugs)

Context

Your Environment

  • Operating System and version (e.g. Linux, Windows, MacOS):

  • How are you running Tinkerbell? Using Vagrant & VirtualBox, Vagrant & Libvirt, on Packet using Terraform, or give details:

  • Link to your project or a code example to reproduce issue:

@jacobweinstock jacobweinstock added the kind/bug Categorizes issue or PR as related to a bug. label Jun 24, 2021
@tstromberg tstromberg added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

2 participants