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

fix: replace environment variables in webserver headers #844

Merged
merged 1 commit into from
May 16, 2022
Merged

fix: replace environment variables in webserver headers #844

merged 1 commit into from
May 16, 2022

Conversation

iwpnd
Copy link
Member

@iwpnd iwpnd commented Apr 26, 2022

Using environment variables in config.Webserver.Headers would not replace environment variables currently. I therefore added an additional step in config.Parse that would iterate over the header and resolve the environment variables if possible. I opted to otherwise raise if the environment variable is not present similar to the behaviour we have right now if any other env is missing. This could also just handle the error and use the original value.

I updated the tests accordingly and added some more to test in isolation.

As mentioned on slack I'm not sure if that is the correct spot to fix it, so your input is greatly appreciated as usual. :)

@iwpnd iwpnd requested review from gdey and ARolek as code owners April 26, 2022 08:53
@coveralls
Copy link

coveralls commented Apr 26, 2022

Pull Request Test Coverage Report for Build 07ae82188-PR-844

  • 5 of 43 (11.63%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 45.403%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/env/types.go 0 11 0.0%
internal/env/parse.go 0 27 0.0%
Totals Coverage Status
Change from base Build 7ac37b942: -0.1%
Covered Lines: 5580
Relevant Lines: 12290

💛 - Coveralls

@ARolek
Copy link
Member

ARolek commented Apr 27, 2022

Related issue: #597

Copy link
Member

@gdey gdey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most this looks good, there is a question and a minor nit.

config/config_test.go Outdated Show resolved Hide resolved
return nil, err
}

d[k] = *s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to check if the v if of type map[string]interface{} and if so, call ParseDict on it as well?

Copy link
Member Author

@iwpnd iwpnd May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think v can be of type map[string]interface{} or can it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iwpnd I'm pretty sure it can be. I don't believe TOML has a max limit of nesting. For the tegola config we don't really have much nesting, but it seems to me the ParseDict() function should likely account for all primitives as well as a map[string]interface{} (which would just call ParseDict() again)

fix: let dict implement UnmarshalTOML

fix: move ParseDict to parse

chore: remove extra space

test: test missing env

feat: parse map[string]interface{} in ParseDict as well
@iwpnd
Copy link
Member Author

iwpnd commented May 14, 2022

Any outstanding issues that I need to resolve here? @gdey @ARolek

@ARolek
Copy link
Member

ARolek commented May 14, 2022

@iwpnd We're just waiting for @gdey to review. I will give him a bump.

Copy link
Member

@gdey gdey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ARolek ARolek merged commit fc67300 into go-spatial:v0.15.x May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants