diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 2de26c9cf..b174a3943 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -526,7 +526,7 @@ func makeRec(name, target, typ string) *models.RecordConfig { return r } -//func (r *models.RecordConfig) ttl(t uint32) *models.RecordConfig { +// func (r *models.RecordConfig) ttl(t uint32) *models.RecordConfig { func ttl(r *models.RecordConfig, t uint32) *models.RecordConfig { r.TTL = t return r diff --git a/models/record.go b/models/record.go index 997a8d1a1..47fb33f1e 100644 --- a/models/record.go +++ b/models/record.go @@ -15,66 +15,74 @@ import ( // RecordConfig stores a DNS record. // Valid types: -// Official: (alphabetical) -// A -// AAAA -// ANAME // Technically not an official rtype yet. -// CAA -// CNAME -// MX -// NAPTR -// NS -// PTR -// SOA -// SRV -// SSHFP -// TLSA -// TXT -// Pseudo-Types: (alphabetical) -// ALIAS -// CF_REDIRECT -// CF_TEMP_REDIRECT -// CF_WORKER_ROUTE -// CLOUDNS_WR -// FRAME -// IMPORT_TRANSFORM -// NAMESERVER -// NO_PURGE -// NS1_URLFWD -// PAGE_RULE -// PURGE -// URL -// URL301 -// WORKER_ROUTE +// +// Official: (alphabetical) +// A +// AAAA +// ANAME // Technically not an official rtype yet. +// CAA +// CNAME +// MX +// NAPTR +// NS +// PTR +// SOA +// SRV +// SSHFP +// TLSA +// TXT +// Pseudo-Types: (alphabetical) +// ALIAS +// CF_REDIRECT +// CF_TEMP_REDIRECT +// CF_WORKER_ROUTE +// CLOUDNS_WR +// FRAME +// IMPORT_TRANSFORM +// NAMESERVER +// NO_PURGE +// NS1_URLFWD +// PAGE_RULE +// PURGE +// URL +// URL301 +// WORKER_ROUTE // // Notes about the fields: // // Name: -// This is the shortname i.e. the NameFQDN without the origin suffix. -// It should never have a trailing "." -// It should never be null. The apex (naked domain) is stored as "@". -// If the origin is "foo.com." and Name is "foo.com", this literally means -// the intended FQDN is "foo.com.foo.com." (which may look odd) +// +// This is the shortname i.e. the NameFQDN without the origin suffix. +// It should never have a trailing "." +// It should never be null. The apex (naked domain) is stored as "@". +// If the origin is "foo.com." and Name is "foo.com", this literally means +// the intended FQDN is "foo.com.foo.com." (which may look odd) +// // NameFQDN: -// This is the FQDN version of Name. -// It should never have a trailing ".". -// NOTE: Eventually we will unexport Name/NameFQDN. Please start using -// the setters (SetLabel/SetLabelFromFQDN) and getters (GetLabel/GetLabelFQDN). -// as they will always work. +// +// This is the FQDN version of Name. +// It should never have a trailing ".". +// NOTE: Eventually we will unexport Name/NameFQDN. Please start using +// the setters (SetLabel/SetLabelFromFQDN) and getters (GetLabel/GetLabelFQDN). +// as they will always work. +// // target: -// This is the host or IP address of the record, with -// the other related parameters (weight, priority, etc.) stored in individual -// fields. -// NOTE: Eventually we will unexport Target. Please start using the -// setters (SetTarget*) and getters (GetTarget*) as they will always work. +// +// This is the host or IP address of the record, with +// the other related parameters (weight, priority, etc.) stored in individual +// fields. +// NOTE: Eventually we will unexport Target. Please start using the +// setters (SetTarget*) and getters (GetTarget*) as they will always work. +// // SubDomain: -// This is the subdomain path, if any, imported from the configuration. If -// present at the time of canonicalization it is inserted between the -// Name and origin when constructing a canonical (FQDN) target. +// +// This is the subdomain path, if any, imported from the configuration. If +// present at the time of canonicalization it is inserted between the +// Name and origin when constructing a canonical (FQDN) target. // // Idioms: -// rec.Label() == "@" // Is this record at the apex? // +// rec.Label() == "@" // Is this record at the apex? type RecordConfig struct { Type string `json:"type"` // All caps rtype name. Name string `json:"name"` // The short name. See above. @@ -214,10 +222,13 @@ func (rc *RecordConfig) Copy() (*RecordConfig, error) { // SetLabel sets the .Name/.NameFQDN fields given a short name and origin. // origin must not have a trailing dot: The entire code base -// maintains dc.Name without the trailig dot. Finding a dot here means -// something is very wrong. +// +// maintains dc.Name without the trailig dot. Finding a dot here means +// something is very wrong. +// // short must not have a training dot: That would mean you have -// a FQDN, and shouldn't be using SetLabel(). Maybe SetLabelFromFQDN()? +// +// a FQDN, and shouldn't be using SetLabel(). Maybe SetLabelFromFQDN()? func (rc *RecordConfig) SetLabel(short, origin string) { // Assertions that make sure the function is being used correctly: @@ -277,7 +288,9 @@ func (rc *RecordConfig) SetLabelFromFQDN(fqdn, origin string) { // GetLabel returns the shortname of the label associated with this RecordConfig. // It will never end with "." // It does not need further shortening (i.e. if it returns "foo.com" and the -// domain is "foo.com" then the FQDN is actually "foo.com.foo.com"). +// +// domain is "foo.com" then the FQDN is actually "foo.com.foo.com"). +// // It will never be "" (the apex is returned as "@"). func (rc *RecordConfig) GetLabel() string { return rc.Name diff --git a/models/t_parse.go b/models/t_parse.go index 18944dc24..33347cb9e 100644 --- a/models/t_parse.go +++ b/models/t_parse.go @@ -14,24 +14,24 @@ import ( // // Recommended calling convention: Process the exceptions first, then use the // function for everything else. -// var err error -// switch rType { -// case "MX": -// // MX priority in a separate field. -// if err := rc.SetTargetMX(cr.Priority, target); err != nil { -// return nil, fmt.Errorf("unparsable MX record received from cloudflare: %w", err) -// } -// case "TXT": -// // TXT records are stored verbatim; no quoting/escaping to parse. -// err = rc.SetTargetTXT(target) -// // ProTip: Use rc.SetTargetTXTs(manystrings) if the API or parser returns a list of substrings. -// default: -// err = rec.PopulateFromString(rType, target, origin) -// } -// if err != nil { -// return nil, fmt.Errorf("unparsable record received from CHANGE_TO_PROVDER_NAME: %w", err) -// } // +// var err error +// switch rType { +// case "MX": +// // MX priority in a separate field. +// if err := rc.SetTargetMX(cr.Priority, target); err != nil { +// return nil, fmt.Errorf("unparsable MX record received from cloudflare: %w", err) +// } +// case "TXT": +// // TXT records are stored verbatim; no quoting/escaping to parse. +// err = rc.SetTargetTXT(target) +// // ProTip: Use rc.SetTargetTXTs(manystrings) if the API or parser returns a list of substrings. +// default: +// err = rec.PopulateFromString(rType, target, origin) +// } +// if err != nil { +// return nil, fmt.Errorf("unparsable record received from CHANGE_TO_PROVDER_NAME: %w", err) +// } func (rc *RecordConfig) PopulateFromString(rtype, contents, origin string) error { if rc.Type != "" && rc.Type != rtype { panic(fmt.Errorf("assertion failed: rtype already set (%s) (%s)", rtype, rc.Type)) diff --git a/models/t_txt.go b/models/t_txt.go index 2dbe0a777..0554258de 100644 --- a/models/t_txt.go +++ b/models/t_txt.go @@ -155,10 +155,11 @@ func (rc *RecordConfig) GetTargetTXTJoined() string { // SetTargetTXTString is like SetTargetTXTs but accepts one big string, // which is parsed into individual strings. // Ex: foo << 1 string -// foo bar << 1 string -// "foo bar" << 1 string -// "foo" "bar" << 2 strings -// "f"oo" "bar" << 2 strings, one has a quote in it +// +// foo bar << 1 string +// "foo bar" << 1 string +// "foo" "bar" << 2 strings +// "f"oo" "bar" << 2 strings, one has a quote in it // // BUG: This function doesn't handle escaped quotes ("like \" this"). // @@ -182,9 +183,10 @@ func (rc *RecordConfig) SetTargetTXTString(s string) error { // and sets .TxtStrings based on the result. // Note: Most APIs do notThis is rarely used. Try using SetTargetTXT() first. // Ex: "foo" << 1 string -// "foo bar" << 1 string -// "foo" "bar" << 2 strings -// foo << error. No quotes! Did you intend to use SetTargetTXT? +// +// "foo bar" << 1 string +// "foo" "bar" << 2 strings +// foo << error. No quotes! Did you intend to use SetTargetTXT? func (rc *RecordConfig) SetTargetTXTfromRFC1035Quoted(s string) error { if s != "" && s[0] != '"' { // If you get this error, it is likely that you should use diff --git a/pkg/credsfile/providerConfig.go b/pkg/credsfile/providerConfig.go index c9f698657..95bfe5836 100644 --- a/pkg/credsfile/providerConfig.go +++ b/pkg/credsfile/providerConfig.go @@ -1,7 +1,8 @@ // Package credsfile provides functions for reading and parsing the provider credentials json file. // It cleans nonstandard json features (comments and trailing commas), as well as replaces environment variable placeholders with // their environment variable equivalents. To reference an environment variable in your json file, simply use values in this format: -// "key"="$ENV_VAR_NAME" +// +// "key"="$ENV_VAR_NAME" package credsfile import ( diff --git a/providers/cloudns/cloudnsProvider.go b/providers/cloudns/cloudnsProvider.go index 2f54ef516..4e5864693 100644 --- a/providers/cloudns/cloudnsProvider.go +++ b/providers/cloudns/cloudnsProvider.go @@ -210,7 +210,7 @@ func (c *cloudnsProvider) EnsureDomainExists(domain string) error { return c.createDomain(domain) } -//parses the ClouDNS format into our standard RecordConfig +// parses the ClouDNS format into our standard RecordConfig func toRc(domain string, r *domainRecord) *models.RecordConfig { ttl, _ := strconv.ParseUint(r.TTL, 10, 32) @@ -269,7 +269,7 @@ func toRc(domain string, r *domainRecord) *models.RecordConfig { return rc } -//toReq takes a RecordConfig and turns it into the native format used by the API. +// toReq takes a RecordConfig and turns it into the native format used by the API. func toReq(rc *models.RecordConfig) (requestParams, error) { req := requestParams{ "record-type": rc.Type, diff --git a/providers/desec/protocol.go b/providers/desec/protocol.go index eb11376ed..d39c5fcc2 100644 --- a/providers/desec/protocol.go +++ b/providers/desec/protocol.go @@ -121,7 +121,7 @@ func (c *desecProvider) initializeDomainIndex() error { return err } -//buildIndexFromResponse takes the bodyString from initializeDomainIndex and builds the domainIndex +// buildIndexFromResponse takes the bodyString from initializeDomainIndex and builds the domainIndex func (c *desecProvider) buildIndexFromResponse(bodyString []byte) error { if c.domainIndex == nil { c.domainIndex = map[string]uint32{} @@ -139,7 +139,7 @@ func (c *desecProvider) buildIndexFromResponse(bodyString []byte) error { return nil } -//Parses the Link Header into a map (https://github.com/desec-io/desec-tools/blob/master/fetch_zone.py#L13) +// Parses the Link Header into a map (https://github.com/desec-io/desec-tools/blob/master/fetch_zone.py#L13) func (c *desecProvider) convertLinks(links string) map[string]string { mapping := make(map[string]string) printer.Debugf("Header: %s\n", links) @@ -204,7 +204,7 @@ func (c *desecProvider) getRecords(domain string) ([]resourceRecord, error) { return rrsNew, nil } -//generateRRSETfromResponse takes the response rrset api calls and returns []resourceRecord +// generateRRSETfromResponse takes the response rrset api calls and returns []resourceRecord func generateRRSETfromResponse(bodyString []byte) ([]resourceRecord, error) { var rrs []rrResponse var rrsNew []resourceRecord @@ -245,7 +245,7 @@ func (c *desecProvider) createDomain(domain string) error { return nil } -//upsertRR will create or override the RRSet with the provided resource record. +// upsertRR will create or override the RRSet with the provided resource record. func (c *desecProvider) upsertRR(rr []resourceRecord, domain string) error { endpoint := fmt.Sprintf("/domains/%s/rrsets/", domain) byt, _ := json.Marshal(rr) diff --git a/providers/domainnameshop/domainnameshopProvider.go b/providers/domainnameshop/domainnameshopProvider.go index 1dc97d5d1..0224f4ea8 100644 --- a/providers/domainnameshop/domainnameshopProvider.go +++ b/providers/domainnameshop/domainnameshopProvider.go @@ -75,8 +75,9 @@ type domainResponse struct { } // The Actual fields are the values in the right format according to what is needed for RecordConfig. -// While the values without Actual are the values directly as received from the DomainNameShop API. -// This is done to make it easier to use the values at later points. +// +// While the values without Actual are the values directly as received from the DomainNameShop API. +// This is done to make it easier to use the values at later points. type domainNameShopRecord struct { ID int `json:"id"` Host string `json:"host"` diff --git a/providers/hexonet/domains.go b/providers/hexonet/domains.go index 3021408c2..d61e428dd 100644 --- a/providers/hexonet/domains.go +++ b/providers/hexonet/domains.go @@ -2,7 +2,7 @@ package hexonet import "fmt" -//EnsureDomainExists returns an error +// EnsureDomainExists returns an error // * if access to dnszone is not allowed (not authorized) or // * if it doesn't exist and creating it fails func (n *HXClient) EnsureDomainExists(domain string) error { diff --git a/providers/msdns/msdnsProvider.go b/providers/msdns/msdnsProvider.go index bf8ab7b8b..8c0b5d0a6 100644 --- a/providers/msdns/msdnsProvider.go +++ b/providers/msdns/msdnsProvider.go @@ -34,7 +34,8 @@ var features = providers.DocumentationNotes{ } // Register with the dnscontrol system. -// This establishes the name (all caps), and the function to call to initialize it. +// +// This establishes the name (all caps), and the function to call to initialize it. func init() { fns := providers.DspFuncs{ Initializer: newDNS, diff --git a/providers/namecheap/namecheapProvider.go b/providers/namecheap/namecheapProvider.go index 48f628132..c49d67385 100644 --- a/providers/namecheap/namecheapProvider.go +++ b/providers/namecheap/namecheapProvider.go @@ -82,8 +82,10 @@ func splitDomain(domain string) (sld string, tld string) { // namecheap has request limiting at unpublished limits // from support in SEP-2017: -// "The limits for the API calls will be 20/Min, 700/Hour and 8000/Day for one user. -// If you can limit the requests within these it should be fine." +// +// "The limits for the API calls will be 20/Min, 700/Hour and 8000/Day for one user. +// If you can limit the requests within these it should be fine." +// // this helper performs some api action, checks for rate limited response, and if so, enters a retry loop until it resolves // if you are consistently hitting this, you may have success asking their support to increase your account's limits. func doWithRetry(f func() error) { diff --git a/providers/ns1/ns1Provider.go b/providers/ns1/ns1Provider.go index c95a26ffb..16724855f 100644 --- a/providers/ns1/ns1Provider.go +++ b/providers/ns1/ns1Provider.go @@ -98,9 +98,9 @@ func (n *nsone) GetZoneRecords(domain string) (models.Records, error) { // GetZoneDNSSEC gets DNSSEC status for zone. Returns true for enabled, false for disabled // a domain in NS1 can be in 3 states: -// 1) DNSSEC is enabled (returns true) -// 2) DNSSEC is disabled (returns false) -// 3) some error state (return false plus the error) +// 1. DNSSEC is enabled (returns true) +// 2. DNSSEC is disabled (returns false) +// 3. some error state (return false plus the error) func (n *nsone) GetZoneDNSSEC(domain string) (bool, error) { _, _, err := n.DNSSEC.Get(domain) @@ -222,11 +222,11 @@ func (n *nsone) modify(recs models.Records, domain string) error { // configureDNSSEC configures DNSSEC for a zone. Set 'enabled' to true to enable, false to disable. // There's a cornercase, in which DNSSEC is globally disabled for the account. // In that situation, enabling DNSSEC will always fail with: -// #1: ENABLE DNSSEC -// FAILURE! POST https://api.nsone.net/v1/zones/example.com: 400 DNSSEC support is not enabled for this account. Please contact support@ns1.com to enable it +// +// #1: ENABLE DNSSEC +// FAILURE! POST https://api.nsone.net/v1/zones/example.com: 400 DNSSEC support is not enabled for this account. Please contact support@ns1.com to enable it // // Unfortunately this is not detectable otherwise, so given that we have a nice error message, we just let this through. -// func (n *nsone) configureDNSSEC(domain string, enabled bool) error { z, _, err := n.Zones.Get(domain) if err != nil { diff --git a/providers/octodns/octoyaml/write.go b/providers/octodns/octoyaml/write.go index f2e83ff34..aa54a4652 100644 --- a/providers/octodns/octoyaml/write.go +++ b/providers/octodns/octoyaml/write.go @@ -73,9 +73,10 @@ func (z *genYamlData) genInterfaceList(w io.Writer) yaml.MapSlice { // It may have a single (simple) or multiple (many) values. // Used to generate: -// label: -// type: A -// value: 1.2.3.4 +// +// label: +// type: A +// value: 1.2.3.4 type simple struct { TTL uint32 `yaml:"ttl,omitempty"` Type string `yaml:"type"` @@ -83,11 +84,12 @@ type simple struct { } // Used to generate: -// label: -// type: A -// values: -// - 1.2.3.4 -// - 2.3.4.5 +// +// label: +// type: A +// values: +// - 1.2.3.4 +// - 2.3.4.5 type many struct { TTL uint32 `yaml:"ttl,omitempty"` Type string `yaml:"type"` @@ -102,17 +104,18 @@ type complexItems []interface{} // 'thing': >> complexVals // - type: CNAME // value: newplace.example.com. << value +// // 'www': // - type: A // values: -// - 1.2.3.4 << values -// - 1.2.3.5 << values +// - 1.2.3.4 << values +// - 1.2.3.5 << values // - type: MX // values: -// - priority: 10 << fields -// value: mx1.example.com. << fields -// - priority: 10 << fields -// value: mx2.example.com. << fields +// - priority: 10 << fields +// value: mx1.example.com. << fields +// - priority: 10 << fields +// value: mx2.example.com. << fields type complexVals struct { TTL uint32 `yaml:"ttl,omitempty"` Type string `yaml:"type"`