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

add skywire version to skywire-cli log #1669

Merged
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
22 changes: 11 additions & 11 deletions cmd/skywire-cli/commands/log/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ var logCmd = &cobra.Command{
for _, v := range uptimes {
//only attempt to fetch from online visors
if v.Online {
visorVersion, err := version.NewVersion(v.Version) //nolint
if err != nil {
log.Warnf("The version %s for visor %s is not valid", v.Version, v.PubKey)
continue
}
if fetchFile == "" {
visorVersion, err := version.NewVersion(v.Version) //nolint
if err != nil {
log.Warnf("The version %s for visor %s is not valid", v.Version, v.PubKey)
continue
}
if !allVisors && visorVersion.LessThan(minimumVersion) {
log.Warnf("The version %s for visor %s does not satisfy our minimum version condition", v.Version, v.PubKey)
continue
Expand All @@ -183,7 +183,7 @@ var logCmd = &cobra.Command{
}
// health check before downloading anything else
// delete that folder if the health check fails
err = download(ctx, log, httpC, "health", "health.json", key, maxFileSize)
err = download(ctx, log, httpC, "health", "health.json", key, maxFileSize, visorVersion)
if err != nil {
if deleteOnErrors {
if deleteOnError {
Expand All @@ -193,12 +193,12 @@ var logCmd = &cobra.Command{
}
}
if !logOnly {
download(ctx, log, httpC, "node-info.json", "node-info.json", key, maxFileSize) //nolint
download(ctx, log, httpC, "node-info.json", "node-info.json", key, maxFileSize, visorVersion) //nolint
}
if !surveyOnly {
for i := 0; i <= duration; i++ {
date := time.Now().AddDate(0, 0, -i).UTC().Format("2006-01-02")
download(ctx, log, httpC, date+".csv", date+".csv", key, maxFileSize) //nolint
download(ctx, log, httpC, date+".csv", date+".csv", key, maxFileSize, visorVersion) //nolint
}
}
}(v.PubKey, &wg)
Expand All @@ -221,7 +221,7 @@ var logCmd = &cobra.Command{
return
}
}
_ = download(ctx, log, httpC, fetchFile, fetchFile, key, maxFileSize) //nolint
_ = download(ctx, log, httpC, fetchFile, fetchFile, key, maxFileSize, visorVersion) //nolint
}(v.PubKey, &wg)
}
}
Expand All @@ -237,13 +237,13 @@ var logCmd = &cobra.Command{
},
}

func download(ctx context.Context, log *logging.Logger, httpC http.Client, targetPath, fileName, pubkey string, maxSize int64) error {
func download(ctx context.Context, log *logging.Logger, httpC http.Client, targetPath, fileName, pubkey string, maxSize int64, version *version.Version) error {
target := fmt.Sprintf("dmsg://%s:80/%s", pubkey, targetPath)
file, _ := os.Create(pubkey + "/" + fileName) //nolint
defer file.Close() //nolint

if err := downloadDmsg(ctx, log, &httpC, file, target, maxSize); err != nil {
log.WithError(err).Errorf("The %s for visor %s not available", fileName, pubkey)
log.WithError(err).Errorf("The %s for visor %s not available. The version of visor is %s.", fileName, pubkey, version.String())
return err
}
return nil
Expand Down
Loading