From 818810cf76c702452daf6de1e3c2e4d4ebd9e009 Mon Sep 17 00:00:00 2001 From: rick Date: Sun, 31 Jan 2021 19:14:06 +0800 Subject: [PATCH] Add external URL support for hd-home config --- .github/workflows/pull-request.yaml | 7 +++++++ cmd/get.go | 13 ++++++++++++- cmd/install.go | 1 - 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index e2653d7..cf749ff 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -66,3 +66,10 @@ jobs: languages: go - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 + Markdown Link Check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: gaurav-nelson/github-action-markdown-link-check@v1 + with: + use-verbose-mode: 'yes' diff --git a/cmd/get.go b/cmd/get.go index 28145c4..e7b87ff 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -142,7 +142,17 @@ func (o *downloadOption) providerURLParse(path string) (url string, err error) { } } - if cfg.Filename != "" { + if cfg.URL != "" { + // it does not come from GitHub release + tmp, _ := template.New("hd").Parse(cfg.URL) + + var buf bytes.Buffer + if err = tmp.Execute(&buf, hdPackage); err == nil { + url = buf.String() + } else { + return + } + } else if cfg.Filename != "" { tmp, _ := template.New("hd").Parse(cfg.Filename) var buf bytes.Buffer @@ -170,6 +180,7 @@ type hdConfig struct { Name string Filename string Binary string + URL string `yaml:"url"` Tar string Replacements map[string]string } diff --git a/cmd/install.go b/cmd/install.go index 375dc53..1298672 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -142,7 +142,6 @@ func (o *installOption) extractFiles(tarFile, targetName string) (err error) { if _, err = io.Copy(targetFile, tarReader); err != nil { break } - fmt.Println("found ", targetName, header) found = true _ = targetFile.Close() }