mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
kubernetes: Add useragent (#6484)
In kubernetes' audit logs you'll see: "userAgent":"coredns/v0.0.0 (linux/amd64) kubernetes/$Format" This change adds a userAgent to the requests made by CoreDNS against the kubernetes API: "userAgent":"CoreDNS/v1.11.1 git_commit:ae2bbc29be1aaae0b3ded5d188968a6c97bb3144 (linux/amd64/go1.22)" Signed-off-by: Manuel Rüger <manuel@rueg.eu>
This commit is contained in:
@@ -31,7 +31,7 @@ func init() {
|
||||
flag.StringVar(&dnsserver.Port, serverType+".port", dnsserver.DefaultPort, "Default port")
|
||||
flag.StringVar(&dnsserver.Port, "p", dnsserver.DefaultPort, "Default port")
|
||||
|
||||
caddy.AppName = coreName
|
||||
caddy.AppName = CoreName
|
||||
caddy.AppVersion = CoreVersion
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@ package coremain
|
||||
// Various CoreDNS constants.
|
||||
const (
|
||||
CoreVersion = "1.11.3"
|
||||
coreName = "CoreDNS"
|
||||
CoreName = "CoreDNS"
|
||||
serverType = "dns"
|
||||
)
|
||||
|
||||
@@ -6,9 +6,11 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/coredns/coredns/coremain"
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/plugin/etcd/msg"
|
||||
"github.com/coredns/coredns/plugin/kubernetes/object"
|
||||
@@ -192,6 +194,7 @@ func (k *Kubernetes) getClientConfig() (*rest.Config, error) {
|
||||
return nil, err
|
||||
}
|
||||
cc.ContentType = "application/vnd.kubernetes.protobuf"
|
||||
cc.UserAgent = fmt.Sprintf("%s/%s git_commit:%s (%s/%s/%s)", coremain.CoreName, coremain.CoreVersion, coremain.GitCommit, runtime.GOOS, runtime.GOARCH, runtime.Version())
|
||||
return cc, err
|
||||
}
|
||||
|
||||
@@ -218,6 +221,7 @@ func (k *Kubernetes) getClientConfig() (*rest.Config, error) {
|
||||
return nil, err
|
||||
}
|
||||
cc.ContentType = "application/vnd.kubernetes.protobuf"
|
||||
cc.UserAgent = fmt.Sprintf("%s/%s git_commit:%s (%s/%s/%s)", coremain.CoreName, coremain.CoreVersion, coremain.GitCommit, runtime.GOOS, runtime.GOARCH, runtime.Version())
|
||||
return cc, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user