Skip to content

Commit

Permalink
fix: rename artifact to asset
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Aug 28, 2021
1 parent 997a59a commit 756d106
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions aqua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inline_repository:
type: github_release
repo_owner: suzuki-shunsuke
repo_name: akoi
artifact: 'akoi_{{trimPrefix "v" .Package.Version}}_{{.OS}}_{{.Arch}}.tar.gz'
asset: 'akoi_{{trimPrefix "v" .Package.Version}}_{{.OS}}_{{.Arch}}.tar.gz'
files:
- name: akoi
- name: aqua
Expand All @@ -27,7 +27,7 @@ inline_repository:
type: github_release
repo_owner: golangci
repo_name: golangci-lint
artifact: 'golangci-lint-{{trimPrefix "v" .Package.Version}}-{{.OS}}-{{.Arch}}.tar.gz'
asset: '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'
6 changes: 3 additions & 3 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PackageInfo is the package metadata how the package is installed.

* `repo_owner`: GitHub Repository owner
* `repo_name`: GitHub Repository name
* `artifact`: (type: `template string`) GitHub Release asset name
* `asset`: (type: `template string`) GitHub Release asset name

### Repository

Expand All @@ -57,12 +57,12 @@ Only `inline` repository is supported.

Some fields are parsed with [Go's text/template](https://pkg.go.dev/text/template) and [sprig](http://masterminds.github.io/sprig/).

* `PackageInfo.artifact`
* `PackageInfo.asset`
* `File.src`

The following variables are passed to the template.

`PackageInfo.artifact`
`PackageInfo.asset`

* `Package`: the Package
* `Name`
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ type PackageInfo struct {
Type string `validate:"required"`
RepoOwner string `yaml:"repo_owner" validate:"required"`
RepoName string `yaml:"repo_name" validate:"required"`
Artifact *text.Template `validate:"required"`
Asset *text.Template `validate:"required"`
ArchiveType string `yaml:"archive_type"`
Files []*File `validate:"required,dive"`
}

func (pkgInfo *PackageInfo) RenderArtifact(pkg *Package) (string, error) {
return pkgInfo.Artifact.Execute(map[string]interface{}{ //nolint:wrapcheck
func (pkgInfo *PackageInfo) RenderAsset(pkg *Package) (string, error) {
return pkgInfo.Asset.Execute(map[string]interface{}{ //nolint:wrapcheck
"Package": pkg,
"PackageInfo": pkgInfo,
"OS": runtime.GOOS,
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (ctrl *Controller) Exec(ctx context.Context, param *Param, args []string) e
if file.Name != exeName {
continue
}
assetName, err := pkgInfo.RenderArtifact(pkg)
assetName, err := pkgInfo.RenderAsset(pkg)
if err != nil {
return fmt.Errorf("render the asset name: %w", err)
}
Expand Down Expand Up @@ -88,7 +88,7 @@ func isUnarchived(archiveType, assetName string) bool {
}

func (ctrl *Controller) exec(ctx context.Context, pkg *Package, pkgInfo *PackageInfo, src string, args []string) error {
assetName, err := pkgInfo.RenderArtifact(pkg)
assetName, err := pkgInfo.RenderAsset(pkg)
if err != nil {
return fmt.Errorf("render the asset name: %w", 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 @@ -117,7 +117,7 @@ func (ctrl *Controller) installPackage(ctx context.Context, inlineRepo map[strin
return fmt.Errorf("repository isn't found %s", pkg.Name)
}

assetName, err := pkgInfo.RenderArtifact(pkg)
assetName, err := pkgInfo.RenderAsset(pkg)
if err != nil {
return fmt.Errorf("render the asset name: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/install_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (ctrl *Controller) installProxy(ctx context.Context) error {
Type: "github_release",
RepoOwner: "suzuki-shunsuke",
RepoName: "aqua-proxy",
Artifact: nil,
Asset: nil,
Files: []*File{
{
Name: "aqua-proxy",
Expand Down
2 changes: 1 addition & 1 deletion tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inline_repository:
type: github_release
repo_owner: suzuki-shunsuke
repo_name: akoi
artifact: 'akoi_{{trimPrefix "v" .Package.Version}}_{{.OS}}_{{.Arch}}.tar.gz'
asset: 'akoi_{{trimPrefix "v" .Package.Version}}_{{.OS}}_{{.Arch}}.tar.gz'
files:
- name: akoi
src: akoi
Expand Down
2 changes: 1 addition & 1 deletion tutorial/aqua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inline_repository:
type: github_release
repo_owner: suzuki-shunsuke
repo_name: akoi
artifact: 'akoi_{{trimPrefix "v" .Package.Version}}_{{.OS}}_{{.Arch}}.tar.gz'
asset: 'akoi_{{trimPrefix "v" .Package.Version}}_{{.OS}}_{{.Arch}}.tar.gz'
files:
- name: akoi
src: akoi

0 comments on commit 756d106

Please sign in to comment.