Add CoreDNS build
This adds CoreDNS and all relevant dependencies. Unused plugins are patched out
to prevent excessive dependencies and binary size.
Test Plan: `bazel build @com_github_coredns_coredns//:coredns`
X-Origin-Diff: phab/D614
GitOrigin-RevId: a897bc0e9f908218fd2f414d7e3b902c14e0a374
diff --git a/build/fietsje/main.go b/build/fietsje/main.go
index c62d6c7..acc5548 100644
--- a/build/fietsje/main.go
+++ b/build/fietsje/main.go
@@ -117,6 +117,18 @@
"github.com/sbezverk/nftableslib",
)
+ p.collect("github.com/coredns/coredns", "v1.7.0",
+ prePatches("coredns-remove-unused-plugins.patch"),
+ ).use(
+ "github.com/caddyserver/caddy",
+ "github.com/dnstap/golang-dnstap",
+ "github.com/farsightsec/golang-framestream",
+ "github.com/infobloxopen/go-trees",
+ "github.com/opentracing/opentracing-go",
+ "github.com/grpc-ecosystem/grpc-opentracing",
+ "github.com/flynn/go-shlex",
+ )
+
// First generate the repositories starlark rule into memory. This is because rendering will lock all unlocked
// dependencies, which might take a while. If a use were to interrupt it now, they would end up with an incomplete
// repositories.bzl and would have to restore from git.
diff --git a/nogo_config.json b/nogo_config.json
index 338c380..254872f 100644
--- a/nogo_config.json
+++ b/nogo_config.json
@@ -13,7 +13,8 @@
"external/org_golang_x_tools/": "third_party",
"external/io_k8s_apiextensions_apiserver/": "third_party",
"external/org_golang_x_text/": "third_party",
- "external/io_bazel_rules_docker/": "third_party"
+ "external/io_bazel_rules_docker/": "third_party",
+ "external/com_github_grpc_ecosystem_grpc_opentracing": "third_party"
}
},
"copylocks": {
@@ -44,7 +45,9 @@
"external/io_k8s_kubectl": "third_party",
"external/org_golang_google_protobuf/": "third_party",
"external/com_github_shirou_gopsutil/": "unreachable",
- "external/io_k8s_apimachinery/": "third_party"
+ "external/io_k8s_apimachinery/": "third_party",
+ "external/com_github_hpcloud_tail": "third_party",
+ "external/com_github_flynn_go_shlex": "third_party"
}
},
"assign": {
diff --git a/third_party/go/patches/coredns-remove-unused-plugins.patch b/third_party/go/patches/coredns-remove-unused-plugins.patch
new file mode 100644
index 0000000..ae43bad
--- /dev/null
+++ b/third_party/go/patches/coredns-remove-unused-plugins.patch
@@ -0,0 +1,203 @@
+Copyright 2020 The Monogon Project Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+From b8a216a10775163dac6267127c35c9230ccbc5f7 Mon Sep 17 00:00:00 2001
+From: Lorenz Brun <lorenz@nexantic.com>
+Date: Mon, 27 Jul 2020 14:25:03 +0200
+Subject: [PATCH] Removed unused plugins
+
+---
+ core/dnsserver/zdirectives.go | 27 ---------------------------
+ core/plugin/zplugin.go | 27 ---------------------------
+ plugin.cfg | 27 ---------------------------
+ plugin/kubernetes/setup.go | 3 ---
+ 4 files changed, 84 deletions(-)
+
+diff --git a/core/dnsserver/zdirectives.go b/core/dnsserver/zdirectives.go
+index 1bf449cb..96306085 100644
+--- a/core/dnsserver/zdirectives.go
++++ b/core/dnsserver/zdirectives.go
+@@ -11,48 +11,21 @@ package dnsserver
+ // care what plugin above them are doing.
+ var Directives = []string{
+ "metadata",
+- "cancel",
+- "tls",
+ "reload",
+ "nsid",
+ "bufsize",
+- "root",
+ "bind",
+ "debug",
+- "trace",
+- "ready",
+ "health",
+- "pprof",
+- "prometheus",
+ "errors",
+ "log",
+- "dnstap",
+ "dns64",
+ "acl",
+ "any",
+- "chaos",
+ "loadbalance",
+ "cache",
+- "rewrite",
+- "dnssec",
+- "autopath",
+ "template",
+- "transfer",
+- "hosts",
+- "route53",
+- "azure",
+- "clouddns",
+- "k8s_external",
+ "kubernetes",
+- "file",
+- "auto",
+- "secondary",
+- "etcd",
+- "loop",
+ "forward",
+- "grpc",
+- "erratic",
+ "whoami",
+- "on",
+- "sign",
+ }
+diff --git a/core/plugin/zplugin.go b/core/plugin/zplugin.go
+index cf83be70..2cbb0672 100644
+--- a/core/plugin/zplugin.go
++++ b/core/plugin/zplugin.go
+@@ -4,49 +4,22 @@ package plugin
+
+ import (
+ // Include all plugins.
+- _ "github.com/caddyserver/caddy/onevent"
+ _ "github.com/coredns/coredns/plugin/acl"
+ _ "github.com/coredns/coredns/plugin/any"
+- _ "github.com/coredns/coredns/plugin/auto"
+- _ "github.com/coredns/coredns/plugin/autopath"
+- _ "github.com/coredns/coredns/plugin/azure"
+ _ "github.com/coredns/coredns/plugin/bind"
+ _ "github.com/coredns/coredns/plugin/bufsize"
+ _ "github.com/coredns/coredns/plugin/cache"
+- _ "github.com/coredns/coredns/plugin/cancel"
+- _ "github.com/coredns/coredns/plugin/chaos"
+- _ "github.com/coredns/coredns/plugin/clouddns"
+ _ "github.com/coredns/coredns/plugin/debug"
+ _ "github.com/coredns/coredns/plugin/dns64"
+- _ "github.com/coredns/coredns/plugin/dnssec"
+- _ "github.com/coredns/coredns/plugin/dnstap"
+- _ "github.com/coredns/coredns/plugin/erratic"
+ _ "github.com/coredns/coredns/plugin/errors"
+- _ "github.com/coredns/coredns/plugin/etcd"
+- _ "github.com/coredns/coredns/plugin/file"
+ _ "github.com/coredns/coredns/plugin/forward"
+- _ "github.com/coredns/coredns/plugin/grpc"
+ _ "github.com/coredns/coredns/plugin/health"
+- _ "github.com/coredns/coredns/plugin/hosts"
+- _ "github.com/coredns/coredns/plugin/k8s_external"
+ _ "github.com/coredns/coredns/plugin/kubernetes"
+ _ "github.com/coredns/coredns/plugin/loadbalance"
+ _ "github.com/coredns/coredns/plugin/log"
+- _ "github.com/coredns/coredns/plugin/loop"
+ _ "github.com/coredns/coredns/plugin/metadata"
+- _ "github.com/coredns/coredns/plugin/metrics"
+ _ "github.com/coredns/coredns/plugin/nsid"
+- _ "github.com/coredns/coredns/plugin/pprof"
+- _ "github.com/coredns/coredns/plugin/ready"
+ _ "github.com/coredns/coredns/plugin/reload"
+- _ "github.com/coredns/coredns/plugin/rewrite"
+- _ "github.com/coredns/coredns/plugin/root"
+- _ "github.com/coredns/coredns/plugin/route53"
+- _ "github.com/coredns/coredns/plugin/secondary"
+- _ "github.com/coredns/coredns/plugin/sign"
+ _ "github.com/coredns/coredns/plugin/template"
+- _ "github.com/coredns/coredns/plugin/tls"
+- _ "github.com/coredns/coredns/plugin/trace"
+- _ "github.com/coredns/coredns/plugin/transfer"
+ _ "github.com/coredns/coredns/plugin/whoami"
+ )
+diff --git a/plugin.cfg b/plugin.cfg
+index c389d74e..f6182c2a 100644
+--- a/plugin.cfg
++++ b/plugin.cfg
+@@ -20,47 +20,20 @@
+ # log:log
+
+ metadata:metadata
+-cancel:cancel
+-tls:tls
+ reload:reload
+ nsid:nsid
+ bufsize:bufsize
+-root:root
+ bind:bind
+ debug:debug
+-trace:trace
+-ready:ready
+ health:health
+-pprof:pprof
+-prometheus:metrics
+ errors:errors
+ log:log
+-dnstap:dnstap
+ dns64:dns64
+ acl:acl
+ any:any
+-chaos:chaos
+ loadbalance:loadbalance
+ cache:cache
+-rewrite:rewrite
+-dnssec:dnssec
+-autopath:autopath
+ template:template
+-transfer:transfer
+-hosts:hosts
+-route53:route53
+-azure:azure
+-clouddns:clouddns
+-k8s_external:k8s_external
+ kubernetes:kubernetes
+-file:file
+-auto:auto
+-secondary:secondary
+-etcd:etcd
+-loop:loop
+ forward:forward
+-grpc:grpc
+-erratic:erratic
+ whoami:whoami
+-on:github.com/caddyserver/caddy/onevent
+-sign:sign
+diff --git a/plugin/kubernetes/setup.go b/plugin/kubernetes/setup.go
+index 0c46a3ab..827fc141 100644
+--- a/plugin/kubernetes/setup.go
++++ b/plugin/kubernetes/setup.go
+@@ -20,9 +20,6 @@ import (
+ "github.com/caddyserver/caddy"
+ "github.com/miekg/dns"
+ meta "k8s.io/apimachinery/pkg/apis/meta/v1"
+- _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // pull this in here, because we want it excluded if plugin.cfg doesn't have k8s
+- _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" // pull this in here, because we want it excluded if plugin.cfg doesn't have k8s
+- _ "k8s.io/client-go/plugin/pkg/client/auth/openstack" // pull this in here, because we want it excluded if plugin.cfg doesn't have k8s
+ "k8s.io/client-go/tools/clientcmd"
+ "k8s.io/klog"
+ )
+--
+2.25.1
+
diff --git a/third_party/go/repositories.bzl b/third_party/go/repositories.bzl
index 042aadb..a65eb2c 100644
--- a/third_party/go/repositories.bzl
+++ b/third_party/go/repositories.bzl
@@ -127,6 +127,12 @@
sum = "h1:4yfM1Zm+7U+m0inJ0g6JvdqGePXD8eG4nXUTbcLT6gk=",
)
go_repository(
+ name = "com_github_caddyserver_caddy",
+ importpath = "github.com/caddyserver/caddy",
+ version = "v1.0.5",
+ sum = "h1:5B1Hs0UF2x2tggr2X9jL2qOZtDXbIWQb9YLbmlxHSuM=",
+ )
+ go_repository(
name = "com_github_cenkalti_backoff",
importpath = "github.com/cenkalti/backoff",
version = "v0.0.0-20190506075156-2146c9339422",
@@ -311,6 +317,16 @@
sum = "h1:EToign46OSLTFWnb2oNj9RG3XDnkOX8r28ZIXUuk5Pc=",
)
go_repository(
+ name = "com_github_coredns_coredns",
+ importpath = "github.com/coredns/coredns",
+ version = "v1.7.0",
+ sum = "h1:Tm2ZSdhTk+4okgjUp4K6KYzvBI2u34cdD4fKQRC4Eeo=",
+ pre_patches = [
+ "//third_party/go/patches:coredns-remove-unused-plugins.patch",
+ ],
+ patch_args = ["-p1"],
+ )
+ go_repository(
name = "com_github_coreos_go_iptables",
importpath = "github.com/coreos/go-iptables",
version = "v0.4.2",
@@ -395,6 +411,12 @@
sum = "h1:sLQnXItICiYgiHcYNNujKT9kOKnk7diOvZGEKvxrwpc=",
)
go_repository(
+ name = "com_github_dnstap_golang_dnstap",
+ importpath = "github.com/dnstap/golang-dnstap",
+ version = "v0.2.0",
+ sum = "h1:+NrmP4mkaTeKYV7xJ5FXpUxRn0RpcgoQcsOCTS8WQPk=",
+ )
+ go_repository(
name = "com_github_docker_distribution",
importpath = "github.com/docker/distribution",
version = "v2.7.1+incompatible",
@@ -479,6 +501,12 @@
sum = "h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM=",
)
go_repository(
+ name = "com_github_farsightsec_golang_framestream",
+ importpath = "github.com/farsightsec/golang-framestream",
+ version = "v0.0.0-20190425193708-fa4b164d59b8",
+ sum = "h1:/iPdQppoAsTfML+yqFSq2EBChiEMnRkh5WvhFgtWwcU=",
+ )
+ go_repository(
name = "com_github_fatih_camelcase",
importpath = "github.com/fatih/camelcase",
version = "v1.0.0",
@@ -491,6 +519,12 @@
sum = "h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=",
)
go_repository(
+ name = "com_github_flynn_go_shlex",
+ importpath = "github.com/flynn/go-shlex",
+ version = "v0.0.0-20150515145356-3f9db97f8568",
+ sum = "h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=",
+ )
+ go_repository(
name = "com_github_friendsofgo_errors",
importpath = "github.com/friendsofgo/errors",
version = "v0.9.2",
@@ -779,6 +813,12 @@
sum = "h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI=",
)
go_repository(
+ name = "com_github_grpc_ecosystem_grpc_opentracing",
+ importpath = "github.com/grpc-ecosystem/grpc-opentracing",
+ version = "v0.0.0-20180507213350-8e809c8a8645",
+ sum = "h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU=",
+ )
+ go_repository(
name = "com_github_grpc_grpc",
importpath = "github.com/grpc/grpc",
version = "v1.26.0",
@@ -845,6 +885,12 @@
sum = "h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=",
)
go_repository(
+ name = "com_github_infobloxopen_go_trees",
+ importpath = "github.com/infobloxopen/go-trees",
+ version = "v0.0.0-20190313150506-2af4e13f9062",
+ sum = "h1:d3VSuNcgTCn21dNMm8g412Fck/XWFmMj4nJhhHT7ZZ0=",
+ )
+ go_repository(
name = "com_github_insomniacslk_dhcp",
importpath = "github.com/insomniacslk/dhcp",
version = "v0.0.0-20200402185128-5dd7202f1971",
@@ -1143,6 +1189,12 @@
],
)
go_repository(
+ name = "com_github_opentracing_opentracing_go",
+ importpath = "github.com/opentracing/opentracing-go",
+ version = "v1.1.0",
+ sum = "h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=",
+ )
+ go_repository(
name = "com_github_optiopay_kafka",
importpath = "github.com/optiopay/kafka",
version = "v0.0.0-20180809090225-01ce283b732b",
diff --git a/third_party/go/shelf.pb.text b/third_party/go/shelf.pb.text
index 9d77503..3e0eded 100644
--- a/third_party/go/shelf.pb.text
+++ b/third_party/go/shelf.pb.text
@@ -167,6 +167,13 @@
semver: "v0.0.0-20190309065803-0b2ad9ac246b"
>
entry: <
+ import_path: "github.com/caddyserver/caddy"
+ version: "v1.0.5"
+ bazel_name: "com_github_caddyserver_caddy"
+ sum: "h1:5B1Hs0UF2x2tggr2X9jL2qOZtDXbIWQb9YLbmlxHSuM="
+ semver: "v1.0.5"
+>
+entry: <
import_path: "github.com/cenkalti/backoff"
version: "v0.0.0-20190506075156-2146c9339422"
bazel_name: "com_github_cenkalti_backoff"
@@ -496,6 +503,13 @@
semver: "v1.0.1"
>
entry: <
+ import_path: "github.com/coredns/coredns"
+ version: "v1.7.0"
+ bazel_name: "com_github_coredns_coredns"
+ sum: "h1:Tm2ZSdhTk+4okgjUp4K6KYzvBI2u34cdD4fKQRC4Eeo="
+ semver: "v1.7.0"
+>
+entry: <
import_path: "github.com/coreos/go-iptables"
version: "v0.4.2"
bazel_name: "com_github_coreos_go_iptables"
@@ -622,6 +636,13 @@
semver: "v1.0.0"
>
entry: <
+ import_path: "github.com/dnstap/golang-dnstap"
+ version: "v0.2.0"
+ bazel_name: "com_github_dnstap_golang_dnstap"
+ sum: "h1:+NrmP4mkaTeKYV7xJ5FXpUxRn0RpcgoQcsOCTS8WQPk="
+ semver: "v0.2.0"
+>
+entry: <
import_path: "github.com/docker/distribution"
version: "0d3efadf0154c2b8a4e7b6621fff9809655cc580"
bazel_name: "com_github_docker_distribution"
@@ -783,6 +804,13 @@
semver: "v0.0.0-20151013193312-d6023ce2651d"
>
entry: <
+ import_path: "github.com/farsightsec/golang-framestream"
+ version: "v0.0.0-20190425193708-fa4b164d59b8"
+ bazel_name: "com_github_farsightsec_golang_framestream"
+ sum: "h1:/iPdQppoAsTfML+yqFSq2EBChiEMnRkh5WvhFgtWwcU="
+ semver: "v0.0.0-20190425193708-fa4b164d59b8"
+>
+entry: <
import_path: "github.com/fatih/camelcase"
version: "v1.0.0"
bazel_name: "com_github_fatih_camelcase"
@@ -797,6 +825,13 @@
semver: "v1.7.0"
>
entry: <
+ import_path: "github.com/flynn/go-shlex"
+ version: "v0.0.0-20150515145356-3f9db97f8568"
+ bazel_name: "com_github_flynn_go_shlex"
+ sum: "h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ="
+ semver: "v0.0.0-20150515145356-3f9db97f8568"
+>
+entry: <
import_path: "github.com/friendsofgo/errors"
version: "v0.9.2"
bazel_name: "com_github_friendsofgo_errors"
@@ -1182,6 +1217,13 @@
semver: "v1.9.5"
>
entry: <
+ import_path: "github.com/grpc-ecosystem/grpc-opentracing"
+ version: "v0.0.0-20180507213350-8e809c8a8645"
+ bazel_name: "com_github_grpc_ecosystem_grpc_opentracing"
+ sum: "h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU="
+ semver: "v0.0.0-20180507213350-8e809c8a8645"
+>
+entry: <
import_path: "github.com/grpc/grpc"
version: "v1.26.0"
bazel_name: "com_github_grpc_grpc"
@@ -1301,6 +1343,13 @@
semver: "v0.3.7"
>
entry: <
+ import_path: "github.com/infobloxopen/go-trees"
+ version: "v0.0.0-20190313150506-2af4e13f9062"
+ bazel_name: "com_github_infobloxopen_go_trees"
+ sum: "h1:d3VSuNcgTCn21dNMm8g412Fck/XWFmMj4nJhhHT7ZZ0="
+ semver: "v0.0.0-20190313150506-2af4e13f9062"
+>
+entry: <
import_path: "github.com/insomniacslk/dhcp"
version: "5dd7202f19711228cb4a51aa8b3415421c2edefe"
bazel_name: "com_github_insomniacslk_dhcp"
@@ -1763,6 +1812,13 @@
semver: "v1.5.1"
>
entry: <
+ import_path: "github.com/opentracing/opentracing-go"
+ version: "v1.1.0"
+ bazel_name: "com_github_opentracing_opentracing_go"
+ sum: "h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU="
+ semver: "v1.1.0"
+>
+entry: <
import_path: "github.com/optiopay/kafka"
version: "b5a758dbffc5786a8cac42703bd5d63f503bd008"
bazel_name: "com_github_optiopay_kafka"