Skip to content

Commit

Permalink
Merge pull request #5 from GDATASoftwareAG/refactor-errors
Browse files Browse the repository at this point in the history
refactor: use always fmt.Errorf("...: %w", err), instead of %s or %v
  • Loading branch information
farodin91 authored Sep 26, 2023
2 parents 06ca27a + dd3e733 commit 5822949
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# ExternalDNS Plugin CoreDNS Webhook

## Commandline
```
usage: external-dns-coredns-webhook [<flags>]
ExternalDNS CoreDNS webhook
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--version Show application version.
--dry-run When enabled, prints DNS record changes rather than actually performing them (default: disabled)
--log-format=text The format in which log messages are printed (default: text, options: text, json)
--log-level=info Set the level of logging. (default: info, options: panic, debug, info, warning, error, fatal
--webhook-provider-read-timeout=5s
The read timeout for the webhook provider in duration format (default: 5s)
--webhook-provider-write-timeout=5s
The write timeout for the webhook provider in duration format (default: 5s)
--webhook-provider-port="0.0.0.0:8888"
Webhook provider port (default: 0.0.0.0:8888)
--prefix="/skydns/" Specify the prefix name
--txt-owner-id="default" When using the TXT registry, a name that identifies this instance of ExternalDNS (default: default)
--pre-filter-external-owned-records
Services are pre filter based on the txt-owner-id (default: false)
```

## Pre-filtering CoreDNS services based on ownerIDs

Expand Down
8 changes: 4 additions & 4 deletions coredns.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (c etcdClient) GetServices(prefix string) ([]*Service, error) {
for _, n := range r.Kvs {
svc := new(Service)
if err := json.Unmarshal(n.Value, svc); err != nil {
return nil, fmt.Errorf("%s: %s", n.Key, err.Error())
return nil, fmt.Errorf("%s: %w", n.Key, err)
}
b := Service{Host: svc.Host, Port: svc.Port, Priority: svc.Priority, Weight: svc.Weight, Text: svc.Text, Key: string(n.Key)}
if _, ok := bx[b]; ok {
Expand Down Expand Up @@ -173,7 +173,7 @@ func newTLSConfig(certPath, keyPath, caPath, serverName string, insecure bool) (
if certPath != "" {
cert, err := tls.LoadX509KeyPair(certPath, keyPath)
if err != nil {
return nil, fmt.Errorf("could not load TLS cert: %s", err)
return nil, fmt.Errorf("could not load TLS cert: %w", err)
}
certificates = append(certificates, cert)
}
Expand All @@ -199,11 +199,11 @@ func loadRoots(caPath string) (*x509.CertPool, error) {
roots := x509.NewCertPool()
pem, err := os.ReadFile(caPath)
if err != nil {
return nil, fmt.Errorf("error reading %s: %s", caPath, err)
return nil, fmt.Errorf("error reading %s: %w", caPath, err)
}
ok := roots.AppendCertsFromPEM(pem)
if !ok {
return nil, fmt.Errorf("could not read root certs: %s", err)
return nil, fmt.Errorf("could not read root certs: %w", err)
}
return roots, nil
}
Expand Down

0 comments on commit 5822949

Please sign in to comment.