Skip to content

Using environment variables for integer values #4

Description

@begriffs

My configuration file contains a field for a web server port. I'd like to read the value from an environment variable, but doing so always treats it as a string.

server-port = "$(FOO)"

Running with FOO exported to 3000 causes this error:

ConfigError {
  configErrorLocation = Key "" "server-port",
  configConversionError = Just [
    ConversionError {
      conversionErrorLoc = "boundedIntegerValue",
      conversionErrorWhy = TypeError,
      conversionErrorVal = Just (String "3000"),
      conversionErrorType = Just Int,
      conversionErrorMsg = Nothing
    }
  ]
}

I tried this too

server-port = $(FOO)

but it reports ParseError "test.conf" "endOfInput".

Is there something I can do in my code to allow both literal integers and those from environment variables?

(Context: PostgREST/postgrest#826)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions