Skip to content

Commit

Permalink
Merge pull request #45 from suzuki-shunsuke/fix/rename-pkg-info-repo
Browse files Browse the repository at this point in the history
fix: rename PackageInfo.Repo
  • Loading branch information
suzuki-shunsuke authored Aug 26, 2021
2 parents f4399e6 + 71b982f commit fca2366
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
25 changes: 23 additions & 2 deletions aqua.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
packages:
- name: aqua
repository: inline
version: v0.1.0-3
- name: akoi
repository: inline
version: v2.2.1
- name: golangci
repository: inline
version: v1.42.0
inline_repository:
- name: akoi
type: github_release
repo: suzuki-shunsuke/akoi
repo_owner: suzuki-shunsuke
repo_name: akoi
artifact: 'akoi_{{trimPrefix "v" .Package.Version}}_{{.OS}}_{{.Arch}}.tar.gz'
files:
- name: akoi
src: akoi
- name: aqua
type: github_release
repo_owner: suzuki-shunsuke
repo_name: aqua
artifact: 'aqua_{{.OS}}_{{.Arch}}.tar.gz'
files:
- name: aqua
- name: golangci
type: github_release
repo_owner: golangci
repo_name: golangci-lint
artifact: 'golangci-lint-{{trimPrefix "v" .Package.Version}}-{{.OS}}-{{.Arch}}.tar.gz'
files:
- name: golangci-lint
src: 'golangci-lint-{{trimPrefix "v" .Package.Version}}-{{.OS}}-{{.Arch}}/golangci-lint'
3 changes: 2 additions & 1 deletion pkg/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ type Package struct {
type PackageInfo struct {
Name string `validate:"required"`
Type string `validate:"required"`
Repo string `validate:"required"`
RepoOwner string `yaml:"repo_owner" validate:"required"`
RepoName string `yaml:"repo_name" validate:"required"`
Artifact *text.Template `validate:"required"`
ArchiveType string `yaml:"archive_type"`
Files []*File `validate:"required,dive"`
Expand Down
6 changes: 1 addition & 5 deletions pkg/controller/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package controller
import (
"context"
"errors"
"strings"

"github.com/sirupsen/logrus"
)
Expand All @@ -15,15 +14,12 @@ func (ctrl *Controller) download(ctx context.Context, pkg *Package, pkgInfo *Pac
"repository": pkg.Repository,
})
logE.Info("download and unarchive the package")
s := strings.Split(pkgInfo.Repo, "/")
owner := s[0]
repoName := s[1]

if pkgInfo.Type == "github_release" && ctrl.GitHub == nil {
return errors.New("GITHUB_TOKEN is required for the type `github_release`")
}

body, err := ctrl.downloadFromGitHub(ctx, owner, repoName, pkg.Version, assetName)
body, err := ctrl.downloadFromGitHub(ctx, pkgInfo.RepoOwner, pkgInfo.RepoName, pkg.Version, assetName)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (ctrl *Controller) installPackage(ctx context.Context, inlineRepo map[strin
}

func getPkgPath(aquaRootDir string, pkg *Package, pkgInfo *PackageInfo, assetName string) string {
return filepath.Join(aquaRootDir, "pkgs", pkgInfo.Type, "github.com", pkgInfo.Repo, pkg.Version, assetName)
return filepath.Join(aquaRootDir, "pkgs", pkgInfo.Type, "github.com", pkgInfo.RepoOwner, pkgInfo.RepoName, pkg.Version, assetName)
}

func (ctrl *Controller) createLink(cfg *Config, file *File) error {
Expand Down
9 changes: 5 additions & 4 deletions pkg/controller/install_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ func (ctrl *Controller) installProxy(ctx context.Context) error {

logE.Debug("install the proxy")
pkgInfo := &PackageInfo{
Name: "inline",
Type: "github_release",
Repo: "suzuki-shunsuke/aqua-proxy",
Artifact: nil,
Name: "inline",
Type: "github_release",
RepoOwner: "suzuki-shunsuke",
RepoName: "aqua-proxy",
Artifact: nil,
Files: []*File{
{
Name: "aqua-proxy",
Expand Down

0 comments on commit fca2366

Please sign in to comment.