From 9dd60220d8ab0173fa6e10250daf9cdb8219436e Mon Sep 17 00:00:00 2001 From: Chris Privitere <23177737+cprivitere@users.noreply.github.com> Date: Tue, 18 Apr 2023 12:59:44 -0500 Subject: [PATCH 1/4] Update deps Bump k8s deps to latest 0.26 Bump controller-runtime to latest Switch to sigs.k8s.io/yaml Move semver to indirect Signed-off-by: Chris Privitere <23177737+cprivitere@users.noreply.github.com> --- go.mod | 30 ++++++++--------- go.sum | 48 +++++++++++++-------------- metal/loadbalancers/metallb/config.go | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/go.mod b/go.mod index c9e0058c..73ef6f02 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/equinix/cloud-provider-equinix-metal go 1.19 require ( - github.com/blang/semver/v4 v4.0.0 github.com/google/uuid v1.3.0 github.com/hashicorp/go-retryablehttp v0.7.2 github.com/packethost/packet-api-server v0.0.0-20230223042617-bc7d1539adbb @@ -11,15 +10,15 @@ require ( github.com/pallinder/go-randomdata v1.2.0 github.com/spf13/pflag v1.0.5 go.universe.tf/metallb v0.13.7 - golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 - gopkg.in/yaml.v2 v2.4.0 - k8s.io/api v0.26.2 - k8s.io/apimachinery v0.26.2 - k8s.io/client-go v0.26.2 - k8s.io/cloud-provider v0.26.2 - k8s.io/component-base v0.26.2 + golang.org/x/exp v0.0.0-20230321023759-10a507213a29 + k8s.io/api v0.26.4 + k8s.io/apimachinery v0.26.4 + k8s.io/client-go v0.26.4 + k8s.io/cloud-provider v0.26.4 + k8s.io/component-base v0.26.4 k8s.io/klog/v2 v2.90.1 - sigs.k8s.io/controller-runtime v0.14.5 + sigs.k8s.io/controller-runtime v0.14.6 + sigs.k8s.io/yaml v1.3.0 ) require ( @@ -27,6 +26,7 @@ require ( github.com/NYTimes/gziphandler v1.1.1 // indirect github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/blang/semver/v4 v4.0.0 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/coreos/go-semver v0.3.0 // indirect @@ -103,16 +103,16 @@ require ( google.golang.org/protobuf v1.28.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.26.1 // indirect - k8s.io/apiserver v0.26.2 // indirect - k8s.io/component-helpers v0.26.2 // indirect - k8s.io/controller-manager v0.26.2 // indirect - k8s.io/kms v0.26.2 // indirect + k8s.io/apiserver v0.26.4 // indirect + k8s.io/component-helpers v0.26.4 // indirect + k8s.io/controller-manager v0.26.4 // indirect + k8s.io/kms v0.26.4 // indirect k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect - sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35 // indirect + sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.36 // indirect sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index fe35b438..b36e2e81 100644 --- a/go.sum +++ b/go.sum @@ -427,8 +427,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI= -golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -754,28 +754,28 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.2 h1:dM3cinp3PGB6asOySalOZxEG4CZ0IAdJsrYZXE/ovGQ= -k8s.io/api v0.26.2/go.mod h1:1kjMQsFE+QHPfskEcVNgL3+Hp88B80uj0QtSOlj8itU= +k8s.io/api v0.26.4 h1:qSG2PmtcD23BkYiWfoYAcak870eF/hE7NNYBYavTT94= +k8s.io/api v0.26.4/go.mod h1:WwKEXU3R1rgCZ77AYa7DFksd9/BAIKyOmRlbVxgvjCk= k8s.io/apiextensions-apiserver v0.26.1 h1:cB8h1SRk6e/+i3NOrQgSFij1B2S0Y0wDoNl66bn8RMI= k8s.io/apiextensions-apiserver v0.26.1/go.mod h1:AptjOSXDGuE0JICx/Em15PaoO7buLwTs0dGleIHixSM= -k8s.io/apimachinery v0.26.2 h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ= -k8s.io/apimachinery v0.26.2/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= -k8s.io/apiserver v0.26.2 h1:Pk8lmX4G14hYqJd1poHGC08G03nIHVqdJMR0SD3IH3o= -k8s.io/apiserver v0.26.2/go.mod h1:GHcozwXgXsPuOJ28EnQ/jXEM9QeG6HT22YxSNmpYNh8= -k8s.io/client-go v0.26.2 h1:s1WkVujHX3kTp4Zn4yGNFK+dlDXy1bAAkIl+cFAiuYI= -k8s.io/client-go v0.26.2/go.mod h1:u5EjOuSyBa09yqqyY7m3abZeovO/7D/WehVVlZ2qcqU= -k8s.io/cloud-provider v0.26.2 h1:VlLGDayUV5VBpvMSBFqmpz2HHTjBLUw02wuZzNeEsW0= -k8s.io/cloud-provider v0.26.2/go.mod h1:/Am9R0merLIZgVqPTE4Z1JkBcCrp2uXImHCxnvVARxc= -k8s.io/component-base v0.26.2 h1:IfWgCGUDzrD6wLLgXEstJKYZKAFS2kO+rBRi0p3LqcI= -k8s.io/component-base v0.26.2/go.mod h1:DxbuIe9M3IZPRxPIzhch2m1eT7uFrSBJUBuVCQEBivs= -k8s.io/component-helpers v0.26.2 h1:+JJ1gwyVsqSwZCJVLJotx/IPq2pMpo0kifeAzfo6i3U= -k8s.io/component-helpers v0.26.2/go.mod h1:PRvoduZ5/IeKGGbZRki3J2cTQVwZLD+EUxIEbvvX0W4= -k8s.io/controller-manager v0.26.2 h1:Y4g50VqaXkr02v5FNTWDQ47ZPFNM1ls00F0+FoKKaTM= -k8s.io/controller-manager v0.26.2/go.mod h1:h8yv0MO3jjo9px49uResC9laZekvOmQRmrRLwe9n6Zw= +k8s.io/apimachinery v0.26.4 h1:rZccKdBLg9vP6J09JD+z8Yr99Ce8gk3Lbi9TCx05Jzs= +k8s.io/apimachinery v0.26.4/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= +k8s.io/apiserver v0.26.4 h1:3Oq4mnJv0mzVX7BR/Nod+8KjlELf/3Ljvu9ZWDyLUoA= +k8s.io/apiserver v0.26.4/go.mod h1:yAY3O1vBM4/0OIGAGeWcdfzQvgdwJ188VirLcuSAVnw= +k8s.io/client-go v0.26.4 h1:/7P/IbGBuT73A+G97trf44NTPSNqvuBREpOfdLbHvD4= +k8s.io/client-go v0.26.4/go.mod h1:6qOItWm3EwxJdl/8p5t7FWtWUOwyMdA8N9ekbW4idpI= +k8s.io/cloud-provider v0.26.4 h1:mqN4vhC4mRoMi+ujI92ImkIOuYS7ZS55FvXB10d6Wp4= +k8s.io/cloud-provider v0.26.4/go.mod h1:F9xY0PvBuZDuGIHOM28dNiPLHxQnWfsiUuCSUikHevo= +k8s.io/component-base v0.26.4 h1:Bg2xzyXNKL3eAuiTEu3XE198d6z22ENgFgGQv2GGOUk= +k8s.io/component-base v0.26.4/go.mod h1:lTuWL1Xz/a4e80gmIC3YZG2JCO4xNwtKWHJWeJmsq20= +k8s.io/component-helpers v0.26.4 h1:qbZrh8QmfL+Yn7lWEI/BPrvITGgkBy33djP5Tzsu2hA= +k8s.io/component-helpers v0.26.4/go.mod h1:2Siz5eWmaKu0khASXMTCfJuASZAbCPX9mtjlCe5IWRs= +k8s.io/controller-manager v0.26.4 h1:SeOHV55WKqCa5HQfPHjMpfSPzJNblDvVDzfNgbQlSdQ= +k8s.io/controller-manager v0.26.4/go.mod h1:HJPU8OKTI8YhrtnvpuFdllK1QCQfibhJXDToDzCEsnQ= k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kms v0.26.2 h1:GM1gg3tFK3OUU/QQFi93yGjG3lJT8s8l3Wkn2+VxBLM= -k8s.io/kms v0.26.2/go.mod h1:69qGnf1NsFOQP07fBYqNLZklqEHSJF024JqYCaeVxHg= +k8s.io/kms v0.26.4 h1:mQ+DeOvgAHC6+heZcozPkEd3rWtP4DVVjo1hLSih9w4= +k8s.io/kms v0.26.4/go.mod h1:69qGnf1NsFOQP07fBYqNLZklqEHSJF024JqYCaeVxHg= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y= @@ -783,10 +783,10 @@ k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35 h1:+xBL5uTc+BkPBwmMi3vYfUJjq+N3K+H6PXeETwf5cPI= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35/go.mod h1:WxjusMwXlKzfAs4p9km6XJRndVt2FROgMVCE4cdohFo= -sigs.k8s.io/controller-runtime v0.14.5 h1:6xaWFqzT5KuAQ9ufgUaj1G/+C4Y1GRkhrxl+BJ9i+5s= -sigs.k8s.io/controller-runtime v0.14.5/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.36 h1:PUuX1qIFv309AT8hF/CdPKDmsG/hn/L8zRX7VvISM3A= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.36/go.mod h1:WxjusMwXlKzfAs4p9km6XJRndVt2FROgMVCE4cdohFo= +sigs.k8s.io/controller-runtime v0.14.6 h1:oxstGVvXGNnMvY7TAESYk+lzr6S3V5VFxQ6d92KcwQA= +sigs.k8s.io/controller-runtime v0.14.6/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= diff --git a/metal/loadbalancers/metallb/config.go b/metal/loadbalancers/metallb/config.go index 52bcc1a2..3a15522a 100644 --- a/metal/loadbalancers/metallb/config.go +++ b/metal/loadbalancers/metallb/config.go @@ -5,7 +5,7 @@ import ( "sort" "strings" - "gopkg.in/yaml.v2" + "sigs.k8s.io/yaml" ) // these are taken from https://github.com/metallb/metallb/blob/main/internal/config/config.go From 032af47957ca46c0d8681f759cb7884be1f84a9a Mon Sep 17 00:00:00 2001 From: Chris Privitere <23177737+cprivitere@users.noreply.github.com> Date: Tue, 18 Apr 2023 13:00:17 -0500 Subject: [PATCH 2/4] fix: Add omit empty to name Signed-off-by: Chris Privitere <23177737+cprivitere@users.noreply.github.com> --- metal/loadbalancers/metallb/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metal/loadbalancers/metallb/config.go b/metal/loadbalancers/metallb/config.go index 3a15522a..9c8ed9c2 100644 --- a/metal/loadbalancers/metallb/config.go +++ b/metal/loadbalancers/metallb/config.go @@ -43,7 +43,7 @@ type Peer struct { RouterID string `yaml:"router-id"` NodeSelectors []NodeSelector `yaml:"node-selectors"` Password string `yaml:"password"` - Name string `yaml:"name"` + Name string `yaml:"name,omitempty"` } type NodeSelector struct { From ed7b11a3f422991c7bb8f4bb74ff09acf8020b2b Mon Sep 17 00:00:00 2001 From: Chris Privitere <23177737+cprivitere@users.noreply.github.com> Date: Tue, 18 Apr 2023 14:09:58 -0500 Subject: [PATCH 3/4] fix: use json struct tags Signed-off-by: Chris Privitere <23177737+cprivitere@users.noreply.github.com> --- metal/loadbalancers/metallb/config.go | 42 +++++++++---------- metal/loadbalancers/metallb/configmap_test.go | 6 +-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/metal/loadbalancers/metallb/config.go b/metal/loadbalancers/metallb/config.go index 9c8ed9c2..0fe6eae1 100644 --- a/metal/loadbalancers/metallb/config.go +++ b/metal/loadbalancers/metallb/config.go @@ -29,45 +29,45 @@ import ( // without validation or useful high level types. type ConfigFile struct { Peers []Peer - BGPCommunities map[string]string `yaml:"bgp-communities"` - Pools []AddressPool `yaml:"address-pools"` + BGPCommunities map[string]string `json:"bgp-communities"` + Pools []AddressPool `json:"address-pools"` } type Peer struct { - MyASN uint32 `yaml:"my-asn"` - ASN uint32 `yaml:"peer-asn"` - Addr string `yaml:"peer-address"` - Port uint16 `yaml:"peer-port"` - SrcAddr string `yaml:"source-address"` - HoldTime string `yaml:"hold-time"` - RouterID string `yaml:"router-id"` - NodeSelectors []NodeSelector `yaml:"node-selectors"` - Password string `yaml:"password"` - Name string `yaml:"name,omitempty"` + MyASN uint32 `json:"my-asn"` + ASN uint32 `json:"peer-asn"` + Addr string `json:"peer-address"` + Port uint16 `json:"peer-port"` + SrcAddr string `json:"source-address"` + HoldTime string `json:"hold-time"` + RouterID string `json:"router-id"` + NodeSelectors []NodeSelector `json:"node-selectors"` + Password string `json:"password"` + Name string `json:"name,omitempty"` } type NodeSelector struct { - MatchLabels map[string]string `yaml:"match-labels"` - MatchExpressions []SelectorRequirements `yaml:"match-expressions"` + MatchLabels map[string]string `json:"match-labels"` + MatchExpressions []SelectorRequirements `json:"match-expressions"` } type SelectorRequirements struct { - Key string `yaml:"key"` - Operator string `yaml:"operator"` - Values []string `yaml:"values"` + Key string `json:"key"` + Operator string `json:"operator"` + Values []string `json:"values"` } type AddressPool struct { Protocol Proto Name string Addresses []string - AvoidBuggyIPs bool `yaml:"avoid-buggy-ips"` - AutoAssign *bool `yaml:"auto-assign"` - BGPAdvertisements []BgpAdvertisement `yaml:"bgp-advertisements"` + AvoidBuggyIPs bool `json:"avoid-buggy-ips"` + AutoAssign *bool `json:"auto-assign"` + BGPAdvertisements []BgpAdvertisement `json:"bgp-advertisements"` } type BgpAdvertisement struct { - AggregationLength *int `yaml:"aggregation-length"` + AggregationLength *int `json:"aggregation-length"` LocalPref *uint32 Communities []string } diff --git a/metal/loadbalancers/metallb/configmap_test.go b/metal/loadbalancers/metallb/configmap_test.go index ac3334ba..79695250 100644 --- a/metal/loadbalancers/metallb/configmap_test.go +++ b/metal/loadbalancers/metallb/configmap_test.go @@ -629,9 +629,9 @@ func TestSelectorRequirementsSliceLess(t *testing.T) { // basic set we use for our tests. /* type SelectorRequirements struct { - Key string `yaml:"key"` - Operator string `yaml:"operator"` - Values []string `yaml:"values"` + Key string `json:"key"` + Operator string `json:"operator"` + Values []string `json:"values"` } */ sr := map[string]SelectorRequirements{ From 66e1d70f91ceca798a0e584cee3dc2b872ca7046 Mon Sep 17 00:00:00 2001 From: Chris Privitere <23177737+cprivitere@users.noreply.github.com> Date: Wed, 19 Apr 2023 13:08:26 -0500 Subject: [PATCH 4/4] fix: additional json tags for remaining fields Signed-off-by: Chris Privitere <23177737+cprivitere@users.noreply.github.com> --- metal/loadbalancers/metallb/config.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/metal/loadbalancers/metallb/config.go b/metal/loadbalancers/metallb/config.go index 0fe6eae1..d032fef6 100644 --- a/metal/loadbalancers/metallb/config.go +++ b/metal/loadbalancers/metallb/config.go @@ -28,7 +28,7 @@ import ( // configFile is the configuration as parsed out of the ConfigMap, // without validation or useful high level types. type ConfigFile struct { - Peers []Peer + Peers []Peer `json:"peers"` BGPCommunities map[string]string `json:"bgp-communities"` Pools []AddressPool `json:"address-pools"` } @@ -58,9 +58,9 @@ type SelectorRequirements struct { } type AddressPool struct { - Protocol Proto - Name string - Addresses []string + Protocol Proto `json:"protocol"` + Name string `json:"name"` + Addresses []string `json:"addresses"` AvoidBuggyIPs bool `json:"avoid-buggy-ips"` AutoAssign *bool `json:"auto-assign"` BGPAdvertisements []BgpAdvertisement `json:"bgp-advertisements"`