Skip to content

Commit aa0e998

Browse files
committed
config: add json tags to config structs
Signed-off-by: Jakob Hahn <[email protected]>
1 parent 079f253 commit aa0e998

File tree

1 file changed

+71
-71
lines changed

1 file changed

+71
-71
lines changed

config/config.go

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var (
7979
)
8080

8181
type Config struct {
82-
Modules map[string]Module `yaml:"modules"`
82+
Modules map[string]Module `yaml:"modules" json:"modules"`
8383
}
8484

8585
type SafeConfig struct {
@@ -193,104 +193,104 @@ func MustNewRegexp(s string) Regexp {
193193
}
194194

195195
type Module struct {
196-
Prober string `yaml:"prober,omitempty"`
197-
Timeout time.Duration `yaml:"timeout,omitempty"`
198-
HTTP HTTPProbe `yaml:"http,omitempty"`
199-
TCP TCPProbe `yaml:"tcp,omitempty"`
200-
ICMP ICMPProbe `yaml:"icmp,omitempty"`
201-
DNS DNSProbe `yaml:"dns,omitempty"`
202-
GRPC GRPCProbe `yaml:"grpc,omitempty"`
196+
Prober string `yaml:"prober,omitempty" json:"prober,omitempty"`
197+
Timeout time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
198+
HTTP HTTPProbe `yaml:"http,omitempty" json:"http,omitempty"`
199+
TCP TCPProbe `yaml:"tcp,omitempty" json:"tcp,omitempty"`
200+
ICMP ICMPProbe `yaml:"icmp,omitempty" json:"icmp,omitempty"`
201+
DNS DNSProbe `yaml:"dns,omitempty" json:"dns,omitempty"`
202+
GRPC GRPCProbe `yaml:"grpc,omitempty" json:"grpc,omitempty"`
203203
}
204204

205205
type HTTPProbe struct {
206206
// Defaults to 2xx.
207-
ValidStatusCodes []int `yaml:"valid_status_codes,omitempty"`
208-
ValidHTTPVersions []string `yaml:"valid_http_versions,omitempty"`
209-
IPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
210-
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
211-
SkipResolvePhaseWithProxy bool `yaml:"skip_resolve_phase_with_proxy,omitempty"`
212-
NoFollowRedirects *bool `yaml:"no_follow_redirects,omitempty"`
213-
FailIfSSL bool `yaml:"fail_if_ssl,omitempty"`
214-
FailIfNotSSL bool `yaml:"fail_if_not_ssl,omitempty"`
215-
Method string `yaml:"method,omitempty"`
216-
Headers map[string]string `yaml:"headers,omitempty"`
217-
FailIfBodyMatchesRegexp []Regexp `yaml:"fail_if_body_matches_regexp,omitempty"`
218-
FailIfBodyNotMatchesRegexp []Regexp `yaml:"fail_if_body_not_matches_regexp,omitempty"`
219-
FailIfHeaderMatchesRegexp []HeaderMatch `yaml:"fail_if_header_matches,omitempty"`
220-
FailIfHeaderNotMatchesRegexp []HeaderMatch `yaml:"fail_if_header_not_matches,omitempty"`
221-
Body string `yaml:"body,omitempty"`
222-
BodyFile string `yaml:"body_file,omitempty"`
223-
HTTPClientConfig config.HTTPClientConfig `yaml:"http_client_config,inline"`
224-
Compression string `yaml:"compression,omitempty"`
225-
BodySizeLimit units.Base2Bytes `yaml:"body_size_limit,omitempty"`
207+
ValidStatusCodes []int `yaml:"valid_status_codes,omitempty" json:"valid_status_codes,omitempty"`
208+
ValidHTTPVersions []string `yaml:"valid_http_versions,omitempty" json:"valid_http_versions,omitempty"`
209+
IPProtocol string `yaml:"preferred_ip_protocol,omitempty" json:"preferred_ip_protocol,omitempty"`
210+
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty" json:"ip_protocol_fallback,omitempty"`
211+
SkipResolvePhaseWithProxy bool `yaml:"skip_resolve_phase_with_proxy,omitempty" json:"skip_resolve_phase_with_proxy,omitempty"`
212+
NoFollowRedirects *bool `yaml:"no_follow_redirects,omitempty" json:"no_follow_redirects,omitempty"`
213+
FailIfSSL bool `yaml:"fail_if_ssl,omitempty" json:"fail_if_ssl,omitempty"`
214+
FailIfNotSSL bool `yaml:"fail_if_not_ssl,omitempty" json:"fail_if_not_ssl,omitempty"`
215+
Method string `yaml:"method,omitempty" json:"method,omitempty"`
216+
Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
217+
FailIfBodyMatchesRegexp []Regexp `yaml:"fail_if_body_matches_regexp,omitempty" json:"fail_if_body_matches_regexp,omitempty"`
218+
FailIfBodyNotMatchesRegexp []Regexp `yaml:"fail_if_body_not_matches_regexp,omitempty" json:"fail_if_body_not_matches_regexp,omitempty"`
219+
FailIfHeaderMatchesRegexp []HeaderMatch `yaml:"fail_if_header_matches,omitempty" json:"fail_if_header_matches,omitempty"`
220+
FailIfHeaderNotMatchesRegexp []HeaderMatch `yaml:"fail_if_header_not_matches,omitempty" json:"fail_if_header_not_matches,omitempty"`
221+
Body string `yaml:"body,omitempty" json:"body,omitempty"`
222+
BodyFile string `yaml:"body_file,omitempty" json:"body_file,omitempty"`
223+
HTTPClientConfig config.HTTPClientConfig `yaml:"http_client_config,inline" json:"http_client_config,inline"`
224+
Compression string `yaml:"compression,omitempty" json:"compression,omitempty"`
225+
BodySizeLimit units.Base2Bytes `yaml:"body_size_limit,omitempty" json:"body_size_limit,omitempty"`
226226
}
227227

228228
type GRPCProbe struct {
229-
Service string `yaml:"service,omitempty"`
230-
TLS bool `yaml:"tls,omitempty"`
231-
TLSConfig config.TLSConfig `yaml:"tls_config,omitempty"`
232-
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
233-
PreferredIPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
229+
Service string `yaml:"service,omitempty" json:"service,omitempty"`
230+
TLS bool `yaml:"tls,omitempty" json:"tls,omitempty"`
231+
TLSConfig config.TLSConfig `yaml:"tls_config,omitempty" json:"tls_config,omitempty"`
232+
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty" json:"ip_protocol_fallback,omitempty"`
233+
PreferredIPProtocol string `yaml:"preferred_ip_protocol,omitempty" json:"preferred_ip_protocol,omitempty"`
234234
}
235235

236236
type HeaderMatch struct {
237-
Header string `yaml:"header,omitempty"`
238-
Regexp Regexp `yaml:"regexp,omitempty"`
239-
AllowMissing bool `yaml:"allow_missing,omitempty"`
237+
Header string `yaml:"header,omitempty" json:"header,omitempty"`
238+
Regexp Regexp `yaml:"regexp,omitempty" json:"regexp,omitempty"`
239+
AllowMissing bool `yaml:"allow_missing,omitempty" json:"allow_missing,omitempty"`
240240
}
241241

242242
type Label struct {
243-
Name string `yaml:"name,omitempty"`
244-
Value string `yaml:"value,omitempty"`
243+
Name string `yaml:"name,omitempty" json:"name,omitempty"`
244+
Value string `yaml:"value,omitempty" json:"value,omitempty"`
245245
}
246246

247247
type QueryResponse struct {
248-
Expect Regexp `yaml:"expect,omitempty"`
249-
Labels []Label `yaml:"labels,omitempty"`
250-
Send string `yaml:"send,omitempty"`
251-
StartTLS bool `yaml:"starttls,omitempty"`
248+
Expect Regexp `yaml:"expect,omitempty" json:"expect,omitempty"`
249+
Labels []Label `yaml:"labels,omitempty" json:"labels,omitempty"`
250+
Send string `yaml:"send,omitempty" json:"send,omitempty"`
251+
StartTLS bool `yaml:"starttls,omitempty" json:"starttls,omitempty"`
252252
}
253253

254254
type TCPProbe struct {
255-
IPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
256-
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
257-
SourceIPAddress string `yaml:"source_ip_address,omitempty"`
258-
QueryResponse []QueryResponse `yaml:"query_response,omitempty"`
259-
TLS bool `yaml:"tls,omitempty"`
260-
TLSConfig config.TLSConfig `yaml:"tls_config,omitempty"`
255+
IPProtocol string `yaml:"preferred_ip_protocol,omitempty" json:"preferred_ip_protocol,omitempty"`
256+
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty" json:"ip_protocol_fallback,omitempty"`
257+
SourceIPAddress string `yaml:"source_ip_address,omitempty" json:"source_ip_address,omitempty"`
258+
QueryResponse []QueryResponse `yaml:"query_response,omitempty" json:"query_response,omitempty"`
259+
TLS bool `yaml:"tls,omitempty" json:"tls,omitempty"`
260+
TLSConfig config.TLSConfig `yaml:"tls_config,omitempty" json:"tls_config,omitempty"`
261261
}
262262

263263
type ICMPProbe struct {
264-
IPProtocol string `yaml:"preferred_ip_protocol,omitempty"` // Defaults to "ip6".
265-
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
266-
SourceIPAddress string `yaml:"source_ip_address,omitempty"`
267-
PayloadSize int `yaml:"payload_size,omitempty"`
268-
DontFragment bool `yaml:"dont_fragment,omitempty"`
269-
TTL int `yaml:"ttl,omitempty"`
264+
IPProtocol string `yaml:"preferred_ip_protocol,omitempty" json:"preferred_ip_protocol,omitempty"` // Defaults to "ip6".
265+
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty" json:"ip_protocol_fallback,omitempty"`
266+
SourceIPAddress string `yaml:"source_ip_address,omitempty" json:"source_ip_address,omitempty"`
267+
PayloadSize int `yaml:"payload_size,omitempty" json:"payload_size,omitempty"`
268+
DontFragment bool `yaml:"dont_fragment,omitempty" json:"dont_fragment,omitempty"`
269+
TTL int `yaml:"ttl,omitempty" json:"ttl,omitempty"`
270270
}
271271

272272
type DNSProbe struct {
273-
IPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
274-
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
275-
DNSOverTLS bool `yaml:"dns_over_tls,omitempty"`
276-
TLSConfig config.TLSConfig `yaml:"tls_config,omitempty"`
277-
SourceIPAddress string `yaml:"source_ip_address,omitempty"`
278-
TransportProtocol string `yaml:"transport_protocol,omitempty"`
279-
QueryClass string `yaml:"query_class,omitempty"` // Defaults to IN.
280-
QueryName string `yaml:"query_name,omitempty"`
281-
QueryType string `yaml:"query_type,omitempty"` // Defaults to ANY.
282-
Recursion bool `yaml:"recursion_desired,omitempty"` // Defaults to true.
283-
ValidRcodes []string `yaml:"valid_rcodes,omitempty"` // Defaults to NOERROR.
284-
ValidateAnswer DNSRRValidator `yaml:"validate_answer_rrs,omitempty"`
285-
ValidateAuthority DNSRRValidator `yaml:"validate_authority_rrs,omitempty"`
286-
ValidateAdditional DNSRRValidator `yaml:"validate_additional_rrs,omitempty"`
273+
IPProtocol string `yaml:"preferred_ip_protocol,omitempty" json:"preferred_ip_protocol,omitempty"`
274+
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty" json:"ip_protocol_fallback,omitempty"`
275+
DNSOverTLS bool `yaml:"dns_over_tls,omitempty" json:"dns_over_tls,omitempty"`
276+
TLSConfig config.TLSConfig `yaml:"tls_config,omitempty" json:"tls_config,omitempty"`
277+
SourceIPAddress string `yaml:"source_ip_address,omitempty" json:"source_ip_address,omitempty"`
278+
TransportProtocol string `yaml:"transport_protocol,omitempty" json:"transport_protocol,omitempty"`
279+
QueryClass string `yaml:"query_class,omitempty" json:"query_class,omitempty"` // Defaults to IN.
280+
QueryName string `yaml:"query_name,omitempty" json:"query_name,omitempty"`
281+
QueryType string `yaml:"query_type,omitempty" json:"query_type,omitempty"` // Defaults to ANY.
282+
Recursion bool `yaml:"recursion_desired,omitempty" json:"recursion_desired,omitempty"` // Defaults to true.
283+
ValidRcodes []string `yaml:"valid_rcodes,omitempty" json:"valid_rcodes,omitempty"` // Defaults to NOERROR.
284+
ValidateAnswer DNSRRValidator `yaml:"validate_answer_rrs,omitempty" json:"validate_answer_rrs,omitempty"`
285+
ValidateAuthority DNSRRValidator `yaml:"validate_authority_rrs,omitempty" json:"validate_authority_rrs,omitempty"`
286+
ValidateAdditional DNSRRValidator `yaml:"validate_additional_rrs,omitempty" json:"validate_additional_rrs,omitempty"`
287287
}
288288

289289
type DNSRRValidator struct {
290-
FailIfMatchesRegexp []string `yaml:"fail_if_matches_regexp,omitempty"`
291-
FailIfAllMatchRegexp []string `yaml:"fail_if_all_match_regexp,omitempty"`
292-
FailIfNotMatchesRegexp []string `yaml:"fail_if_not_matches_regexp,omitempty"`
293-
FailIfNoneMatchesRegexp []string `yaml:"fail_if_none_matches_regexp,omitempty"`
290+
FailIfMatchesRegexp []string `yaml:"fail_if_matches_regexp,omitempty" json:"fail_if_matches_regexp,omitempty"`
291+
FailIfAllMatchRegexp []string `yaml:"fail_if_all_match_regexp,omitempty" json:"fail_if_all_match_regexp,omitempty"`
292+
FailIfNotMatchesRegexp []string `yaml:"fail_if_not_matches_regexp,omitempty" json:"fail_if_not_matches_regexp,omitempty"`
293+
FailIfNoneMatchesRegexp []string `yaml:"fail_if_none_matches_regexp,omitempty" json:"fail_if_none_matches_regexp,omitempty"`
294294
}
295295

296296
// UnmarshalYAML implements the yaml.Unmarshaler interface.

0 commit comments

Comments
 (0)