@@ -44,6 +44,14 @@ type BasicAuth struct {
44
44
PasswordFile string `yaml:"password_file,omitempty"`
45
45
}
46
46
47
+ // SetDirectory joins any relative file paths with dir.
48
+ func (a * BasicAuth ) SetDirectory (dir string ) {
49
+ if a == nil {
50
+ return
51
+ }
52
+ a .PasswordFile = JoinDir (dir , a .PasswordFile )
53
+ }
54
+
47
55
// URL is a custom URL type that allows validation at configuration load time.
48
56
type URL struct {
49
57
* url.URL
@@ -86,6 +94,16 @@ type HTTPClientConfig struct {
86
94
TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
87
95
}
88
96
97
+ // SetDirectory joins any relative file paths with dir.
98
+ func (c * HTTPClientConfig ) SetDirectory (dir string ) {
99
+ if c == nil {
100
+ return
101
+ }
102
+ c .TLSConfig .SetDirectory (dir )
103
+ c .BasicAuth .SetDirectory (dir )
104
+ c .BearerTokenFile = JoinDir (dir , c .BearerTokenFile )
105
+ }
106
+
89
107
// Validate validates the HTTPClientConfig to check only one of BearerToken,
90
108
// BasicAuth and BearerTokenFile is configured.
91
109
func (c * HTTPClientConfig ) Validate () error {
@@ -352,6 +370,16 @@ type TLSConfig struct {
352
370
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
353
371
}
354
372
373
+ // SetDirectory joins any relative file paths with dir.
374
+ func (c * TLSConfig ) SetDirectory (dir string ) {
375
+ if c == nil {
376
+ return
377
+ }
378
+ c .CAFile = JoinDir (dir , c .CAFile )
379
+ c .CertFile = JoinDir (dir , c .CertFile )
380
+ c .KeyFile = JoinDir (dir , c .KeyFile )
381
+ }
382
+
355
383
// UnmarshalYAML implements the yaml.Unmarshaler interface.
356
384
func (c * TLSConfig ) UnmarshalYAML (unmarshal func (interface {}) error ) error {
357
385
type plain TLSConfig
0 commit comments