MCPcopy Index your code
hub / github.com/devspace-sh/devspace / Upgrade

Function Upgrade

pkg/devspace/upgrade/upgrade.go:126–177  ·  view source on GitHub ↗

Upgrade downloads the latest release from github and replaces devspace if a new version is found

(flagVersion string)

Source from the content-addressed store, hash-verified

124
125// Upgrade downloads the latest release from github and replaces devspace if a new version is found
126func Upgrade(flagVersion string) error {
127 log := log.GetInstance()
128 if flagVersion != "" {
129 release, found, err := selfupdate.DetectVersion(githubSlug, flagVersion)
130 if err != nil {
131 return errors.Wrap(err, "find version")
132 } else if !found {
133 return fmt.Errorf("devspace version %s couldn't be found", flagVersion)
134 }
135
136 cmdPath, err := os.Executable()
137 if err != nil {
138 return err
139 }
140
141 log.Info(fmt.Sprintf("Downloading version %s...", flagVersion))
142 err = selfupdate.DefaultUpdater().UpdateTo(release, cmdPath)
143 if err != nil {
144 return err
145 }
146
147 log.Donef("Successfully updated devspace to version %s", flagVersion)
148 return nil
149 }
150
151 v := semver.MustParse(version)
152
153 newerVersion, err := CheckForNewerVersion()
154 if err != nil {
155 return err
156 }
157 if newerVersion == "" {
158 log.Infof("Current binary is the latest version: %s", version)
159 return nil
160 }
161
162 log.Info("Downloading newest version...")
163 latest, err := selfupdate.UpdateSelf(v, githubSlug)
164 if err != nil {
165 return err
166 }
167
168 if latest.Version.Equals(v) {
169 // latest version is the same as current version. It means current binary is up to date.
170 log.Infof("Current binary is the latest version: %s", version)
171 } else {
172 log.Donef("Successfully updated to version %s", latest.Version)
173 log.Infof("Release note: \n\n%s", latest.ReleaseNotes)
174 }
175
176 return nil
177}

Callers 2

RunMethod · 0.92
TestUpgradeFunction · 0.85

Calls 7

GetInstanceFunction · 0.92
CheckForNewerVersionFunction · 0.85
ErrorfMethod · 0.45
InfoMethod · 0.45
DonefMethod · 0.45
InfofMethod · 0.45
EqualsMethod · 0.45

Tested by 1

TestUpgradeFunction · 0.68