@@ -6,40 +6,41 @@ import (
66 "compress/gzip"
77 "context"
88 "fmt"
9- "github.com/loft-sh/devspace/assets"
10- "github.com/loft-sh/devspace/pkg/devspace/env"
119 "io"
1210 "io/fs"
1311 "io/ioutil"
14- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1512 "net/http"
1613 "os"
1714 "path/filepath"
18- "regexp"
1915 "strings"
2016 "sync"
2117 "time"
2218
19+ "github.com/loft-sh/devspace/assets"
20+ "github.com/loft-sh/devspace/pkg/devspace/env"
21+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
2323 "github.com/loft-sh/devspace/pkg/devspace/config/constants"
2424 "github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
2525 "github.com/loft-sh/devspace/pkg/devspace/kubectl"
2626 "github.com/loft-sh/devspace/pkg/devspace/upgrade"
27+ "github.com/loft-sh/devspace/pkg/util/git"
2728 "github.com/loft-sh/devspace/pkg/util/hash"
2829 logpkg "github.com/loft-sh/devspace/pkg/util/log"
2930 "github.com/mitchellh/go-homedir"
3031 "github.com/pkg/errors"
3132 v1 "k8s.io/api/core/v1"
3233)
3334
35+ // DevSpaceHelperRepository is the repository containing the devspace helper
36+ const DevSpaceHelperRepository = "https://github.com/loft-sh/devspace"
37+
3438// DevSpaceHelperBaseURL is the base url where to look for the sync helper
35- const DevSpaceHelperBaseURL = "https://github.com/loft-sh/devspace/ releases"
39+ const DevSpaceHelperBaseURL = DevSpaceHelperRepository + "/ releases/download "
3640
3741// DevSpaceHelperTempFolder is the local folder where we store the sync helper
3842const DevSpaceHelperTempFolder = "devspacehelper"
3943
40- // helperBinaryRegEx is the regexp that finds the correct download link for the sync helper binary
41- var helperBinaryRegEx = `href="(\/loft-sh\/devspace\/releases\/download\/[^\/]*\/%s)"`
42-
4344// DevSpaceHelperContainerPath is the path of the devspace helper in the container
4445const DevSpaceHelperContainerPath = "/tmp/devspacehelper"
4546
@@ -153,34 +154,15 @@ func installDevSpaceHelperInContainer(ctx context.Context, client kubectl.Client
153154
154155// getDownloadURL
155156func devSpaceHelperDownloadURL (version , filename string ) (string , error ) {
156- url := ""
157157 if version == "latest" {
158- url = fmt .Sprintf ("%s/%s" , DevSpaceHelperBaseURL , version )
159- } else {
160- url = fmt .Sprintf ("%s/tag/%s" , DevSpaceHelperBaseURL , version )
161- }
162-
163- // Download html
164- resp , err := http .Get (url )
165- if err != nil {
166- return "" , errors .Wrap (err , "get url" )
167- }
168-
169- body , err := ioutil .ReadAll (resp .Body )
170- if err != nil {
171- return "" , errors .Wrap (err , "read body" )
172- }
173-
174- regEx , err := regexp .Compile (fmt .Sprintf (helperBinaryRegEx , filename ))
175- if err != nil {
176- return "" , err
158+ var err error
159+ version , err = git .GetLatestVersion (DevSpaceHelperRepository )
160+ if err != nil {
161+ return "" , errors .Wrap (err , "get latest version" )
162+ }
177163 }
178164
179- matches := regEx .FindStringSubmatch (string (body ))
180- if len (matches ) != 2 {
181- return "" , errors .Errorf ("couldn't find %s in github release %s at url %s" , filename , version , url )
182- }
183- return "https://github.com" + matches [1 ], nil
165+ return fmt .Sprintf ("%s/%s/%s" , DevSpaceHelperBaseURL , version , filename ), nil
184166}
185167
186168func downloadSyncHelper (ctx context.Context , helperName , syncBinaryFolder , version string , log logpkg.Logger ) error {
0 commit comments