From 2506b9448a4ec97f92c2c8556efdd52741658899 Mon Sep 17 00:00:00 2001 From: Ahmed Elsabbahy Date: Mon, 11 Sep 2017 23:14:33 -0400 Subject: [PATCH] Fix spelling of resolveable -> resolvable (#284) * Fix spelling of resolveable -> resolvable (make it backwards compatible for now) * Update expected generated tests with "resolvable" * Update rest of tests, now that I've confirmed it is backward compatible --- docs/manual.md | 14 +++++----- .../goss/alpine3/goss-expected-q.yaml | 18 ++++++------- .../goss/alpine3/goss-expected.yaml | 18 ++++++------- .../goss/centos7/goss-expected-q.yaml | 18 ++++++------- .../goss/centos7/goss-expected.yaml | 18 ++++++------- integration-tests/goss/goss-shared.yaml | 22 ++++++++-------- .../goss/precise/goss-expected-q.yaml | 18 ++++++------- .../goss/precise/goss-expected.yaml | 18 ++++++------- .../goss/wheezy/goss-expected-q.yaml | 18 ++++++------- .../goss/wheezy/goss-expected.yaml | 18 ++++++------- resource/dns.go | 19 +++++++++----- system/dns.go | 26 +++++++++---------- 12 files changed, 115 insertions(+), 110 deletions(-) diff --git a/docs/manual.md b/docs/manual.md index 6d0d6ee4d..3f938f0ff 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -297,7 +297,7 @@ $ curl localhost:8080/healthz ```bash $ goss validate --format documentation File: /etc/hosts: exists: matches expectation: [true] -DNS: localhost: resolveable: matches expectation: [true] +DNS: localhost: resolvable: matches expectation: [true] [...] Total Duration: 0.002s Count: 10, Failed: 2, Skipped: 0 @@ -439,13 +439,13 @@ command: ### dns -Validates that the provided address is resolveable and the addrs it resolves to. +Validates that the provided address is resolvable and the addrs it resolves to. ```yaml dns: localhost: # required attributes - resolveable: true + resolvable: true # optional attributes server: 8.8.8.8 addrs: @@ -472,21 +472,21 @@ To validate specific DNS address types, prepend the hostname with the type and a dns: # Validate a CNAME record CNAME:dnstest.github.io: - resolveable: true + resolvable: true server: 8.8.8.8 addrs: - "github.map.fastly.net." # Validate a PTR record PTR:8.8.8.8: - resolveable: true + resolvable: true server: 8.8.8.8 addrs: - "google-public-dns-a.google.com." # Validate and SRV record SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true server: 8.8.8.8 addrs: - "0 5 443 a.dnstest.io." @@ -498,7 +498,7 @@ Please note that if you want `localhost` to **only** resolve `127.0.0.1` you'll ```yaml dns: localhost: - resolveable: true + resolvable: true addrs: consist-of: [127.0.0.1] timeout: 500 # in milliseconds diff --git a/integration-tests/goss/alpine3/goss-expected-q.yaml b/integration-tests/goss/alpine3/goss-expected-q.yaml index f0a3679fb..7497a23f0 100644 --- a/integration-tests/goss/alpine3/goss-expected-q.yaml +++ b/integration-tests/goss/alpine3/goss-expected-q.yaml @@ -56,39 +56,39 @@ command: timeout: 10000 dns: CAA:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 CNAME:c.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 MX:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 NS:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 PTR:8.8.8.8: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 TXT:txt._test.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 ip6.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 localhost: - resolveable: true + resolvable: true timeout: 1000 process: apache2: diff --git a/integration-tests/goss/alpine3/goss-expected.yaml b/integration-tests/goss/alpine3/goss-expected.yaml index dbd0f507a..f8c88546c 100644 --- a/integration-tests/goss/alpine3/goss-expected.yaml +++ b/integration-tests/goss/alpine3/goss-expected.yaml @@ -70,7 +70,7 @@ command: timeout: 10000 dns: CAA:dnstest.io: - resolveable: true + resolvable: true addrs: - 0 issue comodoca.com - 0 issue letsencrypt.org @@ -78,52 +78,52 @@ dns: timeout: 1000 server: 8.8.8.8 CNAME:c.dnstest.io: - resolveable: true + resolvable: true addrs: - a.dnstest.io. timeout: 1000 server: 8.8.8.8 MX:dnstest.io: - resolveable: true + resolvable: true addrs: - 10 b.dnstest.io. - 5 a.dnstest.io. timeout: 1000 server: 8.8.8.8 NS:dnstest.io: - resolveable: true + resolvable: true addrs: - ns1.dnstest.io. - ns2.dnstest.io. timeout: 1000 server: 8.8.8.8 PTR:8.8.8.8: - resolveable: true + resolvable: true addrs: - google-public-dns-a.google.com. timeout: 1000 server: 8.8.8.8 SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true addrs: - 0 5 443 a.dnstest.io. - 10 10 443 b.dnstest.io. timeout: 1000 server: 8.8.8.8 TXT:txt._test.dnstest.io: - resolveable: true + resolvable: true addrs: - Hello DNS timeout: 1000 server: 8.8.8.8 ip6.dnstest.io: - resolveable: true + resolvable: true addrs: - 2404:6800:4001:807::200e timeout: 1000 server: 8.8.8.8 localhost: - resolveable: true + resolvable: true addrs: - 127.0.0.1 - ::1 diff --git a/integration-tests/goss/centos7/goss-expected-q.yaml b/integration-tests/goss/centos7/goss-expected-q.yaml index 13aa22c56..efab615ca 100644 --- a/integration-tests/goss/centos7/goss-expected-q.yaml +++ b/integration-tests/goss/centos7/goss-expected-q.yaml @@ -56,39 +56,39 @@ command: timeout: 10000 dns: CAA:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 CNAME:c.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 MX:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 NS:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 PTR:8.8.8.8: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 TXT:txt._test.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 ip6.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 localhost: - resolveable: true + resolvable: true timeout: 1000 process: foobar: diff --git a/integration-tests/goss/centos7/goss-expected.yaml b/integration-tests/goss/centos7/goss-expected.yaml index f98e6e371..e17d1fe86 100644 --- a/integration-tests/goss/centos7/goss-expected.yaml +++ b/integration-tests/goss/centos7/goss-expected.yaml @@ -76,7 +76,7 @@ command: timeout: 10000 dns: CAA:dnstest.io: - resolveable: true + resolvable: true addrs: - 0 issue comodoca.com - 0 issue letsencrypt.org @@ -84,52 +84,52 @@ dns: timeout: 1000 server: 8.8.8.8 CNAME:c.dnstest.io: - resolveable: true + resolvable: true addrs: - a.dnstest.io. timeout: 1000 server: 8.8.8.8 MX:dnstest.io: - resolveable: true + resolvable: true addrs: - 10 b.dnstest.io. - 5 a.dnstest.io. timeout: 1000 server: 8.8.8.8 NS:dnstest.io: - resolveable: true + resolvable: true addrs: - ns1.dnstest.io. - ns2.dnstest.io. timeout: 1000 server: 8.8.8.8 PTR:8.8.8.8: - resolveable: true + resolvable: true addrs: - google-public-dns-a.google.com. timeout: 1000 server: 8.8.8.8 SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true addrs: - 0 5 443 a.dnstest.io. - 10 10 443 b.dnstest.io. timeout: 1000 server: 8.8.8.8 TXT:txt._test.dnstest.io: - resolveable: true + resolvable: true addrs: - Hello DNS timeout: 1000 server: 8.8.8.8 ip6.dnstest.io: - resolveable: true + resolvable: true addrs: - 2404:6800:4001:807::200e timeout: 1000 server: 8.8.8.8 localhost: - resolveable: true + resolvable: true addrs: - 127.0.0.1 - ::1 diff --git a/integration-tests/goss/goss-shared.yaml b/integration-tests/goss/goss-shared.yaml index 83af6cb9c..a18404aa7 100644 --- a/integration-tests/goss/goss-shared.yaml +++ b/integration-tests/goss/goss-shared.yaml @@ -63,7 +63,7 @@ group: exists: false dns: CAA:dnstest.io: - resolveable: true + resolvable: true addrs: - 0 issue comodoca.com - 0 issue letsencrypt.org @@ -71,64 +71,64 @@ dns: timeout: 2000 server: 8.8.8.8 CNAME:c.dnstest.io: - resolveable: true + resolvable: true addrs: - a.dnstest.io. timeout: 2000 server: 8.8.8.8 c.dnstest.io: - resolveable: true + resolvable: true addrs: - 192.30.252.153 timeout: 2000 server: 8.8.8.8 MX:dnstest.io: - resolveable: true + resolvable: true addrs: - 10 b.dnstest.io. - 5 a.dnstest.io. timeout: 2000 server: 8.8.8.8 NS:dnstest.io: - resolveable: true + resolvable: true addrs: - ns1.dnstest.io. - ns2.dnstest.io. timeout: 2000 server: 8.8.8.8 PTR:8.8.8.8: - resolveable: true + resolvable: true addrs: - google-public-dns-a.google.com. timeout: 2000 server: 8.8.8.8 SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true addrs: - 0 5 443 a.dnstest.io. - 10 10 443 b.dnstest.io. timeout: 2000 server: 8.8.8.8 TXT:txt._test.dnstest.io: - resolveable: true + resolvable: true addrs: - Hello DNS timeout: 2000 server: 8.8.8.8 ip6.dnstest.io: - resolveable: true + resolvable: true addrs: - 2404:6800:4001:807::200e timeout: 2000 server: 8.8.8.8 localhost: - resolveable: true + resolvable: true addrs: - 127.0.0.1 - "::1" timeout: 2000 dnstest.io: - resolveable: true + resolvable: true server: 8.8.8.8 timeout: 2000 process: diff --git a/integration-tests/goss/precise/goss-expected-q.yaml b/integration-tests/goss/precise/goss-expected-q.yaml index 1d187772e..4b65adba6 100644 --- a/integration-tests/goss/precise/goss-expected-q.yaml +++ b/integration-tests/goss/precise/goss-expected-q.yaml @@ -56,39 +56,39 @@ command: timeout: 10000 dns: CAA:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 CNAME:c.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 MX:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 NS:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 PTR:8.8.8.8: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 TXT:txt._test.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 ip6.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 localhost: - resolveable: true + resolvable: true timeout: 1000 process: apache2: diff --git a/integration-tests/goss/precise/goss-expected.yaml b/integration-tests/goss/precise/goss-expected.yaml index 714fda288..9d02dbb3d 100644 --- a/integration-tests/goss/precise/goss-expected.yaml +++ b/integration-tests/goss/precise/goss-expected.yaml @@ -76,7 +76,7 @@ command: timeout: 10000 dns: CAA:dnstest.io: - resolveable: true + resolvable: true addrs: - 0 issue comodoca.com - 0 issue letsencrypt.org @@ -84,52 +84,52 @@ dns: timeout: 1000 server: 8.8.8.8 CNAME:c.dnstest.io: - resolveable: true + resolvable: true addrs: - a.dnstest.io. timeout: 1000 server: 8.8.8.8 MX:dnstest.io: - resolveable: true + resolvable: true addrs: - 10 b.dnstest.io. - 5 a.dnstest.io. timeout: 1000 server: 8.8.8.8 NS:dnstest.io: - resolveable: true + resolvable: true addrs: - ns1.dnstest.io. - ns2.dnstest.io. timeout: 1000 server: 8.8.8.8 PTR:8.8.8.8: - resolveable: true + resolvable: true addrs: - google-public-dns-a.google.com. timeout: 1000 server: 8.8.8.8 SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true addrs: - 0 5 443 a.dnstest.io. - 10 10 443 b.dnstest.io. timeout: 1000 server: 8.8.8.8 TXT:txt._test.dnstest.io: - resolveable: true + resolvable: true addrs: - Hello DNS timeout: 1000 server: 8.8.8.8 ip6.dnstest.io: - resolveable: true + resolvable: true addrs: - 2404:6800:4001:807::200e timeout: 1000 server: 8.8.8.8 localhost: - resolveable: true + resolvable: true addrs: - 127.0.0.1 - ::1 diff --git a/integration-tests/goss/wheezy/goss-expected-q.yaml b/integration-tests/goss/wheezy/goss-expected-q.yaml index bb6dca2ee..7a96a694f 100644 --- a/integration-tests/goss/wheezy/goss-expected-q.yaml +++ b/integration-tests/goss/wheezy/goss-expected-q.yaml @@ -56,39 +56,39 @@ command: timeout: 10000 dns: CAA:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 CNAME:c.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 MX:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 NS:dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 PTR:8.8.8.8: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 TXT:txt._test.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 ip6.dnstest.io: - resolveable: true + resolvable: true timeout: 1000 server: 8.8.8.8 localhost: - resolveable: true + resolvable: true timeout: 1000 process: apache2: diff --git a/integration-tests/goss/wheezy/goss-expected.yaml b/integration-tests/goss/wheezy/goss-expected.yaml index 636dd6d29..e451c17fb 100644 --- a/integration-tests/goss/wheezy/goss-expected.yaml +++ b/integration-tests/goss/wheezy/goss-expected.yaml @@ -76,7 +76,7 @@ command: timeout: 10000 dns: CAA:dnstest.io: - resolveable: true + resolvable: true addrs: - 0 issue comodoca.com - 0 issue letsencrypt.org @@ -84,52 +84,52 @@ dns: timeout: 1000 server: 8.8.8.8 CNAME:c.dnstest.io: - resolveable: true + resolvable: true addrs: - a.dnstest.io. timeout: 1000 server: 8.8.8.8 MX:dnstest.io: - resolveable: true + resolvable: true addrs: - 10 b.dnstest.io. - 5 a.dnstest.io. timeout: 1000 server: 8.8.8.8 NS:dnstest.io: - resolveable: true + resolvable: true addrs: - ns1.dnstest.io. - ns2.dnstest.io. timeout: 1000 server: 8.8.8.8 PTR:8.8.8.8: - resolveable: true + resolvable: true addrs: - google-public-dns-a.google.com. timeout: 1000 server: 8.8.8.8 SRV:_https._tcp.dnstest.io: - resolveable: true + resolvable: true addrs: - 0 5 443 a.dnstest.io. - 10 10 443 b.dnstest.io. timeout: 1000 server: 8.8.8.8 TXT:txt._test.dnstest.io: - resolveable: true + resolvable: true addrs: - Hello DNS timeout: 1000 server: 8.8.8.8 ip6.dnstest.io: - resolveable: true + resolvable: true addrs: - 2404:6800:4001:807::200e timeout: 1000 server: 8.8.8.8 localhost: - resolveable: true + resolvable: true addrs: - 127.0.0.1 - ::1 diff --git a/resource/dns.go b/resource/dns.go index b7fb4ee3f..0dfcec476 100644 --- a/resource/dns.go +++ b/resource/dns.go @@ -11,7 +11,8 @@ type DNS struct { Title string `json:"title,omitempty" yaml:"title,omitempty"` Meta meta `json:"meta,omitempty" yaml:"meta,omitempty"` Host string `json:"-" yaml:"-"` - Resolveable matcher `json:"resolveable" yaml:"resolveable"` + Resolveable matcher `json:"resolveable,omitempty" yaml:"resolveable,omitempty"` + Resolvable matcher `json:"resolvable" yaml:"resolvable"` Addrs matcher `json:"addrs,omitempty" yaml:"addrs,omitempty"` Timeout int `json:"timeout" yaml:"timeout"` Server string `json:"server,omitempty" yaml:"server,omitempty"` @@ -32,7 +33,11 @@ func (d *DNS) Validate(sys *system.System) []TestResult { sysDNS := sys.NewDNS(d.Host, sys, util.Config{Timeout: d.Timeout, Server: d.Server}) var results []TestResult - results = append(results, ValidateValue(d, "resolveable", d.Resolveable, sysDNS.Resolveable, skip)) + // Backwards copatibility hack for now + if d.Resolvable == nil { + d.Resolvable = d.Resolveable + } + results = append(results, ValidateValue(d, "resolvable", d.Resolvable, sysDNS.Resolvable, skip)) if shouldSkip(results) { skip = true } @@ -50,14 +55,14 @@ func NewDNS(sysDNS system.DNS, config util.Config) (*DNS, error) { host = sysDNS.Host() } - resolveable, err := sysDNS.Resolveable() + resolvable, err := sysDNS.Resolvable() server := sysDNS.Server() d := &DNS{ - Host: host, - Resolveable: resolveable, - Timeout: config.Timeout, - Server: server, + Host: host, + Resolvable: resolvable, + Timeout: config.Timeout, + Server: server, } if !contains(config.IgnoreList, "addrs") { addrs, _ := sysDNS.Addrs() diff --git a/system/dns.go b/system/dns.go index af70b805d..2db0dbb90 100644 --- a/system/dns.go +++ b/system/dns.go @@ -15,21 +15,21 @@ import ( type DNS interface { Host() string Addrs() ([]string, error) - Resolveable() (bool, error) + Resolvable() (bool, error) Exists() (bool, error) Server() string Qtype() string } type DefDNS struct { - host string - resolveable bool - addrs []string - Timeout int - loaded bool - err error - server string - qtype string + host string + resolvable bool + addrs []string + Timeout int + loaded bool + err error + server string + qtype string } func NewDefDNS(host string, system *System, config util.Config) DNS { @@ -70,7 +70,7 @@ func (d *DefDNS) setup() error { for i := 0; i < 3; i++ { addrs, err := DNSlookup(d.host, d.server, d.qtype, d.Timeout) if err != nil || len(addrs) == 0 { - d.resolveable = false + d.resolvable = false d.addrs = []string{} // DNSError is resolvable == false, ignore error if _, ok := err.(*net.DNSError); ok { @@ -80,7 +80,7 @@ func (d *DefDNS) setup() error { continue } sort.Strings(addrs) - d.resolveable = true + d.resolvable = true d.addrs = addrs d.err = nil return nil @@ -94,10 +94,10 @@ func (d *DefDNS) Addrs() ([]string, error) { return d.addrs, err } -func (d *DefDNS) Resolveable() (bool, error) { +func (d *DefDNS) Resolvable() (bool, error) { err := d.setup() - return d.resolveable, err + return d.resolvable, err } // Stub out