@@ -5,38 +5,38 @@ import (
55 "bytes"
66 "compress/gzip"
77 "fmt"
8- "github.com/loft-sh/devspace/assets"
98 "io"
109 "io/fs"
1110 "io/ioutil"
1211 "net/http"
1312 "os"
1413 "path/filepath"
15- "regexp"
1614 "strings"
1715 "sync"
1816 "time"
1917
18+ "github.com/loft-sh/devspace/assets"
2019 "github.com/loft-sh/devspace/pkg/devspace/config/constants"
2120 "github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
2221 "github.com/loft-sh/devspace/pkg/devspace/kubectl"
2322 "github.com/loft-sh/devspace/pkg/devspace/upgrade"
23+ "github.com/loft-sh/devspace/pkg/util/git"
2424 "github.com/loft-sh/devspace/pkg/util/hash"
2525 logpkg "github.com/loft-sh/devspace/pkg/util/log"
2626 "github.com/mitchellh/go-homedir"
2727 "github.com/pkg/errors"
2828 v1 "k8s.io/api/core/v1"
2929)
3030
31+ // DevSpaceHelperRepository is the repository containing the devspace helper
32+ const DevSpaceHelperRepository = "https://github.com/loft-sh/devspace"
33+
3134// DevSpaceHelperBaseURL is the base url where to look for the sync helper
32- const DevSpaceHelperBaseURL = "https://github.com/loft-sh/devspace/ releases"
35+ const DevSpaceHelperBaseURL = DevSpaceHelperRepository + "/ releases/download "
3336
3437// DevSpaceHelperTempFolder is the local folder where we store the sync helper
3538const DevSpaceHelperTempFolder = "devspacehelper"
3639
37- // helperBinaryRegEx is the regexp that finds the correct download link for the sync helper binary
38- var helperBinaryRegEx = `href="(\/loft-sh\/devspace\/releases\/download\/[^\/]*\/%s)"`
39-
4040// DevSpaceHelperContainerPath is the path of the devspace helper in the container
4141const DevSpaceHelperContainerPath = "/tmp/devspacehelper"
4242
@@ -143,34 +143,15 @@ func installDevSpaceHelperInContainer(client kubectl.Client, pod *v1.Pod, contai
143143
144144// getDownloadURL
145145func devSpaceHelperDownloadURL (version , filename string ) (string , error ) {
146- url := ""
147146 if version == "latest" {
148- url = fmt .Sprintf ("%s/%s" , DevSpaceHelperBaseURL , version )
149- } else {
150- url = fmt .Sprintf ("%s/tag/%s" , DevSpaceHelperBaseURL , version )
151- }
152-
153- // Download html
154- resp , err := http .Get (url )
155- if err != nil {
156- return "" , errors .Wrap (err , "get url" )
157- }
158-
159- body , err := ioutil .ReadAll (resp .Body )
160- if err != nil {
161- return "" , errors .Wrap (err , "read body" )
162- }
163-
164- regEx , err := regexp .Compile (fmt .Sprintf (helperBinaryRegEx , filename ))
165- if err != nil {
166- return "" , err
147+ var err error
148+ version , err = git .GetLatestVersion (DevSpaceHelperRepository )
149+ if err != nil {
150+ return "" , errors .Wrap (err , "get latest version" )
151+ }
167152 }
168153
169- matches := regEx .FindStringSubmatch (string (body ))
170- if len (matches ) != 2 {
171- return "" , errors .Errorf ("couldn't find %s in github release %s at url %s" , filename , version , url )
172- }
173- return "https://github.com" + matches [1 ], nil
154+ return fmt .Sprintf ("%s/%s/%s" , DevSpaceHelperBaseURL , version , filename ), nil
174155}
175156
176157func downloadSyncHelper (helperName , syncBinaryFolder , version string , log logpkg.Logger ) error {
0 commit comments