Skip to content

Commit

Permalink
Merge branch 'main' into renovate/github.com-google-go-github-v55-56.x
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Oct 16, 2023
2 parents 9cd9c61 + cca85e9 commit b223fae
Show file tree
Hide file tree
Showing 75 changed files with 3,071 additions and 436 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actionlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
actionlint:
uses: suzuki-shunsuke/actionlint-workflow/.github/workflows/actionlint.yaml@b6a5f966d4504893b2aeb60cf2b0de8946e48504 # v0.5.0
with:
aqua_version: v2.13.1
aqua_version: v2.14.0
aqua_policy_allow: true
permissions:
pull-requests: write
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/debug-with-action-tmate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ jobs:
GITHUB_TOKEN: ${{github.token}}
- uses: aquaproj/aqua-installer@36dc5833b04eb63f06e3bb818aa6b7a6e6db99a9 # v2.1.2
with:
aqua_version: v2.13.1
aqua_version: v2.14.0
env:
AQUA_GITHUB_TOKEN: ${{github.token}}
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: 1.21.3

# The default vim doesn't work well, so we install the latest vim ourselves.
- uses: rhysd/action-setup-vim@015df8c5b8dabdca7febe31bb66c156c0d780374 # v1.2.15
- uses: rhysd/action-setup-vim@7da6ebc0a6968029b289c2ebeab34c5ca34cea3f # v1.3.0

- uses: mxschmitt/action-tmate@1005f9c9db5f1b055a495e72c6e589764984baf6 # v3.14
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
homebrew: true
go-version: 1.21.3
aqua_policy_allow: true
aqua_version: v2.13.1
aqua_version: v2.14.0
secrets:
gh_app_id: ${{secrets.APP_ID}}
gh_app_private_key: ${{secrets.APP_PRIVATE_KEY}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wc-ghalint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: aquaproj/aqua-installer@36dc5833b04eb63f06e3bb818aa6b7a6e6db99a9 # v2.1.2
with:
aqua_version: v2.13.1
aqua_version: v2.14.0
env:
AQUA_GITHUB_TOKEN: ${{github.token}}
- run: ghalint run
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wc-go-mod-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: suzuki-shunsuke/go-mod-tidy-workflow/.github/workflows/go-mod-tidy.yaml@8facac38f5b2008648c14e31c632c3a709439b9c # v0.1.1
with:
go-version: 1.21.3
aqua_version: v2.13.1
aqua_version: v2.14.0
secrets:
gh_app_id: ${{secrets.gh_app_id}}
gh_app_private_key: ${{secrets.gh_app_private_key}}
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/wc-integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,34 @@ jobs:
run: aqua cp --exclude-tags test -t foo
working-directory: tests/tag

- name: update only registrires
run: |
aqua update -r
git diff .
git checkout -- .
working-directory: tests/update

- name: update only packages
run: |
aqua up -p
git diff .
git checkout -- .
working-directory: tests/update

- name: update all registries and packages
run: |
aqua update
git diff .
git checkout -- .
working-directory: tests/update

- name: update only specific command
run: |
aqua update tfcmt ci-info
git diff .
git checkout -- .
working-directory: tests/update

- run: aqua update-checksum -a

- name: Test rm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wc-update-aqua-checksums.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
permissions:
contents: read
with:
aqua_version: v2.13.1
aqua_version: v2.14.0
prune: true
secrets:
gh_app_id: ${{secrets.gh_app_id}}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-prebuilt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ WORKDIR /home/foo/workspace
RUN curl -sSfL -O https://raw.githubusercontent.com/aquaproj/aqua-installer/v2.1.2/aqua-installer
RUN echo "411caf1b5fcef4f5e74aa2a9fe99182ea13ab93ecd8ed4a983a7cff9f08edab9 aqua-installer" | sha256sum -c
RUN chmod +x aqua-installer
RUN ./aqua-installer -v "v2.13.1"
RUN ./aqua-installer -v "v2.14.0"
ENV PATH=/home/foo/.local/share/aquaproj-aqua/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
4 changes: 2 additions & 2 deletions aqua/aqua-checksums.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@
"algorithm": "sha256"
},
{
"id": "registries/github_content/github.com/aquaproj/aqua-registry/v4.62.0/registry.yaml",
"checksum": "F41BAE744B6D7833B84F4DB300A3E93C3BD74CA270EDB221BFBACAFF6A302B5796083C1969E42C72B4EF3D1BCA3719EF8C1570098E4F1E2F75E6228142A0690D",
"id": "registries/github_content/github.com/aquaproj/aqua-registry/v4.67.0/registry.yaml",
"checksum": "BEBC43E83EA2E7F5598EB6346E004EF7D586F40AFAB70C0FB659E2340472F5A2F6E0C2E7C4A44F1B08BC8F6F8236EDB5DCCBDFC8DFF4ED3235A095B03F4E9916",
"algorithm": "sha512"
}
]
Expand Down
2 changes: 1 addition & 1 deletion aqua/aqua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ checksum:
require_checksum: true
registries:
- type: standard
ref: v4.62.0 # renovate: depName=aquaproj/aqua-registry
ref: v4.67.0 # renovate: depName=aquaproj/aqua-registry
packages:
- import: imports/*.yaml
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ require (
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"volta": {
"node": "18.18.1"
"node": "18.18.2"
}
}
8 changes: 6 additions & 2 deletions pkg/asset/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/goccy/go-yaml/ast"
)

func UpdateASTFile(file *ast.File, pkgs interface{}) error {
func UpdateASTFile(file *ast.File, pkgs interface{}) error { //nolint:cyclop
node, err := yaml.ValueToNode(pkgs)
if err != nil {
return fmt.Errorf("convert packages to node: %w", err)
Expand All @@ -20,7 +20,11 @@ func UpdateASTFile(file *ast.File, pkgs interface{}) error {
continue
}
for _, mapValue := range body.Values {
if mapValue.Key.String() != "packages" {
key, ok := mapValue.Key.(*ast.StringNode)
if !ok {
continue
}
if key.Value != "packages" {
continue
}
switch mapValue.Value.Type() {
Expand Down
3 changes: 3 additions & 0 deletions pkg/cli/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func (r *Runner) setParam(c *cli.Context, commandName string, param *config.Para
param.GlobalConfigFilePaths = finder.ParseGlobalConfigFilePaths(os.Getenv("AQUA_GLOBAL_CONFIG"))
param.Deep = c.Bool("deep")
param.Pin = c.Bool("pin")
param.OnlyPackage = c.Bool("only-package")
param.OnlyRegistry = c.Bool("only-registry")
wd, err := os.Getwd()
if err != nil {
return fmt.Errorf("get the current directory: %w", err)
Expand Down Expand Up @@ -172,6 +174,7 @@ func (r *Runner) Run(ctx context.Context, args ...string) error {
r.newRootDirCommand(),
r.newUpdateChecksumCommand(),
r.newRemoveCommand(),
r.newUpdateCommand(),
},
}

Expand Down
124 changes: 124 additions & 0 deletions pkg/cli/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package cli

import (
"fmt"
"net/http"

"github.com/aquaproj/aqua/v2/pkg/config"
"github.com/aquaproj/aqua/v2/pkg/controller"
"github.com/urfave/cli/v2"
)

func (r *Runner) newUpdateCommand() *cli.Command {
return &cli.Command{
Name: "update",
Aliases: []string{"up"},
Usage: "Update registries and packages",
Description: updateDescription,
Action: r.updateAction,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "i",
Usage: `Select packages with fuzzy finder`,
},
&cli.BoolFlag{
Name: "select-version",
Aliases: []string{"s"},
Usage: `Select the version with fuzzy finder`,
},
&cli.BoolFlag{
Name: "only-registry",
Aliases: []string{"r"},
Usage: `Update only registries`,
},
&cli.BoolFlag{
Name: "only-package",
Aliases: []string{"p"},
Usage: `Update only packages`,
},
},
}
}

const updateDescription = `Update registries and packages.
If no argument is passed, all registries and packages are updated to the latest.
# Update all packages and registries to the latest versions
$ aqua update
This command has an alias "up"
$ aqua up
This command gets the latest version from GitHub Releases, GitHub Tags, and crates.io and updates aqua.yaml.
This command doesn't update commit hashes.
This command doesn't install packages.
This command updates only a nearest aqua.yaml from the current directory.
If this command finds a aqua.yaml, it ignores other aqua.yaml including global configuration files ($AQUA_GLOBAL_CONFIG).
So if you want to update other files, please change the current directory or specify the configuration file path with the option '-c'.
$ aqua -c foo/aqua.yaml update
If you want to update only registries, please use the --only-registry [-r] option.
# Update only registries
$ aqua update -r
If you want to update only packages, please use the --only-package [-p] option.
# Update only packages
$ aqua update -p
If you want to update only specific packages, please use the -i option.
You can select packages with the fuzzy finder.
If -i option is used, registries aren't updated.
# Select updated packages with fuzzy finder
$ aqua update -i
If you want to select versions, please use the --select-version [-s] option.
You can select versions with the fuzzy finder. You can not only update but also downgrade packages.
# Select updated packages and versions with fuzzy finder
$ aqua update -i -s
This command doesn't update packages if the field 'version' is used.
packages:
- name: cli/cli@v2.0.0 # Update
- name: gohugoio/hugo
version: v0.118.0 # Doesn't update
So if you don't want to update specific packages, the field 'version' is useful.
You can specify packages with command names. aqua finds packages that have these commands and updates them.
$ aqua update <command name> [<command name> ...]
e.g.
# Update cli/cli
$ aqua update gh
`

func (r *Runner) updateAction(c *cli.Context) error {
tracer, err := startTrace(c.String("trace"))
if err != nil {
return err
}
defer tracer.Stop()

cpuProfiler, err := startCPUProfile(c.String("cpu-profile"))
if err != nil {
return err
}
defer cpuProfiler.Stop()

param := &config.Param{}
if err := r.setParam(c, "update", param); err != nil {
return fmt.Errorf("parse the command line arguments: %w", err)
}
ctrl := controller.InitializeUpdateCommandController(c.Context, param, http.DefaultClient, r.Runtime)
return ctrl.Update(c.Context, r.LogE, param) //nolint:wrapcheck
}
5 changes: 4 additions & 1 deletion pkg/config-reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ func (r *ConfigReaderImpl) readImports(configFilePath string, cfg *aqua.Config)
if err := r.Read(filePath, subCfg); err != nil {
return err
}
pkgs = append(pkgs, subCfg.Packages...)
for _, pkg := range subCfg.Packages {
pkg.FilePath = filePath
pkgs = append(pkgs, pkg)
}
}
}
cfg.Packages = pkgs
Expand Down
1 change: 1 addition & 0 deletions pkg/config-reader/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ packages:
Name: "aquaproj/aqua-installer",
Registry: "standard",
Version: "v1.0.0",
FilePath: "/home/workspace/foo/aqua-installer.yaml",
},
},
},
Expand Down

0 comments on commit b223fae

Please sign in to comment.