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 downloading of assets in pmctl #80

Merged
merged 4 commits into from
Jun 20, 2020
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
19 changes: 7 additions & 12 deletions pmctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
},
Beta: false,
DevMode: false,
Online: false,
Online: true, // is disabled later based on command
}

rootCmd = &cobra.Command{
Expand Down Expand Up @@ -182,17 +182,12 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
Beta: false,
})

registry.AddIndex(updater.Index{
Path: "beta.json",
Stable: false,
Beta: true,
})

registry.AddIndex(updater.Index{
Path: "all/intel/intel.json",
Stable: true,
Beta: false,
})
// TODO: enable loading beta versions
// registry.AddIndex(updater.Index{
// Path: "beta.json",
// Stable: false,
// Beta: true,
// })

updateRegistryIndex()
}
Expand Down
14 changes: 10 additions & 4 deletions pmctl/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,10 @@ func handleRun(cmd *cobra.Command, opts *Options) (err error) {
return
}

func run(cmd *cobra.Command, opts *Options) (err error) {
func run(cmd *cobra.Command, opts *Options) (err error) { //nolint:gocognit

// set download option
if opts.AllowDownload {
registry.Online = true
}
registry.Online = opts.AllowDownload

// parse identifier
opts.ShortIdentifier = path.Dir(opts.Identifier)
Expand Down Expand Up @@ -187,8 +185,16 @@ func run(cmd *cobra.Command, opts *Options) (err error) {
log.Println("error seems to be permanent, giving up...")
return err
}
// resilience
time.Sleep(time.Duration(tries) * 2 * time.Second)
if tries >= 2 {
// try updating
updateRegistryIndex()
}
log.Println("trying again...")
case tryAgain && err == nil:
// reset error count
tries = 0
// upgrade
log.Println("restarting by request...")
// update index
Expand Down