aboutsummaryrefslogtreecommitdiff
path: root/internal/config/config.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-20 06:54:27 -0800
committerFuwn <[email protected]>2026-01-20 06:54:27 -0800
commitd3094c19da8aa8aa111b19b1ba6a2c48fb18d15d (patch)
tree006e2927ebccf1234ee4cf84c37c186735fd7ec5 /internal/config/config.go
parentfeat: Expand group-level defaults with more monitor options (diff)
downloadkaze-d3094c19da8aa8aa111b19b1ba6a2c48fb18d15d.tar.xz
kaze-d3094c19da8aa8aa111b19b1ba6a2c48fb18d15d.zip
feat: Add all remaining monitor options to group defaults
Support defaulting any monitor option at group level: - expected_content, body (HTTP/HTTPS) - ping_count (ICMP) - dns_server, record_type (DNS) - graphql_query, graphql_variables (GraphQL) - db_type (Database) Only name, type, target, link, reset_on_next_check, expected_ips, and expected_cname remain monitor-specific (not defaultable).
Diffstat (limited to 'internal/config/config.go')
-rw-r--r--internal/config/config.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 5c485d9..d82fee0 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -82,6 +82,18 @@ type MonitorDefaults struct {
UserAgent string `yaml:"user_agent,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
ExpectedStatus *int `yaml:"expected_status,omitempty"`
+ ExpectedContent string `yaml:"expected_content,omitempty"`
+ Body string `yaml:"body,omitempty"`
+ // ICMP specific
+ PingCount *int `yaml:"ping_count,omitempty"`
+ // DNS specific
+ DNSServer string `yaml:"dns_server,omitempty"`
+ RecordType string `yaml:"record_type,omitempty"`
+ // GraphQL specific
+ GraphQLQuery string `yaml:"graphql_query,omitempty"`
+ GraphQLVariables map[string]string `yaml:"graphql_variables,omitempty"`
+ // Database specific
+ DBType string `yaml:"db_type,omitempty"`
}
// MonitorConfig represents a single monitor
@@ -337,6 +349,44 @@ func (c *Config) applyDefaults() {
if m.ExpectedStatus == 0 && grp.Defaults.ExpectedStatus != nil {
m.ExpectedStatus = *grp.Defaults.ExpectedStatus
}
+ // Apply expected_content default
+ if m.ExpectedContent == "" && grp.Defaults.ExpectedContent != "" {
+ m.ExpectedContent = grp.Defaults.ExpectedContent
+ }
+ // Apply body default
+ if m.Body == "" && grp.Defaults.Body != "" {
+ m.Body = grp.Defaults.Body
+ }
+ // Apply ICMP ping_count default
+ if m.PingCount == 0 && grp.Defaults.PingCount != nil {
+ m.PingCount = *grp.Defaults.PingCount
+ }
+ // Apply DNS defaults
+ if m.DNSServer == "" && grp.Defaults.DNSServer != "" {
+ m.DNSServer = grp.Defaults.DNSServer
+ }
+ if m.RecordType == "" && grp.Defaults.RecordType != "" {
+ m.RecordType = grp.Defaults.RecordType
+ }
+ // Apply GraphQL defaults
+ if m.GraphQLQuery == "" && grp.Defaults.GraphQLQuery != "" {
+ m.GraphQLQuery = grp.Defaults.GraphQLQuery
+ }
+ // Apply GraphQL variables (merge, monitor variables take precedence)
+ if len(grp.Defaults.GraphQLVariables) > 0 {
+ if m.GraphQLVariables == nil {
+ m.GraphQLVariables = make(map[string]string)
+ }
+ for k, v := range grp.Defaults.GraphQLVariables {
+ if _, exists := m.GraphQLVariables[k]; !exists {
+ m.GraphQLVariables[k] = v
+ }
+ }
+ }
+ // Apply database type default
+ if m.DBType == "" && grp.Defaults.DBType != "" {
+ m.DBType = grp.Defaults.DBType
+ }
}
}
}