file configmap provider search all URLs in the current directory #7856
Description
Describe the issue
file configmap provider assumes all relative URLs as relative paths from the current directory.
When a URL refers a file in other directory and it contains ${file:xxx.yaml}
expression, the collector will search xxx.yaml always in the current directory.
Is it by design?
Steps to reproduce
I constructed file tree as below:
$ ls otelcol-contrib
otelcol-contrib
$ ls configs
config.yaml exporters.yaml
configs/config.yaml
exporters: ${file:exporters.yaml}
receivers:
otlp:
protocols:
grpc:
service:
pipelines:
traces:
receivers: [otlp]
exporters: [otlp]
configs/exporters.yaml
otlp:
endpoint: localhost:4317
Then, I ran otelcol-contrib with --config=file:configs/config.yaml
UPDATED: 2023-06-09
$ ./otelcol-contrib --config=file:configs/config.yaml
Error: failed to get config: cannot resolve the configuration: unable to read the file file:exporters.yaml: open exporters.yaml: no such file or directory
2023/06/09 22:24:59 collector server run finished with error: failed to get config: cannot resolve the configuration: unable to read the file file:exporters.yaml: open exporters.yaml: no such file or directory
I ran below after change current directory to configs.
$ ../otelcol-contrib --config=file:config.yaml
... otelcol-contrib launches successfully ...
What did you expect to see?
I expect the collector reads configs/config.yaml and configs/exporters.yaml then it will launch successfully.
In my opinion, it is more commonplace if a config file refer to other config files, parent config file search a file from a directory that parent config is stored in, like #include
of C.
What did you see instead?
unable to read the file file:config/config.yaml: open config/config.yaml: no such file or directory
What version did you use?
Version: v0.79.0
What config did you use?
Config: I described it above
Environment
OS: Arch Linux
Compiler(if manually compiled): I downloaded it from releases
Additional context
Add any other context about the problem here.