1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

MAINT: Enforcing formatted code (#1544)

* Enforcing formatted code

Signed-off-by: Jan-Philipp Benecke <jan-philipp@bnck.me>

* Show lines

Signed-off-by: Jan-Philipp Benecke <jan-philipp@bnck.me>

* Run check after deps are installed

Signed-off-by: Jan-Philipp Benecke <jan-philipp@bnck.me>
This commit is contained in:
Jan-Philipp Benecke
2022-06-18 14:56:04 +02:00
committed by GitHub
parent 766f37f60d
commit ba2c7f9c0e
6 changed files with 32 additions and 29 deletions

View File

@ -27,6 +27,10 @@ jobs:
keys: keys:
- linux-go-{{ checksum "go.sum" }}-<< pipeline.parameters.cache-key >> - linux-go-{{ checksum "go.sum" }}-<< pipeline.parameters.cache-key >>
- run:
name: Enforce Go Formatted Code
command: "[ `go fmt ./... 2>&1 | wc -l` -eq 0 ]"
- run: - run:
name: Install goreleaser name: Install goreleaser
command: go install github.com/goreleaser/goreleaser@latest command: go install github.com/goreleaser/goreleaser@latest

View File

@ -334,8 +334,8 @@ func TestCheckDuplicates_dup_ns(t *testing.T) {
} }
func TestUniq(t *testing.T) { func TestUniq(t *testing.T) {
a := []uint32 {1, 2, 2, 3, 4, 5, 5, 6} a := []uint32{1, 2, 2, 3, 4, 5, 5, 6}
expected := []uint32 {1, 2, 3, 4, 5, 6} expected := []uint32{1, 2, 3, 4, 5, 6}
r := uniq(a) r := uniq(a)
if !reflect.DeepEqual(r, expected) { if !reflect.DeepEqual(r, expected) {

View File

@ -13,11 +13,11 @@ import (
) )
type ZoneListFilter struct { type ZoneListFilter struct {
Key string `json:"key"` Key string `json:"key"`
Value string `json:"value"` Value string `json:"value"`
Operator string `json:"operator"` Operator string `json:"operator"`
Link string `json:"link,omitempty"` Link string `json:"link,omitempty"`
Filter []*ZoneListFilter `json:"filters,omitempty"` Filter []*ZoneListFilter `json:"filters,omitempty"`
} }
type ZoneListRequest struct { type ZoneListRequest struct {
@ -31,7 +31,7 @@ func (api *autoDnsProvider) request(method string, requestPath string, data inte
requestUrl.Path = api.baseURL.Path + requestPath requestUrl.Path = api.baseURL.Path + requestPath
request := &http.Request{ request := &http.Request{
URL: &requestUrl, URL: &requestUrl,
Header: api.defaultHeaders, Header: api.defaultHeaders,
Method: method, Method: method,
} }
@ -88,7 +88,7 @@ func (api *autoDnsProvider) getZone(domain string) (*Zone, error) {
} }
// if resolving of a systemNameServer succeeds the system contains this zone // if resolving of a systemNameServer succeeds the system contains this zone
var responseData, _ = api.request("GET", "zone/" + domain + "/" + systemNameServer.Name, nil) var responseData, _ = api.request("GET", "zone/"+domain+"/"+systemNameServer.Name, nil)
var responseObject JSONResponseDataZone var responseObject JSONResponseDataZone
// make sure that the response is valid, the zone is in AutoDNS but we're not sure the returned data meets our expectation // make sure that the response is valid, the zone is in AutoDNS but we're not sure the returned data meets our expectation
unmErr := json.Unmarshal(responseData, &responseObject) unmErr := json.Unmarshal(responseData, &responseObject)
@ -128,7 +128,7 @@ func (api *autoDnsProvider) updateZone(domain string, resourceRecords []*Resourc
zone.NameServers = append(zone.NameServers, nameServers...) zone.NameServers = append(zone.NameServers, nameServers...)
var _, putErr = api.request("PUT", "zone/" + domain + "/" + systemNameServer.Name, zone) var _, putErr = api.request("PUT", "zone/"+domain+"/"+systemNameServer.Name, zone)
if putErr != nil { if putErr != nil {
return putErr return putErr

View File

@ -30,8 +30,8 @@ var features = providers.DocumentationNotes{
} }
type autoDnsProvider struct { type autoDnsProvider struct {
baseURL url.URL baseURL url.URL
defaultHeaders http.Header defaultHeaders http.Header
} }
func init() { func init() {
@ -47,18 +47,18 @@ func New(settings map[string]string, _ json.RawMessage) (providers.DNSServicePro
api := &autoDnsProvider{} api := &autoDnsProvider{}
api.baseURL = url.URL{ api.baseURL = url.URL{
Scheme: "https", Scheme: "https",
User: url.UserPassword( User: url.UserPassword(
settings["username"], settings["username"],
settings["password"], settings["password"],
), ),
Host: "api.autodns.com", Host: "api.autodns.com",
Path: "/v1/", Path: "/v1/",
} }
api.defaultHeaders = http.Header{ api.defaultHeaders = http.Header{
"Accept": []string{"application/json; charset=UTF-8"}, "Accept": []string{"application/json; charset=UTF-8"},
"Content-Type": []string{"application/json; charset=UTF-8"}, "Content-Type": []string{"application/json; charset=UTF-8"},
"X-Domainrobot-Context": []string{settings["context"]}, "X-Domainrobot-Context": []string{settings["context"]},
} }
@ -138,8 +138,8 @@ func (api *autoDnsProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mo
} else { } else {
resourceRecord := &ResourceRecord{ resourceRecord := &ResourceRecord{
Name: record.Name, Name: record.Name,
TTL: int64(record.TTL), TTL: int64(record.TTL),
Type: record.Type, Type: record.Type,
Value: record.GetTargetField(), Value: record.GetTargetField(),
} }
@ -212,7 +212,7 @@ func (api *autoDnsProvider) GetZoneRecords(domain string) (models.Records, error
nameServerRecord.SetLabel("", domain) nameServerRecord.SetLabel("", domain)
// make sure the value for this NS record is suffixed with a dot at the end // make sure the value for this NS record is suffixed with a dot at the end
_ = nameServerRecord.PopulateFromString("NS", strings.TrimSuffix(nameServer.Name, ".") + ".", domain) _ = nameServerRecord.PopulateFromString("NS", strings.TrimSuffix(nameServer.Name, ".")+".", domain)
existingRecords = append(existingRecords, nameServerRecord) existingRecords = append(existingRecords, nameServerRecord)
} }

View File

@ -39,10 +39,9 @@ type MainAddressRecord struct {
} }
type Zone struct { type Zone struct {
Origin string `json:"origin"` Origin string `json:"origin"`
Soa * bind.SoaDefaults `json:"soa,omitempty"` Soa *bind.SoaDefaults `json:"soa,omitempty"`
// List of name servers // List of name servers
NameServers []*models.Nameserver `json:"nameServers,omitempty"` NameServers []*models.Nameserver `json:"nameServers,omitempty"`

View File

@ -19,10 +19,10 @@ import (
var docNotes = providers.DocumentationNotes{ var docNotes = providers.DocumentationNotes{
providers.CanGetZones: providers.Can(), providers.CanGetZones: providers.Can(),
providers.CanUseAlias: providers.Can(), providers.CanUseAlias: providers.Can(),
providers.CanAutoDNSSEC: providers.Can(), providers.CanAutoDNSSEC: providers.Can(),
providers.CanUseCAA: providers.Can(), providers.CanUseCAA: providers.Can(),
providers.CanUseDS: providers.Can(), providers.CanUseDS: providers.Can(),
providers.CanUseDSForChildren: providers.Can(), providers.CanUseDSForChildren: providers.Can(),
providers.CanUseNAPTR: providers.Can(), providers.CanUseNAPTR: providers.Can(),
providers.CanUsePTR: providers.Can(), providers.CanUsePTR: providers.Can(),
providers.DocCreateDomains: providers.Can(), providers.DocCreateDomains: providers.Can(),
@ -113,7 +113,7 @@ func (n *nsone) GetZoneDNSSEC(domain string) (bool, error) {
} }
// getDomainCorrectionsDNSSEC creates DNSSEC zone corrections based on current state and preference // getDomainCorrectionsDNSSEC creates DNSSEC zone corrections based on current state and preference
func (n *nsone) getDomainCorrectionsDNSSEC(domain, toggleDNSSEC string) (*models.Correction) { func (n *nsone) getDomainCorrectionsDNSSEC(domain, toggleDNSSEC string) *models.Correction {
// get dnssec status from NS1 for domain // get dnssec status from NS1 for domain
// if errors are returned, we bail out without any DNSSEC corrections // if errors are returned, we bail out without any DNSSEC corrections
@ -164,7 +164,7 @@ func (n *nsone) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correct
corrections := []*models.Correction{} corrections := []*models.Correction{}
if dnssecCorrections := n.getDomainCorrectionsDNSSEC(domain, dc.AutoDNSSEC); dnssecCorrections != nil { if dnssecCorrections := n.getDomainCorrectionsDNSSEC(domain, dc.AutoDNSSEC); dnssecCorrections != nil {
corrections = append(corrections, dnssecCorrections) corrections = append(corrections, dnssecCorrections)
} }