This repository was archived by the owner on Dec 17, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ package commands
2+
3+ import (
4+ "github.com/blang/semver"
5+ "github.com/docker/machine/libmachine"
6+ "github.com/docker/machine/libmachine/log"
7+ "github.com/lambda-linux/lambda-machine-local/version"
8+ "github.com/rhysd/go-github-selfupdate/selfupdate"
9+ )
10+
11+ const (
12+ slug = "lambda-linux/lambda-machine-local"
13+ )
14+
15+ func cmdUpdateCli (c CommandLine , api libmachine.API ) error {
16+ if len (c .Args ()) != 0 {
17+ return ErrTooManyArguments
18+ }
19+
20+ if log .GetDebug () {
21+ log .Debug ("Enabling selfupdate.EnableLog()" )
22+ selfupdate .EnableLog ()
23+ }
24+
25+ latest_gh , found , err := selfupdate .DetectLatest (slug )
26+ if err != nil {
27+ log .Info (err )
28+ return nil
29+ }
30+ if ! found {
31+ log .Info ("No release was found" )
32+ return nil
33+ }
34+
35+ current_ver := semver .MustParse (version .Version )
36+
37+ if current_ver .GTE (latest_gh .Version ) {
38+ log .Infof ("Lambda Machine Local version %s is currently the latest version" , current_ver )
39+ return nil
40+ }
41+
42+ log .Info ("Starting update..." )
43+ latest_gh , err = selfupdate .UpdateSelf (current_ver , slug )
44+ if err != nil {
45+ log .Info (err )
46+ return nil
47+ }
48+ log .Infof ("Updated to latest Lambda Machine Local version %s" , latest_gh .Version )
49+
50+ return nil
51+ }
You can’t perform that action at this time.
0 commit comments