Skip to content

Commit

Permalink
Merge pull request #1576 from aquaproj/revert-1571-revert-1516-feat-v2-2
Browse files Browse the repository at this point in the history
Breaking changes for v2
  • Loading branch information
suzuki-shunsuke authored Mar 21, 2023
2 parents 7ebb640 + 771587b commit ccde778
Show file tree
Hide file tree
Showing 34 changed files with 192 additions and 441 deletions.
25 changes: 2 additions & 23 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,13 @@ jobs:
- run: aqua list
- run: aqua update-checksum
working-directory: tests/main
- run: aqua update-checksum -deep
working-directory: tests/main
- run: aqua update-checksum -prune
working-directory: tests/main
- run: aqua i -l -a
working-directory: tests/main
- run: cmdx -v
working-directory: tests/main
- run: aqua i --test
working-directory: tests/main
- run: aqua which golangci-lint
- run: aqua i
working-directory: tests/main
- run: aqua which go
- run: golangci-lint version
- run: kind version
working-directory: tests/main
- run: kind version
Expand All @@ -223,12 +216,6 @@ jobs:
- run: gh version
- run: tfenv --version
- run: aqua -c tests/main/aqua-global.yaml g local,kubernetes-sigs/kustomize
- run: btop -v
- run: btop -v
env:
AQUA_EXPERIMENTAL_X_SYS_EXEC: "true"
- run: wire --help
- run: gox --help
- run: bats -v
- run: helm version
- run: github-compare -v
Expand Down Expand Up @@ -264,16 +251,10 @@ jobs:
- name: Test generate-registry (specify version)
run: aqua gr suzuki-shunsuke/[email protected]

- name: "test version_source: github_tag"
run: aqua -c aqua-global.yaml g local,mitchellh/gox
working-directory: tests/main

- name: test aqua cp
run: aqua cp actionlint golangci-lint
run: aqua cp actionlint
- name: test aqua cp
run: dist/actionlint -version
- name: test aqua cp
run: dist/golangci-lint version
- name: test aqua cp
run: aqua cp
- name: test aqua cp -a
Expand Down Expand Up @@ -314,8 +295,6 @@ jobs:
- run: aqua update-checksum -a

# Test if global configuration files are read in `aqua list` and `aqua g`
- run: aqua g suzuki-shunsuke/cmdx
working-directory: /tmp
- run: aqua list
working-directory: /tmp

Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/windows-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
working-directory: tests/main
- run: cmdx -v
working-directory: tests/main
- run: aqua i --test
- run: aqua i
working-directory: tests/main
- run: aqua which golangci-lint
working-directory: tests/main
Expand All @@ -56,8 +56,6 @@ jobs:
- run: ghq -version
- run: gh version
- run: aqua -c tests/main/aqua-global.yaml g local,kubernetes-sigs/kustomize
- run: wire --help
- run: gox --help
- run: github-compare -v
- run: helm version
- run: terrafmt version
Expand All @@ -72,10 +70,6 @@ jobs:
- name: "Test generate-registry (rust)"
run: aqua gr XAMPPRocky/tokei

- name: "test version_source: github_tag"
run: aqua -c aqua-global.yaml g local,mitchellh/gox
working-directory: tests/main

# Test if global configuration files are read in `aqua list` and `aqua g`
- run: aqua g suzuki-shunsuke/cmdx
working-directory: ${{ env.HOME }}
Expand Down Expand Up @@ -118,7 +112,7 @@ jobs:
working-directory: tests/main
- run: cmdx -v
working-directory: tests/main
- run: aqua i --test
- run: aqua i
working-directory: tests/main
- run: aqua which golangci-lint
working-directory: tests/main
Expand All @@ -134,8 +128,6 @@ jobs:
- run: ghq -version
- run: gh version
- run: aqua -c tests/main/aqua-global.yaml g local,kubernetes-sigs/kustomize
- run: wire --help
- run: gox --help
- run: github-compare -v
- run: terrafmt version
- run: helm version
Expand All @@ -150,10 +142,6 @@ jobs:
- name: "Test generate-registry (rust)"
run: aqua gr XAMPPRocky/tokei

- name: "test version_source: github_tag"
run: aqua -c aqua-global.yaml g local,mitchellh/gox
working-directory: tests/main

# Test if global configuration files are read in `aqua list` and `aqua g`
- run: aqua g suzuki-shunsuke/cmdx
working-directory: ${{env.HOME}}
Expand Down
1 change: 0 additions & 1 deletion pkg/cli/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func (runner *Runner) cpAction(c *cli.Context) error {
if err := runner.setParam(c, "cp", param); err != nil {
return fmt.Errorf("parse the command line arguments: %w", err)
}
param.IsTest = true
param.SkipLink = true
ctrl := controller.InitializeCopyCommandController(c.Context, param, http.DefaultClient, runner.Runtime)
if err := ctrl.Copy(c.Context, runner.LogE, param); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $ aqua i --exclude-tags foo # Install only packages not having a tag "foo"
},
&cli.BoolFlag{
Name: "test",
Usage: "test file.src after installing the package",
Usage: "This flag was deprecated and had no meaning from aqua v2.0.0. This flag will be removed in aqua v3.0.0. https://github.com/aquaproj/aqua/issues/1691",
},
&cli.BoolFlag{
Name: "all",
Expand Down
1 change: 0 additions & 1 deletion pkg/cli/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (runner *Runner) setParam(c *cli.Context, commandName string, param *config
param.Dest = c.String("o")
param.OutTestData = c.String("out-testdata")
param.OnlyLink = c.Bool("only-link")
param.IsTest = c.Bool("test")
if commandName == "generate-registry" {
param.InsertFile = c.String("i")
} else {
Expand Down
15 changes: 5 additions & 10 deletions pkg/cli/update_checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,33 @@ import (
func (runner *Runner) newUpdateChecksumCommand() *cli.Command {
return &cli.Command{
Name: "update-checksum",
Usage: "Create or Update .aqua-checksums.json",
Usage: "Create or Update aqua-checksums.json",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "all",
Aliases: []string{"a"},
Usage: "Create or Update all .aqua-checksums.json including global configuration",
Usage: "Create or Update all aqua-checksums.json including global configuration",
},
&cli.BoolFlag{
Name: "deep",
Usage: "If a package's checksum configuration is disabled, download the asset and calculate the checksum",
Usage: "This flag was deprecated and had no meaning from aqua v2.0.0. This flag will be removed in aqua v3.0.0. https://github.com/aquaproj/aqua/issues/1769",
},
&cli.BoolFlag{
Name: "prune",
Usage: "Remove unused checksums",
},
},
Description: `Create or Update .aqua-checksums.json.
Description: `Create or Update aqua-checksums.json.
e.g.
$ aqua update-checksum
By default aqua doesn't update .aqua-checksums.json of the global configuration.
By default aqua doesn't update aqua-checksums.json of the global configuration.
If you want to update them too,
please set "-a" option.
$ aqua update-checksum -a
By default, aqua update-checksum doesn't add checksums if the package's checksum configuration is disabled.
If -deep option is set, aqua update-checksum downloads assets and calculate checksums.
$ aqua update-checksum -deep
By default, aqua update-checksum doesn't remove existing checksums even if they aren't unused.
If -prune option is set, aqua unused checksums would be removed.
Expand Down
2 changes: 1 addition & 1 deletion pkg/config-finder/config_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (finder *ConfigFinder) Finds(wd, configFilePath string) []string {
if configFilePath == "" {
return findconfig.Finds(wd, finder.exist, configFileNames()...)
}
return append([]string{util.Abs(wd, configFilePath)}, findconfig.Finds(wd, finder.exist, configFileNames()...)...)
return []string{util.Abs(wd, configFilePath)}
}

func (finder *ConfigFinder) exist(p string) bool {
Expand Down
3 changes: 1 addition & 2 deletions pkg/config-finder/config_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func Test_configFinderFind(t *testing.T) { //nolint:funlen
}
}

func Test_configFinderFinds(t *testing.T) { //nolint:funlen
func Test_configFinderFinds(t *testing.T) {
t.Parallel()
data := []struct {
name string
Expand Down Expand Up @@ -150,7 +150,6 @@ func Test_configFinderFinds(t *testing.T) { //nolint:funlen
},
exp: []string{
"/home/foo/aqua-2.yaml",
"/home/.aqua.yaml",
},
},
}
Expand Down
1 change: 0 additions & 1 deletion pkg/config/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ type Param struct {
Tags map[string]struct{}
ExcludedTags map[string]struct{}
OnlyLink bool
IsTest bool
All bool
Insert bool
SelectVersion bool
Expand Down
45 changes: 22 additions & 23 deletions pkg/config/registry/package_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package registry
import (
"fmt"
"path"
"strings"

"github.com/aquaproj/aqua/pkg/runtime"
"github.com/iancoleman/orderedmap"
Expand All @@ -14,7 +15,6 @@ const (
PkgInfoTypeGitHubContent = "github_content"
PkgInfoTypeGitHubArchive = "github_archive"
PkgInfoTypeHTTP = "http"
PkgInfoTypeGo = "go"
PkgInfoTypeGoInstall = "go_install"
)

Expand All @@ -35,7 +35,6 @@ type PackageInfo struct {
FormatOverrides []*FormatOverride `yaml:"format_overrides,omitempty" json:"format_overrides,omitempty"`
Files []*File `json:"files,omitempty" yaml:",omitempty"`
Replacements Replacements `json:"replacements,omitempty" yaml:",omitempty"`
SupportedIf *string `yaml:"supported_if,omitempty" json:"supported_if,omitempty"`
SupportedEnvs SupportedEnvs `yaml:"supported_envs,omitempty" json:"supported_envs,omitempty"`
VersionFilter *string `yaml:"version_filter,omitempty" json:"version_filter,omitempty"`
VersionPrefix *string `yaml:"version_prefix,omitempty" json:"version_prefix,omitempty"`
Expand Down Expand Up @@ -71,7 +70,6 @@ func (pkgInfo *PackageInfo) Copy() *PackageInfo {
FormatOverrides: pkgInfo.FormatOverrides,
VersionConstraints: pkgInfo.VersionConstraints,
VersionOverrides: pkgInfo.VersionOverrides,
SupportedIf: pkgInfo.SupportedIf,
SupportedEnvs: pkgInfo.SupportedEnvs,
VersionFilter: pkgInfo.VersionFilter,
VersionPrefix: pkgInfo.VersionPrefix,
Expand Down Expand Up @@ -106,7 +104,6 @@ func (pkgInfo *PackageInfo) resetByPkgType(typ string) {
case PkgInfoTypeHTTP:
pkgInfo.Path = nil
pkgInfo.Asset = nil
case PkgInfoTypeGo:
case PkgInfoTypeGoInstall:
pkgInfo.URL = nil
pkgInfo.Asset = nil
Expand Down Expand Up @@ -155,9 +152,6 @@ func (pkgInfo *PackageInfo) overrideVersion(child *VersionOverride) *PackageInfo
if child.FormatOverrides != nil {
pkg.FormatOverrides = child.FormatOverrides
}
if child.SupportedIf != nil {
pkg.SupportedIf = child.SupportedIf
}
if child.SupportedEnvs != nil {
pkg.SupportedEnvs = child.SupportedEnvs
}
Expand Down Expand Up @@ -275,7 +269,6 @@ type VersionOverride struct {
FormatOverrides FormatOverrides `yaml:"format_overrides,omitempty" json:"format_overrides,omitempty"`
Overrides Overrides `yaml:",omitempty" json:"overrides,omitempty"`
Replacements Replacements `yaml:",omitempty" json:"replacements,omitempty"`
SupportedIf *string `yaml:"supported_if,omitempty" json:"supported_if,omitempty"`
SupportedEnvs SupportedEnvs `yaml:"supported_envs,omitempty" json:"supported_envs,omitempty"`
VersionFilter *string `yaml:"version_filter,omitempty" json:"version_filter,omitempty"`
VersionPrefix *string `yaml:"version_prefix,omitempty" json:"version_prefix,omitempty"`
Expand Down Expand Up @@ -395,7 +388,7 @@ func (pkgInfo *PackageInfo) GetLink() string {
}

func (pkgInfo *PackageInfo) GetFormat() string {
if pkgInfo.Type == PkgInfoTypeGitHubArchive || pkgInfo.Type == PkgInfoTypeGo {
if pkgInfo.Type == PkgInfoTypeGitHubArchive {
return "tar.gz"
}
return pkgInfo.Format
Expand Down Expand Up @@ -440,7 +433,7 @@ func (pkgInfo *PackageInfo) Validate() error { //nolint:cyclop
return errPkgNameIsRequired
}
switch pkgInfo.Type {
case PkgInfoTypeGitHubArchive, PkgInfoTypeGo:
case PkgInfoTypeGitHubArchive:
if !pkgInfo.HasRepo() {
return errRepoRequired
}
Expand Down Expand Up @@ -479,28 +472,34 @@ func (pkgInfo *PackageInfo) GetFiles() []*File {
if len(pkgInfo.Files) != 0 {
return pkgInfo.Files
}
if pkgInfo.HasRepo() {

if cmdName := pkgInfo.getDefaultCmdName(); cmdName != "" {
return []*File{
{
Name: pkgInfo.RepoName,
Name: cmdName,
},
}
}
return pkgInfo.Files
}

func (pkgInfo *PackageInfo) getDefaultCmdName() string {
if pkgInfo.HasRepo() {
if pkgInfo.Name == "" {
return pkgInfo.RepoName
}
if i := strings.LastIndex(pkgInfo.Name, "/"); i != -1 {
return pkgInfo.Name[i+1:]
}
return pkgInfo.Name
}
if pkgInfo.Type == PkgInfoTypeGoInstall {
if pkgInfo.Asset != nil {
return []*File{
{
Name: *pkgInfo.Asset,
},
}
}
return []*File{
{
Name: path.Base(pkgInfo.GetPath()),
},
return *pkgInfo.Asset
}
return path.Base(pkgInfo.GetPath())
}
return pkgInfo.Files
return ""
}

func (pkgInfo *PackageInfo) SLSASourceURI() string {
Expand Down
16 changes: 15 additions & 1 deletion pkg/config/registry/package_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func TestPackageInfo_GetReplacements(t *testing.T) {
}
}

func TestPackageInfo_GetFiles(t *testing.T) {
func TestPackageInfo_GetFiles(t *testing.T) { //nolint:funlen
t.Parallel()
data := []struct {
title string
Expand Down Expand Up @@ -248,6 +248,20 @@ func TestPackageInfo_GetFiles(t *testing.T) {
RepoName: "ci-info",
},
},
{
title: "has name",
exp: []*registry.File{
{
Name: "cmctl",
},
},
pkgInfo: &registry.PackageInfo{
Type: "github_release",
RepoOwner: "cert-manager",
RepoName: "cert-manager",
Name: "cert-manager/cert-manager/cmctl",
},
},
}
for _, d := range data {
d := d
Expand Down
6 changes: 1 addition & 5 deletions pkg/config/registry/supported_envs.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package registry

import (
"github.com/aquaproj/aqua/pkg/expr"
"github.com/aquaproj/aqua/pkg/runtime"
)

func (pkgInfo *PackageInfo) CheckSupported(rt *runtime.Runtime, env string) (bool, error) {
if pkgInfo.SupportedEnvs != nil {
return pkgInfo.CheckSupportedEnvs(rt.GOOS, rt.GOARCH, env), nil
}
if pkgInfo.SupportedIf == nil {
return true, nil
}
return expr.EvaluateSupportedIf(pkgInfo.SupportedIf, rt) //nolint:wrapcheck
return true, nil
}

func (pkgInfo *PackageInfo) CheckSupportedEnvs(goos, goarch, env string) bool {
Expand Down
Loading

0 comments on commit ccde778

Please sign in to comment.