@@ -5,38 +5,38 @@ import (
5
5
"bytes"
6
6
"compress/gzip"
7
7
"fmt"
8
- "github.com/loft-sh/devspace/assets"
9
8
"io"
10
9
"io/fs"
11
10
"io/ioutil"
12
11
"net/http"
13
12
"os"
14
13
"path/filepath"
15
- "regexp"
16
14
"strings"
17
15
"sync"
18
16
"time"
19
17
18
+ "github.com/loft-sh/devspace/assets"
20
19
"github.com/loft-sh/devspace/pkg/devspace/config/constants"
21
20
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
22
21
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
23
22
"github.com/loft-sh/devspace/pkg/devspace/upgrade"
23
+ "github.com/loft-sh/devspace/pkg/util/git"
24
24
"github.com/loft-sh/devspace/pkg/util/hash"
25
25
logpkg "github.com/loft-sh/devspace/pkg/util/log"
26
26
"github.com/mitchellh/go-homedir"
27
27
"github.com/pkg/errors"
28
28
v1 "k8s.io/api/core/v1"
29
29
)
30
30
31
+ // DevSpaceHelperRepository is the repository containing the devspace helper
32
+ const DevSpaceHelperRepository = "https://github.com/loft-sh/devspace"
33
+
31
34
// 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 "
33
36
34
37
// DevSpaceHelperTempFolder is the local folder where we store the sync helper
35
38
const DevSpaceHelperTempFolder = "devspacehelper"
36
39
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
-
40
40
// DevSpaceHelperContainerPath is the path of the devspace helper in the container
41
41
const DevSpaceHelperContainerPath = "/tmp/devspacehelper"
42
42
@@ -143,34 +143,15 @@ func installDevSpaceHelperInContainer(client kubectl.Client, pod *v1.Pod, contai
143
143
144
144
// getDownloadURL
145
145
func devSpaceHelperDownloadURL (version , filename string ) (string , error ) {
146
- url := ""
147
146
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
+ }
167
152
}
168
153
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
174
155
}
175
156
176
157
func downloadSyncHelper (helperName , syncBinaryFolder , version string , log logpkg.Logger ) error {
0 commit comments