From 7113939121787a124ede4b8e69daeebcb25b7654 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Fri, 11 Mar 2022 10:51:55 +0100 Subject: [PATCH] style: golangci lint --- .drone.yml | 6 ++++-- main.go | 1 - pkg/config/config.go | 1 - pkg/daemon/daemon.go | 13 +++---------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5253785..7866f51 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,8 +16,10 @@ steps: cpu: 50 memory: 50M -- name: golang-ci lint - image: docker.io/golangci/golangci-lint:1.44.2-alpine +- name: golangci lint + commands: + - golangci-lint run + image: docker.io/golangci/golangci-lint:v1.44.2-alpine resources: limits: cpu: 100 diff --git a/main.go b/main.go index 8e20c7f..922f110 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,6 @@ var ( ) func main() { - switch os.Getenv("DYNDNS_CLIENT_LOGGER_LEVEL") { case "DEBUG", "debug": log.SetLevel(log.DebugLevel) diff --git a/pkg/config/config.go b/pkg/config/config.go index 1a6187a..ba4953b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -37,7 +37,6 @@ func GetDefaultConfiguration() (*types.Config, error) { // Read config from a file func Read(cnfFile string) (*types.Config, error) { - // Load burned in configuration if config not available if _, err := os.Stat(cnfFile); os.IsNotExist(err) { if err := os.MkdirAll(filepath.Dir(cnfFile), 0755); err != nil { diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 78b718e..52122e6 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -48,7 +48,7 @@ func Start(cnf *types.Config) { for { interfaces, err := netlink.LinkList() if err != nil { - log.Fatal("%v", err.Error()) + log.Fatalf("%v", err.Error()) } select { @@ -99,7 +99,7 @@ func Start(cnf *types.Config) { interfaceLogger.Error(err.Error()) } } else { - err = removeIPRecords(daemonCtx, interfaceLogger, updaters, cnf.Zones, recordType, update.LinkAddress.IP) + err = removeIPRecords(daemonCtx, interfaceLogger, updaters, cnf.Zones, recordType) if err != nil { interfaceLogger.Error(err.Error()) } @@ -146,7 +146,6 @@ func searchInterfaceByIndex(index int, interfaces []netlink.Link) (netlink.Link, } func addIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string]updater.Updater, zones map[string]*types.Zone, recordType string, ip net.IP) error { - var ( errorChannel = make(chan error, len(zones)) wg = new(sync.WaitGroup) @@ -166,7 +165,6 @@ func addIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string] wg.Add(1) go func(ctx context.Context, zoneName string, hostname string, recordType string, ip net.IP, wg *sync.WaitGroup) { - zoneLogger := logEntry.WithFields(log.Fields{ "zone": zoneName, "hostname": hostname, @@ -186,7 +184,6 @@ func addIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string] } zoneLogger.Info("dns-record successfully updated") - }(ctx, zoneName, hostname, recordType, ip, wg) } @@ -203,7 +200,6 @@ func addIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string] } func pruneRecords(ctx context.Context, updaters map[string]updater.Updater, zones map[string]*types.Zone) error { - var ( errorChannel = make(chan error, len(zones)) wg = new(sync.WaitGroup) @@ -250,8 +246,7 @@ func pruneRecords(ctx context.Context, updaters map[string]updater.Updater, zone return nil } -func removeIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string]updater.Updater, zones map[string]*types.Zone, recordType string, ip net.IP) error { - +func removeIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string]updater.Updater, zones map[string]*types.Zone, recordType string) error { var ( errorChannel = make(chan error, len(zones)) wg = new(sync.WaitGroup) @@ -290,7 +285,6 @@ func removeIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[stri } zoneLogger.Info("dns-record successfully removed") - }(ctx, zoneName, hostname, recordType, wg) } @@ -309,7 +303,6 @@ func removeIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[stri // verifyHostname returns a boolean if the hostname id valid. The hostname does // not contains any dot or local, localhost, localdomain. func verifyHostname(hostname string) bool { - if !validHostname.MatchString(hostname) { return false }