Skip to content

Commit

Permalink
feat(update): update dl mirror & k3s version
Browse files Browse the repository at this point in the history
update dl mirror & k3s version

Signed-off-by: ysicing <i@ysicing.me>
  • Loading branch information
ysicing committed Dec 10, 2021
1 parent 1992c08 commit 3aa9661
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Ergo CHANGELOG

- v2.7.0-beta
- v2.6.8
- 自动生成文档
- kubeconfig管理使用
- 优化配置文件下载

- v2.6.7
- 多处优化
Expand Down
15 changes: 12 additions & 3 deletions common/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
const (
PluginRepoRemoteMode = "remote"
PluginRepoLocalMode = "local"
PluginGithubJiasu = "https://mirror.ghproxy.com"
PluginGithubJiasu = "https://ghproxy.hk1.godu.dev"
PluginRepoType = "plugin"
ServiceRepoType = "service"
ServiceRunType = "compose"
Expand All @@ -32,8 +32,8 @@ const (
const (
K3sBinName = "k3s"
K3sBinPath = "/usr/local/bin/k3s"
K3sBinVersion = "v1.22.3+k3s1"
K3sBinURL = "https://github.com/k3s-io/k3s/releases/download/v1.22.3%2Bk3s1/k3s"
K3sBinVersion = "v1.22.4+k3s1"
K3sBinURL = "https://github.com/k3s-io/k3s/releases/download/v1.22.4%2Bk3s1/k3s"
K3sAgentEnv = "/etc/systemd/system/k3s-agent.service.env"
K3sKubeConfig = "/etc/rancher/k3s/k3s.yaml"
)
Expand All @@ -43,3 +43,12 @@ const (
KubeBurst = 10
KubectlBinPath = "/usr/local/bin/kubectl"
)

const (
DownloadAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4688.0 Safari/537.36 Edg/97.0.1069.0"
)

var (
DefaultCipherSuites = []uint16{0xc02f, 0xc030, 0xc02b, 0xc02c, 0xcca8, 0xcca9, 0xc013, 0xc009,
0xc014, 0xc00a, 0x009c, 0x009d, 0x002f, 0x0035, 0xc012, 0x000a}
)
8 changes: 7 additions & 1 deletion pkg/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ func downloadHTTP(localPath, url string, dlog log.Logger) error {
url = fmt.Sprintf("%v/%v", common.PluginGithubJiasu, url)
}

resp, err := http.Get(url)
// resp, err := http.Get(url)
client := &http.Client{
Timeout: time.Second * 5,
}
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("User-Agent", common.DownloadAgent)
resp, err := client.Do(req)
if err != nil {
return err
}
Expand Down
18 changes: 17 additions & 1 deletion pkg/downloader/downloader_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package downloader

import (
"fmt"
"path/filepath"
"testing"

"github.com/ysicing/ergo/common"
"gotest.tools/assert"
)

Expand All @@ -15,9 +17,23 @@ func TestDownload(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Run("without cache", func(t *testing.T) {
// t.Run("without proxy", func(t *testing.T) {
// t.Run("without digest", func(t *testing.T) {
// localPath := filepath.Join(t.TempDir(), t.Name())
// r, err := Download(dummyRemoteFileURL, localPath)
// assert.NilError(t, err)
// assert.Equal(t, StatusDownloaded, r.Status)

// // download again, make sure StatusSkippedIsReturned
// r, err = Download(dummyRemoteFileURL, localPath)
// assert.NilError(t, err)
// assert.Equal(t, StatusSkipped, r.Status)
// })
// })
t.Run("with proxy", func(t *testing.T) {
t.Run("without digest", func(t *testing.T) {
localPath := filepath.Join(t.TempDir(), t.Name())
dummyRemoteFileURL := fmt.Sprintf("%v/%v", common.PluginGithubJiasu, dummyRemoteFileURL)
r, err := Download(dummyRemoteFileURL, localPath)
assert.NilError(t, err)
assert.Equal(t, StatusDownloaded, r.Status)
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.0-beta
2.6.8

0 comments on commit 3aa9661

Please sign in to comment.