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

Support reading configuration from stdin #3739

Closed
howardjohn opened this issue Mar 27, 2023 · 4 comments · Fixed by #3740
Closed

Support reading configuration from stdin #3739

howardjohn opened this issue Mar 27, 2023 · 4 comments · Fixed by #3740
Labels
area: config Related to .golangci.yml and/or cli options enhancement New feature or improvement

Comments

@howardjohn
Copy link

Your feature request related to a problem? Please describe.

We would like to read configuration from stdin. The reason is we want to deep merge a few configuration files with yq and pipe them in. This sort of works, but gives an error.

$ echo '' | golangci-lint run -c /dev/stdin
WARN [config_reader] Can't pretty print config file path: can't eval symlinks for path /dev/stdin: lstat /proc/688987/fd/pipe:[50935730]: no such file or directory

(in real world our command is not, echo, of course)

Describe the solution you'd like.

Support config from stdin without warning/error

Describe alternatives you've considered.

For our specific issue, passing multiple config files and having them deep merged would also be suitable. However, this may be complex as different folks have different meanings of "merge"

Additional context.

No response

@howardjohn howardjohn added the enhancement New feature or improvement label Mar 27, 2023
@ldez
Copy link
Member

ldez commented Mar 27, 2023

Hello,

It's not an error but a warning because it's not a "real" file, the warning doesn't stop the analysis or the reading of the configuration.

I guess yq is https://github.com/kislyuk/yq.

I don't know the possibilities of yq but you can already do:

yq '. *= load("bar-golangci.yml")' foo-golangci.yml | golangci-lint run -c /dev/stdin
# OR
golangci-lint run -c <(yq '. *= load("bar-golangci.yml")' foo-golangci.yml)

We will not create a "merge" of configuration files because merging files will lead to unnecessary complexity.

@ldez
Copy link
Member

ldez commented Mar 27, 2023

I create a PR to remove the warning when the configuration file explicitly stdin.

#3740

@ldez

This comment was marked as outdated.

@ldez
Copy link
Member

ldez commented Mar 27, 2023

I was not using my own fix 🤦, I need to sleep.

Everything works as expected.

@ldez ldez added the area: config Related to .golangci.yml and/or cli options label Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: config Related to .golangci.yml and/or cli options enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants