Skip to content

Commit 0bbd7fa

Browse files
authored
Merge pull request #17 from threefoldtech/use-registrar-client-in-update-worker
update zos update worker to use node registrar client
2 parents b05e7d8 + 8a9e3b5 commit 0bbd7fa

File tree

4 files changed

+116
-91
lines changed

4 files changed

+116
-91
lines changed

.github/workflows/zos-update-worker-main.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Zos Update Worker
22

33
defaults:
44
run:
5-
working-directory: tools/zos-update-worker
5+
working-directory: tools/zos-update-worker
66

7-
on:
7+
on:
88
push:
99
paths:
1010
- tools/zos-update-worker/**
@@ -21,20 +21,24 @@ jobs:
2121

2222
- name: Install GO
2323
uses: actions/setup-go@v3
24-
with:
25-
go-version: 1.19
24+
with:
25+
go-version: 1.24
2626

2727
- name: golangci-lint
2828
uses: golangci/golangci-lint-action@v3
2929
with:
3030
args: --timeout 3m --verbose
31-
working-directory: tools/zos-update-worker
31+
working-directory: tools/zos-update-worker
32+
33+
- uses: WillAbides/setup-go-faster@v1.14.0
34+
with:
35+
go-version: 1.24
3236

3337
- name: staticcheck
34-
uses: dominikh/staticcheck-action@v1.3.0
38+
uses: dominikh/staticcheck-action@v1.3.1
3539
with:
36-
version: "2022.1.3"
37-
working-directory: tools/zos-update-worker
40+
version: "latest"
41+
working-directory: tools/zos-update-worker
3842
env:
3943
GO111MODULE: on
4044

@@ -43,8 +47,6 @@ jobs:
4347
with:
4448
gofmt-flags: "-l -d"
4549
gofmt-path: "tools/zos-update-worker"
46-
50+
4751
- name: Test
4852
run: go test -v ./...
49-
50-

tools/zos-update-worker/go.mod

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
module github.com/threefoldtech/zos4/tools/zos-update-version
22

3-
go 1.23.0
3+
go 1.24
44

5-
toolchain go1.24.0
5+
require (
6+
github.com/pkg/errors v0.9.1
7+
github.com/rs/zerolog v1.33.0
8+
github.com/spf13/cobra v1.9.1
9+
github.com/threefoldtech/tfgrid4-sdk-go/node-registrar v0.0.0-20250409160225-5883fc775bc7
10+
)
611

712
require (
8-
github.com/rs/zerolog v1.28.0
9-
github.com/spf13/cobra v1.8.1
13+
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
14+
github.com/cosmos/go-bip39 v1.0.0 // indirect
15+
github.com/decred/base58 v1.0.4 // indirect
16+
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
17+
github.com/gtank/merlin v0.1.1 // indirect
18+
github.com/gtank/ristretto255 v0.1.2 // indirect
19+
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
20+
github.com/vedhavyas/go-subkey/v2 v2.0.0 // indirect
21+
golang.org/x/crypto v0.35.0 // indirect
1022
)
1123

1224
require (
@@ -15,7 +27,7 @@ require (
1527
github.com/mattn/go-colorable v0.1.14 // indirect
1628
github.com/mattn/go-isatty v0.0.20 // indirect
1729
github.com/spf13/pflag v1.0.6 // indirect
18-
golang.org/x/sys v0.30.0 // indirect
30+
golang.org/x/sys v0.31.0 // indirect
1931
)
2032

2133
replace github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.5 => github.com/threefoldtech/go-substrate-rpc-client/v4 v4.0.6-0.20220927094755-0f0d22c73cc7

tools/zos-update-worker/go.sum

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,80 @@
1+
github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM=
2+
github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
3+
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
4+
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
15
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
26
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
3-
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
4-
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
7+
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
8+
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
9+
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
10+
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
11+
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
12+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
13+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
14+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
15+
github.com/decred/base58 v1.0.4 h1:QJC6B0E0rXOPA8U/kw2rP+qiRJsUaE2Er+pYb3siUeA=
16+
github.com/decred/base58 v1.0.4/go.mod h1:jJswKPEdvpFpvf7dsDvFZyLT22xZ9lWqEByX38oGd9E=
17+
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
18+
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
19+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
20+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
21+
github.com/ethereum/go-ethereum v1.10.20 h1:75IW830ClSS40yrQC1ZCMZCt5I+zU16oqId2SiQwdQ4=
22+
github.com/ethereum/go-ethereum v1.10.20/go.mod h1:LWUN82TCHGpxB3En5HVmLLzPD7YSrEUFmFfN1nKkVN0=
523
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
24+
github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
25+
github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is=
26+
github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
27+
github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc=
28+
github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o=
629
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
730
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
8-
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
31+
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
932
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
1033
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
11-
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
34+
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
35+
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
1236
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
1337
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
38+
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM=
39+
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b h1:QrHweqAtyJ9EwCaGHBu1fghwxIPiopAHV06JlXrMHjk=
40+
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b/go.mod h1:xxLb2ip6sSUts3g1irPVHyk/DGslwQsNOo9I7smJfNU=
41+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
1442
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
15-
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
16-
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
17-
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
43+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
44+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
45+
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
46+
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
47+
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
1848
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
19-
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
20-
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
21-
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
49+
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
50+
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
2251
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
2352
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
24-
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
25-
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
53+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
54+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
55+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
56+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
57+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
58+
github.com/threefoldtech/tfgrid4-sdk-go/node-registrar v0.0.0-20250409160225-5883fc775bc7 h1:T3qgbann0BZTAfCzXYlL6P6NpPPd23+Ywq27iBcrp44=
59+
github.com/threefoldtech/tfgrid4-sdk-go/node-registrar v0.0.0-20250409160225-5883fc775bc7/go.mod h1:wZl1DI8fj9dfQryTDBgAqsbALzzi6VJTtuzcOP9xlkY=
60+
github.com/vedhavyas/go-subkey/v2 v2.0.0 h1:LemDIsrVtRSOkp0FA8HxP6ynfKjeOj3BY2U9UNfeDMA=
61+
github.com/vedhavyas/go-subkey/v2 v2.0.0/go.mod h1:95aZ+XDCWAUUynjlmi7BtPExjXgXxByE0WfBwbmIRH4=
62+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
63+
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
64+
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
65+
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
66+
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
67+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
68+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
69+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
70+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2671
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
27-
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
28-
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
72+
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
73+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
74+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
75+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2976
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
77+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
78+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
79+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
3080
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

tools/zos-update-worker/internal/update_worker.go

Lines changed: 22 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ package internal
22

33
import (
44
"context"
5-
"encoding/base64"
6-
"encoding/json"
75
"fmt"
8-
"io"
9-
"net/http"
106
"os"
117
"path/filepath"
12-
"strings"
138
"time"
149

10+
"github.com/pkg/errors"
11+
1512
"github.com/cenkalti/backoff"
1613
"github.com/rs/zerolog/log"
14+
"github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client"
1715
)
1816

1917
type Network string
@@ -30,63 +28,17 @@ type Params struct {
3028
TestUrl string
3129
MainUrl string
3230
}
33-
type RegistrarClient struct {
34-
url string
35-
}
36-
37-
func NewRegistrarClient(url string) RegistrarClient {
38-
return RegistrarClient{url: url}
39-
}
40-
41-
type RegistrarVersion struct {
42-
SafeToUpgrade bool `json:"safe_to_upgrade"`
43-
Version string `json:"version"`
44-
}
45-
46-
func (r RegistrarClient) GetZosVersion() (RegistrarVersion, error) {
47-
url := fmt.Sprintf("%s/v1/zos/version", r.url)
48-
resp, err := http.DefaultClient.Get(url)
49-
if err != nil {
50-
fmt.Println("Error sending get version request:", err)
51-
return RegistrarVersion{}, err
52-
}
53-
defer resp.Body.Close()
54-
body, err := io.ReadAll(resp.Body)
55-
if err != nil {
56-
fmt.Println("Error reading response body:", err)
57-
} else {
58-
fmt.Println("Response received:", string(body))
59-
}
60-
if resp.StatusCode != http.StatusOK {
61-
return RegistrarVersion{}, fmt.Errorf("failed to get version %s with status code %s", url, resp.Status)
62-
}
63-
defer resp.Body.Close()
64-
jsonVersion, err := base64.StdEncoding.DecodeString(strings.Trim(string(body), "\""))
65-
if err != nil {
66-
return RegistrarVersion{}, fmt.Errorf("failed to decode version %w", err)
67-
}
68-
correctedJSON := strings.ReplaceAll(string(jsonVersion), "'", "\"")
69-
var version RegistrarVersion
70-
err = json.Unmarshal([]byte(correctedJSON), &version)
71-
// err = json.NewDecoder(resp.Body).Decode(&version)
72-
if err != nil {
73-
return RegistrarVersion{}, fmt.Errorf("failed to unmarshal version %w", err)
74-
}
75-
76-
return version, nil
77-
}
7831

7932
type Worker struct {
8033
src string
8134
dst string
8235

8336
interval time.Duration
84-
clients map[Network]RegistrarClient
37+
clients map[Network]client.RegistrarClient
8538
}
8639

8740
// NewWorker creates a new instance of the worker
8841
func NewWorker(src string, dst string, params Params) (*Worker, error) {
89-
9042
// we need to recalculate the path of the symlink here because of the following
9143
// - assume we run the tool like `updater -d dst -s src`
9244
// - it's then gonna build the links as above.
@@ -109,18 +61,30 @@ func NewWorker(src string, dst string, params Params) (*Worker, error) {
10961

11062
log.Info().Str("src", src).Str("dst", dst).Msg("paths")
11163

112-
clients := map[Network]RegistrarClient{}
64+
clients := map[Network]client.RegistrarClient{}
11365

11466
if params.QAUrl != "" {
115-
clients[QANetwork] = RegistrarClient{url: params.QAUrl}
67+
cli, err := client.NewRegistrarClient(params.QAUrl)
68+
if err != nil {
69+
return nil, errors.Wrap(err, "failed to create new registrar client for qa net")
70+
}
71+
clients[QANetwork] = cli
11672
}
11773

11874
if params.TestUrl != "" {
119-
clients[TestNetwork] = RegistrarClient{url: params.TestUrl}
75+
cli, err := client.NewRegistrarClient(params.TestUrl)
76+
if err != nil {
77+
return nil, errors.Wrap(err, "failed to create new registrar client for test net")
78+
}
79+
clients[TestNetwork] = cli
12080
}
12181

12282
if params.MainUrl != "" {
123-
clients[MainNetwork] = RegistrarClient{url: params.MainUrl}
83+
cli, err := client.NewRegistrarClient(params.MainUrl)
84+
if err != nil {
85+
return nil, errors.Wrap(err, "failed to create new registrar client for main net")
86+
}
87+
clients[MainNetwork] = cli
12488
}
12589

12690
return &Worker{
@@ -141,7 +105,7 @@ func checkNetwork(network Network) error {
141105
}
142106

143107
// updateZosVersion updates the latest zos flist for a specific network with the updated zos version
144-
func (w *Worker) updateZosVersion(network Network, regClient RegistrarClient) error {
108+
func (w *Worker) updateZosVersion(network Network, regClient client.RegistrarClient) error {
145109
if err := checkNetwork(network); err != nil {
146110
return err
147111
}
@@ -167,7 +131,7 @@ func (w *Worker) updateZosVersion(network Network, regClient RegistrarClient) er
167131
return fmt.Errorf("failed to get dst relative path to src: %w", err)
168132
}
169133

170-
//zos
134+
// zos
171135
zosCurrent := fmt.Sprintf("%v/.tag-%v", w.src, regVersion.Version)
172136
zosLatest := fmt.Sprintf("%v/%v", w.dst, network)
173137

@@ -225,15 +189,12 @@ func (w *Worker) UpdateWithInterval(ctx context.Context) {
225189
exp.MaxInterval = 2 * time.Second
226190
exp.MaxElapsedTime = 10 * time.Second
227191
err := backoff.Retry(func() error {
228-
229192
err := w.updateZosVersion(network, regClient)
230193
if err != nil {
231194
log.Error().Err(err).Msg("update failure. retrying")
232195
}
233196
return err
234-
235197
}, exp)
236-
237198
if err != nil {
238199
log.Error().Err(err).Msg("update zos failed with error")
239200
}

0 commit comments

Comments
 (0)