From eda64774d375cf73fc219937c4406df6fe13cfcf Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sat, 2 Nov 2024 11:44:08 +0900 Subject: [PATCH 1/8] feat: allow command aliases --- pkg/config/aqua/config.go | 29 +++++++++------ pkg/controller/which/which.go | 45 ++++++++++++++--------- pkg/installpackage/link.go | 69 ++++++++++++++++++++++++----------- 3 files changed, 94 insertions(+), 49 deletions(-) diff --git a/pkg/config/aqua/config.go b/pkg/config/aqua/config.go index b0be57e81..2de013d7e 100644 --- a/pkg/config/aqua/config.go +++ b/pkg/config/aqua/config.go @@ -7,17 +7,24 @@ import ( ) type Package struct { - Name string `validate:"required" json:"name,omitempty"` - Registry string `validate:"required" yaml:",omitempty" json:"registry,omitempty" jsonschema:"description=Registry name,example=foo,example=local,default=standard"` - Version string `validate:"required" yaml:",omitempty" json:"version,omitempty"` - Import string `yaml:",omitempty" json:"import,omitempty"` - Tags []string `yaml:",omitempty" json:"tags,omitempty"` - Description string `yaml:",omitempty" json:"description,omitempty"` - Link string `yaml:",omitempty" json:"link,omitempty"` - Update *Update `yaml:",omitempty" json:"update,omitempty"` - FilePath string `json:"-" yaml:"-"` - GoVersionFile string `json:"go_version_file,omitempty" yaml:"go_version_file,omitempty"` - Vars map[string]any `json:"vars,omitempty" yaml:",omitempty"` + Name string `validate:"required" json:"name,omitempty"` + Registry string `validate:"required" yaml:",omitempty" json:"registry,omitempty" jsonschema:"description=Registry name,example=foo,example=local,default=standard"` + Version string `validate:"required" yaml:",omitempty" json:"version,omitempty"` + Import string `yaml:",omitempty" json:"import,omitempty"` + Tags []string `yaml:",omitempty" json:"tags,omitempty"` + Description string `yaml:",omitempty" json:"description,omitempty"` + Link string `yaml:",omitempty" json:"link,omitempty"` + Update *Update `yaml:",omitempty" json:"update,omitempty"` + FilePath string `json:"-" yaml:"-"` + GoVersionFile string `json:"go_version_file,omitempty" yaml:"go_version_file,omitempty"` + Vars map[string]any `json:"vars,omitempty" yaml:",omitempty"` + CommandAliases []*CommandAlias `json:"command_aliases,omitempty" yaml:"command_aliases,omitempty"` +} + +type CommandAlias struct { + Command string `validate:"required" json:"command"` + Alias string `validate:"required" json:"alias"` + NoLink bool `yaml:"no_link,omitempty" json:"no_link,omitempty"` } type Update struct { diff --git a/pkg/controller/which/which.go b/pkg/controller/which/which.go index dd58ccbd6..08d8bbe28 100644 --- a/pkg/controller/which/which.go +++ b/pkg/controller/which/which.go @@ -157,25 +157,36 @@ func (c *Controller) findExecFileFromPkg(logE *logrus.Entry, registries map[stri } for _, file := range pkgInfo.GetFiles() { - if file.Name == exeName { - findResult := &FindResult{ - Package: &config.Package{ - Package: pkg, - PackageInfo: pkgInfo, - }, - File: file, + cmds := map[string]struct{}{} + for _, alias := range pkg.CommandAliases { + if file.Name != alias.Command { + continue } - if err := findResult.Package.ApplyVars(); err != nil { - return nil, fmt.Errorf("apply package variables: %w", err) - } - exePath, err := c.getExePath(findResult) - if err != nil { - logE.WithError(err).Error("get the execution file path") - return nil, nil //nolint:nilnil - } - findResult.ExePath = exePath - return findResult, nil + cmds[alias.Alias] = struct{}{} + } + if len(cmds) == 0 { + cmds[file.Name] = struct{}{} + } + if _, ok := cmds[exeName]; !ok { + continue + } + findResult := &FindResult{ + Package: &config.Package{ + Package: pkg, + PackageInfo: pkgInfo, + }, + File: file, + } + if err := findResult.Package.ApplyVars(); err != nil { + return nil, fmt.Errorf("apply package variables: %w", err) + } + exePath, err := c.getExePath(findResult) + if err != nil { + logE.WithError(err).Error("get the execution file path") + return nil, nil //nolint:nilnil } + findResult.ExePath = exePath + return findResult, nil } return nil, nil //nolint:nilnil } diff --git a/pkg/installpackage/link.go b/pkg/installpackage/link.go index 16c40f7ae..6fb3ee4ad 100644 --- a/pkg/installpackage/link.go +++ b/pkg/installpackage/link.go @@ -28,39 +28,66 @@ func (is *Installer) createLinks(logE *logrus.Entry, pkgs []*config.Package) boo for _, pkg := range pkgs { pkgInfo := pkg.PackageInfo + logE := logE.WithFields(logrus.Fields{ + "package_name": pkg.Package.Name, + "package_version": pkg.Package.Version, + }) for _, file := range pkgInfo.GetFiles() { - if is.realRuntime.IsWindows() { - hardLink := filepath.Join(is.rootDir, "bin", file.Name+".exe") - if f, err := afero.Exists(is.fs, hardLink); err != nil { - logerr.WithError(logE, err).WithFields(logrus.Fields{ - "command": file.Name, - }).Error("check if a hard link to aqua-proxy exists") - failed = true + logE := logE.WithFields(logrus.Fields{ + "command": file.Name, + }) + cmds := map[string]struct{}{} + for _, alias := range pkg.Package.CommandAliases { + if file.Name != alias.Command { + continue + } + if alias.NoLink { continue - } else if f { + } + cmds[alias.Alias] = struct{}{} + } + if len(cmds) == 0 { + cmds[file.Name] = struct{}{} + } + for cmd := range cmds { + logE := logE + if cmd != file.Name { + logE = logE.WithFields(logrus.Fields{ + "command_alias": cmd, + }) + } + if is.realRuntime.IsWindows() { + if err := is.createHardLink(logE, cmd, aquaProxyPathOnWindows); err != nil { + logerr.WithError(logE, err).Error("create a hard link to aqua-proxy") + failed = true + } continue } - logE.WithFields(logrus.Fields{ - "command": file.Name, - }).Info("creating a hard link to aqua-proxy") - if err := is.linker.Hardlink(aquaProxyPathOnWindows, hardLink); err != nil { - logerr.WithError(logE, err).WithFields(logrus.Fields{ - "command": file.Name, - }).Error("create a hard link to aqua-proxy") + if err := is.createLink(logE, filepath.Join(is.rootDir, "bin", cmd), filepath.Join("..", proxyName)); err != nil { + logerr.WithError(logE, err).Error("create the symbolic link") failed = true + continue } - continue - } - if err := is.createLink(logE, filepath.Join(is.rootDir, "bin", file.Name), filepath.Join("..", proxyName)); err != nil { - logerr.WithError(logE, err).Error("create the symbolic link") - failed = true - continue } } } return failed } +func (is *Installer) createHardLink(logE *logrus.Entry, cmd string, aquaProxyPathOnWindows string) error { + hardLink := filepath.Join(is.rootDir, "bin", cmd+".exe") + if f, err := afero.Exists(is.fs, hardLink); err != nil { + return fmt.Errorf("check if a hard link to aqua-proxy exists: %w", err) + } else if f { + return nil + } + logE.Info("creating a hard link to aqua-proxy") + if err := is.linker.Hardlink(aquaProxyPathOnWindows, hardLink); err != nil { + return fmt.Errorf("create a hard link to aqua-proxy: %w", err) + } + return nil +} + func (is *Installer) recreateHardLinks() error { binDir := filepath.Join(is.rootDir, "bin") infos, err := afero.ReadDir(is.fs, binDir) From 946db66b74be8f09bdc81c536cd17734df97a9f1 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sat, 2 Nov 2024 11:51:52 +0900 Subject: [PATCH 2/8] ci: add an integration test --- .github/workflows/wc-integration-test.yaml | 7 +++++++ tests/aliases/aqua.yaml | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/aliases/aqua.yaml diff --git a/.github/workflows/wc-integration-test.yaml b/.github/workflows/wc-integration-test.yaml index 94b4d8a2e..bdafdc887 100644 --- a/.github/workflows/wc-integration-test.yaml +++ b/.github/workflows/wc-integration-test.yaml @@ -39,6 +39,13 @@ jobs: run: aqua -c aqua.yaml g -i kubernetes-sigs/kustomize working-directory: tests/main + - name: Test command aliases + run: aqua i -l + working-directory: tests/aliases + - name: Test command aliases + run: terraform-013 version + working-directory: tests/aliases + - run: aqua list - run: aqua list -installed - run: aqua list -installed -a diff --git a/tests/aliases/aqua.yaml b/tests/aliases/aqua.yaml new file mode 100644 index 000000000..fe33acc0f --- /dev/null +++ b/tests/aliases/aqua.yaml @@ -0,0 +1,19 @@ +--- +# aqua - Declarative CLI Version Manager +# https://aquaproj.github.io/ +# checksum: +# enabled: true +# require_checksum: true +# supported_envs: +# - all +registries: +- type: standard + ref: v4.246.0 # renovate: depName=aquaproj/aqua-registry +packages: +- name: hashicorp/terraform@v1.9.8 +- name: hashicorp/terraform + version: v0.13.7 + command_aliases: + - command: terraform + alias: terraform-013 + # no_link: true From b29247ef8eb4925ac73720e3557087421c0985d2 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sat, 2 Nov 2024 12:03:05 +0900 Subject: [PATCH 3/8] refactor: split functions --- pkg/installpackage/link.go | 97 +++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 38 deletions(-) diff --git a/pkg/installpackage/link.go b/pkg/installpackage/link.go index 6fb3ee4ad..a3932c3d9 100644 --- a/pkg/installpackage/link.go +++ b/pkg/installpackage/link.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/aquaproj/aqua/v2/pkg/config" + "github.com/aquaproj/aqua/v2/pkg/config/registry" "github.com/sirupsen/logrus" "github.com/spf13/afero" "github.com/suzuki-shunsuke/logrus-error/logerr" @@ -27,53 +28,73 @@ func (is *Installer) createLinks(logE *logrus.Entry, pkgs []*config.Package) boo } for _, pkg := range pkgs { - pkgInfo := pkg.PackageInfo logE := logE.WithFields(logrus.Fields{ "package_name": pkg.Package.Name, "package_version": pkg.Package.Version, }) - for _, file := range pkgInfo.GetFiles() { - logE := logE.WithFields(logrus.Fields{ - "command": file.Name, - }) - cmds := map[string]struct{}{} - for _, alias := range pkg.Package.CommandAliases { - if file.Name != alias.Command { - continue - } - if alias.NoLink { - continue - } - cmds[alias.Alias] = struct{}{} - } - if len(cmds) == 0 { - cmds[file.Name] = struct{}{} - } - for cmd := range cmds { - logE := logE - if cmd != file.Name { - logE = logE.WithFields(logrus.Fields{ - "command_alias": cmd, - }) - } - if is.realRuntime.IsWindows() { - if err := is.createHardLink(logE, cmd, aquaProxyPathOnWindows); err != nil { - logerr.WithError(logE, err).Error("create a hard link to aqua-proxy") - failed = true - } - continue - } - if err := is.createLink(logE, filepath.Join(is.rootDir, "bin", cmd), filepath.Join("..", proxyName)); err != nil { - logerr.WithError(logE, err).Error("create the symbolic link") - failed = true - continue - } - } + if is.createPackageLinks(logE, pkg, aquaProxyPathOnWindows) { + failed = true + } + } + return failed +} + +func (is *Installer) createPackageLinks(logE *logrus.Entry, pkg *config.Package, aquaProxyPathOnWindows string) bool { + failed := false + pkgInfo := pkg.PackageInfo + for _, file := range pkgInfo.GetFiles() { + logE := logE.WithFields(logrus.Fields{ + "command": file.Name, + }) + if is.createFileLinks(logE, pkg, file, aquaProxyPathOnWindows) { + failed = true + } + } + return failed +} + +func (is *Installer) createFileLinks(logE *logrus.Entry, pkg *config.Package, file *registry.File, aquaProxyPathOnWindows string) bool { + failed := false + cmds := map[string]struct{}{} + for _, alias := range pkg.Package.CommandAliases { + if file.Name != alias.Command { + continue + } + if alias.NoLink { + continue + } + cmds[alias.Alias] = struct{}{} + } + if len(cmds) == 0 { + cmds[file.Name] = struct{}{} + } + for cmd := range cmds { + if err := is.createCmdLink(logE, file, cmd, aquaProxyPathOnWindows); err != nil { + logerr.WithError(logE, err).Error("create a link to aqua-proxy") + failed = true } } return failed } +func (is *Installer) createCmdLink(logE *logrus.Entry, file *registry.File, cmd string, aquaProxyPathOnWindows string) error { + if cmd != file.Name { + logE = logE.WithFields(logrus.Fields{ + "command_alias": cmd, + }) + } + if is.realRuntime.IsWindows() { + if err := is.createHardLink(logE, cmd, aquaProxyPathOnWindows); err != nil { + return fmt.Errorf("create a hard link to aqua-proxy: %w", err) + } + return nil + } + if err := is.createLink(logE, filepath.Join(is.rootDir, "bin", cmd), filepath.Join("..", proxyName)); err != nil { + return fmt.Errorf("create a symbolic link: %w", err) + } + return nil +} + func (is *Installer) createHardLink(logE *logrus.Entry, cmd string, aquaProxyPathOnWindows string) error { hardLink := filepath.Join(is.rootDir, "bin", cmd+".exe") if f, err := afero.Exists(is.fs, hardLink); err != nil { From 578c71aa77174b7c073f66b565466ba342554eda Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sat, 2 Nov 2024 12:21:55 +0900 Subject: [PATCH 4/8] refactor: split functions --- pkg/controller/which/which.go | 64 ++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/pkg/controller/which/which.go b/pkg/controller/which/which.go index 08d8bbe28..87f27962d 100644 --- a/pkg/controller/which/which.go +++ b/pkg/controller/which/which.go @@ -157,36 +157,46 @@ func (c *Controller) findExecFileFromPkg(logE *logrus.Entry, registries map[stri } for _, file := range pkgInfo.GetFiles() { - cmds := map[string]struct{}{} - for _, alias := range pkg.CommandAliases { - if file.Name != alias.Command { - continue - } - cmds[alias.Alias] = struct{}{} + findResult, err := c.findExecFileFromFile(logE, exeName, pkg, pkgInfo, file) + if err != nil { + return nil, err } - if len(cmds) == 0 { - cmds[file.Name] = struct{}{} + if findResult != nil { + return findResult, nil } - if _, ok := cmds[exeName]; !ok { + } + return nil, nil //nolint:nilnil +} + +func (c *Controller) findExecFileFromFile(logE *logrus.Entry, exeName string, pkg *aqua.Package, pkgInfo *registry.PackageInfo, file *registry.File) (*FindResult, error) { + cmds := map[string]struct{}{} + for _, alias := range pkg.CommandAliases { + if file.Name != alias.Command { continue } - findResult := &FindResult{ - Package: &config.Package{ - Package: pkg, - PackageInfo: pkgInfo, - }, - File: file, - } - if err := findResult.Package.ApplyVars(); err != nil { - return nil, fmt.Errorf("apply package variables: %w", err) - } - exePath, err := c.getExePath(findResult) - if err != nil { - logE.WithError(err).Error("get the execution file path") - return nil, nil //nolint:nilnil - } - findResult.ExePath = exePath - return findResult, nil + cmds[alias.Alias] = struct{}{} } - return nil, nil //nolint:nilnil + if len(cmds) == 0 { + cmds[file.Name] = struct{}{} + } + if _, ok := cmds[exeName]; !ok { + return nil, nil //nolint:nilnil + } + findResult := &FindResult{ + Package: &config.Package{ + Package: pkg, + PackageInfo: pkgInfo, + }, + File: file, + } + if err := findResult.Package.ApplyVars(); err != nil { + return nil, fmt.Errorf("apply package variables: %w", err) + } + exePath, err := c.getExePath(findResult) + if err != nil { + logE.WithError(err).Error("get the execution file path") + return nil, nil //nolint:nilnil + } + findResult.ExePath = exePath + return findResult, nil } From 494bacb44c572c2faa42a44ac59185b4b754f78c Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sat, 2 Nov 2024 12:25:11 +0900 Subject: [PATCH 5/8] docs: update JSON Schema --- json-schema/aqua-yaml.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/json-schema/aqua-yaml.json b/json-schema/aqua-yaml.json index 7145b0dc5..d05142f45 100644 --- a/json-schema/aqua-yaml.json +++ b/json-schema/aqua-yaml.json @@ -18,6 +18,25 @@ "additionalProperties": false, "type": "object" }, + "CommandAlias": { + "properties": { + "command": { + "type": "string" + }, + "alias": { + "type": "string" + }, + "no_link": { + "type": "boolean" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "command", + "alias" + ] + }, "Config": { "properties": { "packages": { @@ -80,6 +99,12 @@ }, "vars": { "type": "object" + }, + "command_aliases": { + "items": { + "$ref": "#/$defs/CommandAlias" + }, + "type": "array" } }, "additionalProperties": false, From 8bd9ff75d40c5aed78b658eaddf2e0f459d17667 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sat, 2 Nov 2024 12:29:07 +0900 Subject: [PATCH 6/8] fix: fix a log --- pkg/installpackage/link.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/installpackage/link.go b/pkg/installpackage/link.go index a3932c3d9..b3acbe7cd 100644 --- a/pkg/installpackage/link.go +++ b/pkg/installpackage/link.go @@ -164,9 +164,7 @@ func (is *Installer) createLink(logE *logrus.Entry, linkPath, linkDest string) e return fmt.Errorf("unexpected file mode %s: %s", linkPath, mode.String()) } } - logE.WithFields(logrus.Fields{ - "command": filepath.Base(linkPath), - }).Info("create a symbolic link") + logE.Info("create a symbolic link") if err := is.linker.Symlink(linkDest, linkPath); err != nil { return fmt.Errorf("create a symbolic link: %w", err) } From 632c0da6b507b51945aa3ea091ff4ffa525ed356 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sat, 2 Nov 2024 13:21:52 +0900 Subject: [PATCH 7/8] fix: fix cp command to support command aliases --- pkg/controller/cp/controller.go | 2 +- pkg/controller/cp/copy.go | 5 ++--- pkg/installpackage/check_file.go | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pkg/controller/cp/controller.go b/pkg/controller/cp/controller.go index c01ba993c..fd230dfd4 100644 --- a/pkg/controller/cp/controller.go +++ b/pkg/controller/cp/controller.go @@ -133,7 +133,7 @@ func (c *Controller) installAndCopy(ctx context.Context, logE *logrus.Entry, par } } - if err := c.copy(logE, param, findResult, exeName); err != nil { + if err := c.copy(logE, param, findResult.ExePath, exeName); err != nil { return err } return nil diff --git a/pkg/controller/cp/copy.go b/pkg/controller/cp/copy.go index 4654af9f6..d9bf90ab1 100644 --- a/pkg/controller/cp/copy.go +++ b/pkg/controller/cp/copy.go @@ -5,11 +5,10 @@ import ( "path/filepath" "github.com/aquaproj/aqua/v2/pkg/config" - "github.com/aquaproj/aqua/v2/pkg/controller/which" "github.com/sirupsen/logrus" ) -func (c *Controller) copy(logE *logrus.Entry, param *config.Param, findResult *which.FindResult, exeName string) error { +func (c *Controller) copy(logE *logrus.Entry, param *config.Param, exePath string, exeName string) error { p := filepath.Join(param.Dest, exeName) if c.runtime.GOOS == "windows" && filepath.Ext(exeName) == "" { p += ".exe" @@ -18,7 +17,7 @@ func (c *Controller) copy(logE *logrus.Entry, param *config.Param, findResult *w "exe_name": exeName, "dest": p, }).Info("coping a file") - if err := c.packageInstaller.Copy(p, findResult.ExePath); err != nil { + if err := c.packageInstaller.Copy(p, exePath); err != nil { return fmt.Errorf("copy a file: %w", err) } return nil diff --git a/pkg/installpackage/check_file.go b/pkg/installpackage/check_file.go index 70868fc68..0c887a66d 100644 --- a/pkg/installpackage/check_file.go +++ b/pkg/installpackage/check_file.go @@ -59,10 +59,20 @@ func (is *Installer) checkAndCopyFile(ctx context.Context, logE *logrus.Entry, p return nil } logE.Info("copying an executable file") - if err := is.Copy(filepath.Join(is.copyDir, file.Name), exePath); err != nil { - return err + exeNames := map[string]struct{}{} + for _, alias := range pkg.Package.CommandAliases { + if alias.Command == file.Name { + exeNames[alias.Alias] = struct{}{} + } + } + if len(exeNames) == 0 { + exeNames[file.Name] = struct{}{} + } + for exeName := range exeNames { + if err := is.Copy(filepath.Join(is.copyDir, exeName), exePath); err != nil { + return err + } } - return nil } From a7d6090084d94a291ed438c969293feb7c3df6e9 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sat, 2 Nov 2024 13:34:36 +0900 Subject: [PATCH 8/8] fix: create links using original command names --- pkg/controller/which/which.go | 7 +++---- pkg/installpackage/check_file.go | 7 +++---- pkg/installpackage/link.go | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/controller/which/which.go b/pkg/controller/which/which.go index 87f27962d..013f03fa8 100644 --- a/pkg/controller/which/which.go +++ b/pkg/controller/which/which.go @@ -169,16 +169,15 @@ func (c *Controller) findExecFileFromPkg(logE *logrus.Entry, registries map[stri } func (c *Controller) findExecFileFromFile(logE *logrus.Entry, exeName string, pkg *aqua.Package, pkgInfo *registry.PackageInfo, file *registry.File) (*FindResult, error) { - cmds := map[string]struct{}{} + cmds := map[string]struct{}{ + file.Name: {}, + } for _, alias := range pkg.CommandAliases { if file.Name != alias.Command { continue } cmds[alias.Alias] = struct{}{} } - if len(cmds) == 0 { - cmds[file.Name] = struct{}{} - } if _, ok := cmds[exeName]; !ok { return nil, nil //nolint:nilnil } diff --git a/pkg/installpackage/check_file.go b/pkg/installpackage/check_file.go index 0c887a66d..19afec278 100644 --- a/pkg/installpackage/check_file.go +++ b/pkg/installpackage/check_file.go @@ -59,15 +59,14 @@ func (is *Installer) checkAndCopyFile(ctx context.Context, logE *logrus.Entry, p return nil } logE.Info("copying an executable file") - exeNames := map[string]struct{}{} + exeNames := map[string]struct{}{ + file.Name: {}, + } for _, alias := range pkg.Package.CommandAliases { if alias.Command == file.Name { exeNames[alias.Alias] = struct{}{} } } - if len(exeNames) == 0 { - exeNames[file.Name] = struct{}{} - } for exeName := range exeNames { if err := is.Copy(filepath.Join(is.copyDir, exeName), exePath); err != nil { return err diff --git a/pkg/installpackage/link.go b/pkg/installpackage/link.go index b3acbe7cd..b3a7be76e 100644 --- a/pkg/installpackage/link.go +++ b/pkg/installpackage/link.go @@ -55,7 +55,9 @@ func (is *Installer) createPackageLinks(logE *logrus.Entry, pkg *config.Package, func (is *Installer) createFileLinks(logE *logrus.Entry, pkg *config.Package, file *registry.File, aquaProxyPathOnWindows string) bool { failed := false - cmds := map[string]struct{}{} + cmds := map[string]struct{}{ + file.Name: {}, + } for _, alias := range pkg.Package.CommandAliases { if file.Name != alias.Command { continue @@ -65,9 +67,6 @@ func (is *Installer) createFileLinks(logE *logrus.Entry, pkg *config.Package, fi } cmds[alias.Alias] = struct{}{} } - if len(cmds) == 0 { - cmds[file.Name] = struct{}{} - } for cmd := range cmds { if err := is.createCmdLink(logE, file, cmd, aquaProxyPathOnWindows); err != nil { logerr.WithError(logE, err).Error("create a link to aqua-proxy")