Skip to content

Commit

Permalink
Merge pull request #1666 from mrpalide/fix/handle-issue-on-fetch-data…
Browse files Browse the repository at this point in the history
…-for-generate-config

fix issue fetching data from hardcoded server
  • Loading branch information
jdknives authored Nov 2, 2023
2 parents 8bcb1bc + 173bf88 commit b6cad4e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
45 changes: 23 additions & 22 deletions cmd/skywire-cli/commands/config/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,25 +496,26 @@ var genConfigCmd = &cobra.Command{
log.WithError(err).Error("Failed to fetch servers\n")
log.Warn("Falling back on hardcoded servers")
}
}
if res.Body != nil {
defer res.Body.Close() //nolint
}
body, err := io.ReadAll(res.Body)
if err != nil {
log.WithError(err).Fatal("Failed to read response\n")
}
//fill in services struct with the response
err = json.Unmarshal(body, &services)
if err != nil {
log.WithError(err).Fatal("Failed to unmarshal json response\n")
}
if !isStdout {
log.Infof("Fetched service endpoints from '%s'", serviceConfURL)
}
} else {
if res.Body != nil {
defer res.Body.Close() //nolint
}
body, err := io.ReadAll(res.Body)
if err != nil {
log.WithError(err).Fatal("Failed to read response\n")
}
//fill in services struct with the response
err = json.Unmarshal(body, &services)
if err != nil {
log.WithError(err).Fatal("Failed to unmarshal json response\n")
}
if !isStdout {
log.Infof("Fetched service endpoints from '%s'", serviceConfURL)
}

// reset the state of isStdout
isStdout = wasStdout
// reset the state of isStdout
isStdout = wasStdout
}
}

// Read in old config and obtain old secret key or generate a new random secret key
Expand Down Expand Up @@ -580,11 +581,11 @@ var genConfigCmd = &cobra.Command{
conf.Common.PK = pk

dnsServer := utilenv.DNSServer
if services != nil {
if services.DNSServer != "" {
dnsServer = services.DNSServer
}

if services.DNSServer != "" {
dnsServer = services.DNSServer
}

if isDmsgHTTP {
dmsghttpConfig := visorconfig.DMSGHTTPName
// TODO
Expand Down
2 changes: 1 addition & 1 deletion cmd/skywire-cli/commands/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
disableApps string
isBestProtocol bool
serviceConfURL string
services *visorconfig.Services
services visorconfig.Services
isForce bool
isHide bool
isAll bool
Expand Down

0 comments on commit b6cad4e

Please sign in to comment.