Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config fallback in cli #1193

Merged
merged 3 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/skywire-cli/commands/config/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ var genConfigCmd = &cobra.Command{
if output == "" {
outunset = true
confPath = skyenv.ConfigName
output = confPath
} else {
confPath = output
}
Expand Down
8 changes: 5 additions & 3 deletions internal/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ func serversBtn(conf *visorconfig.V1, servers []*systray.MenuItem, rpcClient vis
btnChannel := make(chan int)
for index, server := range servers {
go func(chn chan int, server *systray.MenuItem, index int) {
select {
case <-server.ClickedCh:
chn <- index
for {
select {
case <-server.ClickedCh:
chn <- index
}
}
}(btnChannel, server, index)
}
Expand Down
23 changes: 6 additions & 17 deletions pkg/visor/visorconfig/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@ import (
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire-utilities/pkg/cipher"
utilenv "github.com/skycoin/skywire-utilities/pkg/skyenv"
)

var (
services *Services
svcconf = strings.ReplaceAll(utilenv.ServiceConfAddr, "http://", "")
)

//Fetch fetches the service URLs & ip:ports from the config service endpoint
func Fetch(mLog *logging.MasterLogger, serviceConfURL string, stdout bool) *Services {
// Fetch fetches the service URLs & ip:ports from the config service endpoint
func Fetch(mLog *logging.MasterLogger, serviceConfURL string, stdout bool) (services *Services) {

urlstr := []string{"http://", serviceConfURL}
serviceConf := strings.Join(urlstr, "")
Expand All @@ -34,15 +28,10 @@ func Fetch(mLog *logging.MasterLogger, serviceConfURL string, stdout bool) *Serv
//check for errors in the response
res, err := client.Do(req)
if err != nil {
if serviceConfURL != svcconf {
//if serviceConfURL was changed this error should be fatal
mLog.WithError(err).Fatal("Failed to fetch servers\n")
} else { //otherwise just error and continue
//silence errors for stdout
if !stdout {
mLog.WithError(err).Error("Failed to fetch servers\n")
mLog.Warn("Falling back on hardcoded servers")
}
//silence errors for stdout
if !stdout {
mLog.WithError(err).Error("Failed to fetch servers\n")
mLog.Warn("Falling back on hardcoded servers")
}
} else {
// nil error from client.Do(req)
Expand Down