blob: fc81bf50f8aff4d4fbf7152317ffcad13ee744c1 [file] [log] [blame]
Serge Bazanski4b1e37c2021-09-28 12:49:15 +02001package fietsje
Serge Bazanskif369cfa2020-05-22 18:36:42 +02002
Serge Bazanski4b1e37c2021-09-28 12:49:15 +02003// deps_monogon.go contains the main entrypoint for Monogon-specific
4// dependencies to be handled by fietsje, and calls out to all other functions
5// in deps_*.go.
Serge Bazanskif369cfa2020-05-22 18:36:42 +02006
7import (
8 "bytes"
Serge Bazanski4b1e37c2021-09-28 12:49:15 +02009 "fmt"
Serge Bazanskif369cfa2020-05-22 18:36:42 +020010 "io/ioutil"
Serge Bazanskif369cfa2020-05-22 18:36:42 +020011)
12
Serge Bazanski4b1e37c2021-09-28 12:49:15 +020013// Monogon runs fietsje for all Monogon transitive dependencies.
14func Monogon(shelfPath, repositoriesBzlPath string) error {
Serge Bazanski116c4a62021-09-24 14:22:27 +020015 shelf, err := shelfLoad(shelfPath)
Serge Bazanskif369cfa2020-05-22 18:36:42 +020016 if err != nil {
Serge Bazanski4b1e37c2021-09-28 12:49:15 +020017 return fmt.Errorf("could not load shelf: %w", err)
Serge Bazanskif369cfa2020-05-22 18:36:42 +020018 }
19
20 p := &planner{
21 available: make(map[string]*dependency),
22 enabled: make(map[string]bool),
23 seen: make(map[string]string),
24
25 shelf: shelf,
26 }
27
Serge Bazanski216fe7b2021-05-21 18:36:16 +020028 // Currently can't bump past v1.30.0, as that removes the old balancer.Picker API
29 // that go-etcd depends upon. See https://github.com/etcd-io/etcd/pull/12398 .
Serge Bazanskif369cfa2020-05-22 18:36:42 +020030 p.collect(
Serge Bazanskif12bedf2021-01-15 16:58:50 +010031 "google.golang.org/grpc", "v1.29.1",
Serge Bazanskif369cfa2020-05-22 18:36:42 +020032 ).use(
Serge Bazanskif369cfa2020-05-22 18:36:42 +020033 "golang.org/x/text",
34 )
35
36 depsKubernetes(p)
37 depsContainerd(p)
38 depsGVisor(p)
Serge Bazanskif369cfa2020-05-22 18:36:42 +020039
40 // our own deps, common
41 p.collectOverride("go.uber.org/zap", "v1.15.0")
42 p.collectOverride("golang.org/x/mod", "v0.3.0")
Lorenz Brun6adf8842021-10-05 13:39:11 +020043 p.collectOverride("github.com/spf13/viper", "v1.9.0").use(
44 "gopkg.in/ini.v1",
45 "github.com/subosito/gotenv",
46 )
47 p.collectOverride("github.com/spf13/cobra", "v1.2.1")
Serge Bazanskif369cfa2020-05-22 18:36:42 +020048 p.collect("github.com/cenkalti/backoff/v4", "v4.0.2")
49
50 p.collect("github.com/google/go-tpm", "ae6dd98980d4")
51 p.collect("github.com/google/go-tpm-tools", "f8c04ff88181")
Lorenz Bruna50e8452020-09-09 17:09:27 +020052 p.collect("github.com/google/certificate-transparency-go", "v1.1.0")
Lorenz Brun56a7ae62020-10-29 11:03:30 +010053 p.collect("github.com/insomniacslk/dhcp", "67c425063dcad32c5d14ce9a520c8865240dc945").use(
54 "github.com/mdlayher/ethernet",
Serge Bazanskif369cfa2020-05-22 18:36:42 +020055 "github.com/mdlayher/raw",
Lorenz Brun56a7ae62020-10-29 11:03:30 +010056 "github.com/u-root/u-root",
Serge Bazanskif369cfa2020-05-22 18:36:42 +020057 )
58 p.collect("github.com/rekby/gpt", "a930afbc6edcc89c83d39b79e52025698156178d")
59 p.collect("github.com/yalue/native_endian", "51013b03be4fd97b0aabf29a6923e60359294186")
60
Lorenz Brunb60d9cb2021-02-18 17:34:00 +010061 // Used by //build/bazel_cc_fix, override to make sure we use the latest version
62 p.collectOverride("github.com/mattn/go-shellwords", "v1.0.11")
63
Serge Bazanskid9ed6562021-01-07 16:06:44 +010064 // Used by //metropolis/build/mkimage
Serge Bazanskif369cfa2020-05-22 18:36:42 +020065 p.collect("github.com/diskfs/go-diskfs", "v1.0.0").use(
66 "gopkg.in/djherbis/times.v1",
67 )
Lorenz Brun878f5f92020-05-12 16:15:39 +020068
Serge Bazanskid9ed6562021-01-07 16:06:44 +010069 // Used by //metropolis/build/genosrelease
70 p.collect("github.com/joho/godotenv", "v1.3.0")
71
Serge Bazanskif369cfa2020-05-22 18:36:42 +020072 // used by //build/bindata
73 p.collect("github.com/kevinburke/go-bindata", "v3.16.0")
74
Leopold Schabel3058b7a2020-06-03 17:51:07 +020075 // for interactive debugging during development (//:dlv alias)
76 depsDelve(p)
77
Serge Bazanskid9ed6562021-01-07 16:06:44 +010078 // Used by //metropolis/test/nanoswitch
Lorenz Brun52f7f292020-06-24 16:42:02 +020079 p.collect("github.com/google/nftables", "7127d9d22474b437f0e8136ddb21855df29790bf").use(
80 "github.com/koneu/natend",
Lorenz Brunf042e6f2020-06-24 16:46:09 +020081 )
82
Serge Bazanskid9ed6562021-01-07 16:06:44 +010083 // Used by //metropolis/node/core/network/dhcp4c
84 p.collect("github.com/google/gopacket", "v1.1.17")
85
Lorenz Brunf042e6f2020-06-24 16:46:09 +020086 // used by //core//kubernetes/clusternet
87 p.collect("golang.zx2c4.com/wireguard/wgctrl", "ec7f26be9d9e47a32a2789f8c346031978485cbf").use(
Lorenz Brun52f7f292020-06-24 16:42:02 +020088 "github.com/mdlayher/netlink",
Lorenz Brunf042e6f2020-06-24 16:46:09 +020089 "github.com/mdlayher/genetlink",
Lorenz Brun52f7f292020-06-24 16:42:02 +020090 )
91
Lorenz Brunb682ba52020-07-08 14:51:36 +020092 p.collect(
93 "github.com/sbezverk/nfproxy", "7fac5f39824e7f34228b08ba8b7640770ca6a9f4",
94 patches("nfproxy.patch"),
95 ).use(
96 "github.com/sbezverk/nftableslib",
97 )
98
Lorenz Brunb29e0b02020-07-28 17:26:12 +020099 p.collect("github.com/coredns/coredns", "v1.7.0",
100 prePatches("coredns-remove-unused-plugins.patch"),
101 ).use(
102 "github.com/caddyserver/caddy",
103 "github.com/dnstap/golang-dnstap",
104 "github.com/farsightsec/golang-framestream",
Lorenz Brunb29e0b02020-07-28 17:26:12 +0200105 "github.com/flynn/go-shlex",
Serge Bazanskid9ed6562021-01-07 16:06:44 +0100106 "github.com/grpc-ecosystem/grpc-opentracing",
107 "github.com/infobloxopen/go-trees",
108 "github.com/miekg/dns",
109 "github.com/opentracing/opentracing-go",
Lorenz Brunb29e0b02020-07-28 17:26:12 +0200110 )
111
Leopold Schabel26d41992020-12-15 19:27:58 +0100112 // goimports
113 p.collectOverride("golang.org/x/tools", "v0.0.0-20201215171152-6307297f4651")
114
Serge Bazanski6ebdc412021-05-21 16:25:55 +0200115 // commentwrap is used as a nogo analyzer to stick to a maximum line
116 // length for comments.
117 // We have to patch both it and its only direct dependency to add generated
118 // go_tool_library targets. This is needed as Gazelle doesn't generate them,
119 // because they're a temporary solution to a problem that shouldn't exist soon:
120 // https://github.com/bazelbuild/rules_go/issues/2374
121 p.collect("github.com/corverroos/commentwrap", "2926638be44ce0c6c0ee2471e9b5ad9473c984cd",
122 patches("commentwrap-tool-library.patch"),
123 ).with(patches("reflow-tool-library.patch")).use(
124 "github.com/muesli/reflow",
125 )
126
Serge Bazanski216fe7b2021-05-21 18:36:16 +0200127 // First generate the repositories starlark rule into memory. This is because
128 // rendering will lock all unlocked dependencies, which might take a while. If a
129 // use were to interrupt it now, they would end up with an incomplete
Serge Bazanskif369cfa2020-05-22 18:36:42 +0200130 // repositories.bzl and would have to restore from git.
131 buf := bytes.NewBuffer(nil)
132 err = p.render(buf)
133 if err != nil {
Serge Bazanski4b1e37c2021-09-28 12:49:15 +0200134 return fmt.Errorf("could not render deps: %w", err)
Serge Bazanskif369cfa2020-05-22 18:36:42 +0200135 }
136
Serge Bazanski116c4a62021-09-24 14:22:27 +0200137 err = ioutil.WriteFile(repositoriesBzlPath, buf.Bytes(), 0666)
Serge Bazanskif369cfa2020-05-22 18:36:42 +0200138 if err != nil {
Serge Bazanski4b1e37c2021-09-28 12:49:15 +0200139 return fmt.Errorf("could not write deps: %w", err)
Serge Bazanskif369cfa2020-05-22 18:36:42 +0200140 }
Serge Bazanski4b1e37c2021-09-28 12:49:15 +0200141 return nil
Serge Bazanskif369cfa2020-05-22 18:36:42 +0200142}