Skip to content

Commit 87e059f

Browse files
committed
rename default urls
1 parent 82870df commit 87e059f

File tree

4 files changed

+40
-43
lines changed

4 files changed

+40
-43
lines changed

pkg/environment/config.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ type Config struct {
3636
GraphQL []string `json:"graphql_urls"`
3737
KycURL string `json:"kyc_url"`
3838
RegistrarURL string `json:"registrar_url"`
39-
FlistURL string `json:"flist_url"`
40-
V4FlistURL string `json:"v4_flist_url"`
41-
HubURL string `json:"hub_url"`
42-
V4HubURL string `json:"v4_hub_url"`
43-
HubStorage string `json:"hub_storage"`
44-
V4HubStorage string `json:"v4_hub_storage"`
4539
BinRepo string `json:"bin_repo"`
4640
GeoipURLs []string `json:"geoip_urls"`
41+
42+
FlistURL string `json:"flist_url"`
43+
V4FlistURL string `json:"v4_flist_url"`
44+
45+
HubURL string `json:"hub_url"`
46+
V4HubURL string `json:"v4_hub_url"`
47+
48+
HubStorage string `json:"hub_storage"`
49+
V4HubStorage string `json:"v4_hub_storage"`
4750
}
4851

4952
// Merge, updates current config with cfg merging and override config

pkg/environment/environment.go

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import (
1818
const (
1919
baseExtendedURL = "https://raw.githubusercontent.com/threefoldtech/zos-config/main/"
2020

21-
hubURL = "https://hub.threefold.me"
22-
v4HubURL = "https://v4.hub.threefold.me"
21+
defaultHubURL = "https://hub.threefold.me"
22+
defaultV4HubURL = "https://v4.hub.threefold.me"
2323

24-
flistURL = "redis://hub.threefold.me:9900"
25-
v4FlistURL = "redis://v4.hub.threefold.me:9940"
24+
defaultFlistURL = "redis://hub.threefold.me:9900"
25+
defaultV4FlistURL = "redis://v4.hub.threefold.me:9940"
2626

2727
defaultHubStorage = "zdb://hub.threefold.me:9900"
2828
defaultV4HubStorage = "zdb://v4.hub.threefold.me:9940"
@@ -55,11 +55,12 @@ type Environment struct {
5555
RunningMode RunMode
5656

5757
FlistURL string
58-
HubURL string
59-
V4HubURL string
6058
HubStorage string
6159
BinRepo string
6260

61+
HubURL string
62+
V4HubURL string
63+
6364
FarmID pkg.FarmID
6465
Orphan bool
6566

@@ -142,9 +143,9 @@ var (
142143
"https://activation.dev.grid.tf/activation/activate",
143144
"https://activation.02.dev.grid.tf/activation/activate",
144145
},
145-
FlistURL: flistURL,
146-
HubURL: hubURL,
147-
V4HubURL: v4HubURL,
146+
FlistURL: defaultFlistURL,
147+
HubURL: defaultHubURL,
148+
V4HubURL: defaultV4HubURL,
148149
HubStorage: defaultHubStorage,
149150
BinRepo: "tf-zos-v3-bins.dev",
150151
GraphQL: []string{
@@ -170,9 +171,9 @@ var (
170171
"https://activation.test.grid.tf/activation/activate",
171172
"https://activation.02.test.grid.tf/activation/activate",
172173
},
173-
FlistURL: flistURL,
174-
HubURL: hubURL,
175-
V4HubURL: v4HubURL,
174+
FlistURL: defaultFlistURL,
175+
HubURL: defaultHubURL,
176+
V4HubURL: defaultV4HubURL,
176177
HubStorage: defaultHubStorage,
177178
BinRepo: "tf-zos-v3-bins.test",
178179
GraphQL: []string{
@@ -198,9 +199,9 @@ var (
198199
"https://activation.qa.grid.tf/activation/activate",
199200
"https://activation.02.qa.grid.tf/activation/activate",
200201
},
201-
FlistURL: flistURL,
202-
HubURL: hubURL,
203-
V4HubURL: v4HubURL,
202+
FlistURL: defaultFlistURL,
203+
HubURL: defaultHubURL,
204+
V4HubURL: defaultV4HubURL,
204205
HubStorage: defaultHubStorage,
205206
BinRepo: "tf-zos-v3-bins.qanet",
206207
GraphQL: []string{
@@ -226,19 +227,19 @@ var (
226227
// "wss://relay.02.grid.tf",
227228
},
228229
ActivationURL: []string{
229-
"https://activation.grid.threefold.me/activation/activate",
230230
"https://activation.grid.tf/activation/activate",
231231
"https://activation.02.grid.tf/activation/activate",
232+
"https://activation.grid.threefold.me/activation/activate",
232233
},
233-
FlistURL: flistURL,
234-
HubURL: hubURL,
235-
V4HubURL: v4HubURL,
234+
FlistURL: defaultFlistURL,
235+
HubURL: defaultHubURL,
236+
V4HubURL: defaultV4HubURL,
236237
HubStorage: defaultHubStorage,
237238
BinRepo: "tf-zos-v3-bins",
238239
GraphQL: []string{
239-
"https://graphql.grid.threefold.me/graphql",
240240
"https://graphql.grid.tf/graphql",
241241
"https://graphql.02.grid.tf/graphql",
242+
"https://graphql.grid.threefold.me/graphql",
242243
},
243244
KycURL: "https://kyc.threefold.me",
244245
RegistrarURL: "https://registrar.prod4.threefold.me",
@@ -326,29 +327,24 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) {
326327
if err != nil {
327328
// maybe the node can't reach the internet right now
328329
// this will enforce node to skip config
330+
// or we can keep retrying untill it can fetch config
329331
config = Config{}
330332
}
331333

332-
if substrate, ok := params.Get("substrate"); ok {
333-
if len(substrate) > 0 {
334-
env.SubstrateURL = substrate
335-
}
334+
if substrate, ok := params.Get("substrate"); ok && len(substrate) > 0 {
335+
env.SubstrateURL = substrate
336336
} else if substrate := config.SubstrateURL; len(substrate) > 0 {
337337
env.SubstrateURL = substrate
338338
}
339339

340-
if relay, ok := params.Get("relay"); ok {
341-
if len(relay) > 0 {
342-
env.relaysURLs = relay
343-
}
340+
if relay, ok := params.Get("relay"); ok && len(relay) > 0 {
341+
env.relaysURLs = relay
344342
} else if relay := config.RelaysURLs; len(relay) > 0 {
345343
env.relaysURLs = relay
346344
}
347345

348-
if activation, ok := params.Get("activation"); ok {
349-
if len(activation) > 0 {
350-
env.ActivationURL = activation
351-
}
346+
if activation, ok := params.Get("activation"); ok && len(activation) > 0 {
347+
env.ActivationURL = activation
352348
} else if activation := config.ActivationURL; len(activation) > 0 {
353349
env.ActivationURL = activation
354350
}
@@ -392,7 +388,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) {
392388

393389
// if the node running v4 chage urls to use v4 hub
394390
if params.IsV4() {
395-
env.FlistURL = v4FlistURL
391+
env.FlistURL = defaultV4FlistURL
396392
if flist := config.V4FlistURL; len(flist) > 0 {
397393
env.FlistURL = flist
398394
}

pkg/upgrade/hub/hub.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ func (h *HubClient) StorageURL() string {
9898
// StorageURL return hub storage url
9999
func (h *HubClient) HubBaseURL() string {
100100
env := environment.MustGet()
101-
hubBaseURL := env.HubURL
102101
if kernel.GetParams().IsV4() {
103102
return env.V4HubURL
104103
}
105-
return hubBaseURL
104+
return env.HubURL
106105
}
107106

108107
// Info gets flist info from hub

pkg/upgrade/upgrade_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ func TestUpgraderDownload(t *testing.T) {
2121
}
2222

2323
env := environment.MustGet()
24-
hubStorage := env.HubStorage
25-
err := Storage(hubStorage)(up)
24+
err := Storage(env.HubStorage)(up)
2625
require.NoError(err)
2726

2827
const repo = "azmy.3bot"

0 commit comments

Comments
 (0)