Skip to content

Commit

Permalink
fix: rename repository to registry
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Aug 28, 2021
1 parent 4d00dbe commit 172a591
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 44 deletions.
6 changes: 3 additions & 3 deletions aqua.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
packages:
- name: akoi
repository: inline
registry: inline
version: v2.2.1
- name: golangci
repository: inline
registry: inline
version: v1.42.0
inline_repository:
inline_registry:
- name: akoi
type: github_release
repo_owner: suzuki-shunsuke
Expand Down
12 changes: 6 additions & 6 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ If the confgiuration file path isn't specified, the file named `[.]aqua.y[a]ml`
## Configuration File Format

* `packages`: The list of installed packages
* `inline_repository`: The list of package metadata
* `inline_registry`: The list of package metadata

### type: Package

* `name`: the package name. This is used to map the package and the package metadata
`name` must be unique in the same [Repository](#repository)
* `repository`: the name of package metadata
`name` must be unique in the same [Registry](#registry)
* `registry`: the name of package metadata
* `version`: the package version

### type: PackageInfo
Expand All @@ -43,10 +43,10 @@ PackageInfo is the package metadata how the package is installed.
* `repo_name`: GitHub Repository name
* `asset`: (type: `template string`) GitHub Release asset name

### Repository
### Registry

`Repository` is the list of package metadata.
Only `inline` repository is supported.
`Registry` is the list of package metadata.
Only `inline` registry is supported.

### type: File

Expand Down
10 changes: 5 additions & 5 deletions pkg/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
)

type Config struct {
Packages []*Package `validate:"dive"`
InlineRepository []*PackageInfo `yaml:"inline_repository" validate:"dive"`
Packages []*Package `validate:"dive"`
InlineRegistry []*PackageInfo `yaml:"inline_registry" validate:"dive"`
}

type Package struct {
Name string `validate:"required"`
Repository string `validate:"required"`
Version string `validate:"required"`
Name string `validate:"required"`
Registry string `validate:"required"`
Version string `validate:"required"`
}

type PackageInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func (ctrl *Controller) download(ctx context.Context, pkg *Package, pkgInfo *Pac
logE := logrus.WithFields(logrus.Fields{
"package_name": pkg.Name,
"package_version": pkg.Version,
"repository": pkg.Repository,
"registry": pkg.Registry,
})
logE.Info("download and unarchive the package")

Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func (ctrl *Controller) Exec(ctx context.Context, param *Param, args []string) e
if err := ctrl.readConfig(param.ConfigFilePath, cfg); err != nil {
return err
}
inlineRepo := make(map[string]*PackageInfo, len(cfg.InlineRepository))
for _, pkgInfo := range cfg.InlineRepository {
inlineRepo[pkgInfo.Name] = pkgInfo
inlineRegistry := make(map[string]*PackageInfo, len(cfg.InlineRegistry))
for _, pkgInfo := range cfg.InlineRegistry {
inlineRegistry[pkgInfo.Name] = pkgInfo
}
fileSrc := ""
for _, pkg := range cfg.Packages {
pkgInfo, ok := inlineRepo[pkg.Name]
pkgInfo, ok := inlineRegistry[pkg.Name]
if !ok {
logrus.Warnf("repository isn't found %s", pkg.Name)
logrus.Warnf("registry isn't found %s", pkg.Name)
continue
}
for _, file := range pkgInfo.Files {
Expand Down Expand Up @@ -74,7 +74,7 @@ func (ctrl *Controller) Exec(ctx context.Context, param *Param, args []string) e
}

binDir := filepath.Join(filepath.Dir(param.ConfigFilePath), ".aqua", "bin")
if err := ctrl.installPackage(ctx, inlineRepo, pkg, binDir, false); err != nil {
if err := ctrl.installPackage(ctx, inlineRegistry, pkg, binDir, false); err != nil {
return err
}

Expand Down
20 changes: 10 additions & 10 deletions pkg/controller/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func (ctrl *Controller) Install(ctx context.Context, param *Param) error { //nol
if err := os.MkdirAll(binDir, 0o775); err != nil { //nolint:gomnd
return fmt.Errorf("create the directory: %w", err)
}
inlineRepo := make(map[string]*PackageInfo, len(cfg.InlineRepository))
for _, pkgInfo := range cfg.InlineRepository {
inlineRepo[pkgInfo.Name] = pkgInfo
inlineRegistry := make(map[string]*PackageInfo, len(cfg.InlineRegistry))
for _, pkgInfo := range cfg.InlineRegistry {
inlineRegistry[pkgInfo.Name] = pkgInfo
}

rootBin := filepath.Join(ctrl.RootDir, "bin")
Expand All @@ -60,7 +60,7 @@ func (ctrl *Controller) Install(ctx context.Context, param *Param) error { //nol
go func(pkg *Package) {
defer wg.Done()
maxInstallChan <- struct{}{}
if err := ctrl.installPackage(ctx, inlineRepo, pkg, binDir, param.OnlyLink); err != nil {
if err := ctrl.installPackage(ctx, inlineRegistry, pkg, binDir, param.OnlyLink); err != nil {
<-maxInstallChan
logrus.WithFields(logrus.Fields{
"package_name": pkg.Name,
Expand Down Expand Up @@ -102,19 +102,19 @@ func getMaxParallelism() int {
return num
}

func (ctrl *Controller) installPackage(ctx context.Context, inlineRepo map[string]*PackageInfo, pkg *Package, binDir string, onlyLink bool) error { //nolint:cyclop
func (ctrl *Controller) installPackage(ctx context.Context, inlineRegistry map[string]*PackageInfo, pkg *Package, binDir string, onlyLink bool) error { //nolint:cyclop
logE := logrus.WithFields(logrus.Fields{
"package_name": pkg.Name,
"package_version": pkg.Version,
"repository": pkg.Repository,
"registry": pkg.Registry,
})
logE.Debug("install the package")
if pkg.Repository != "inline" {
return fmt.Errorf("only inline repository is supported (%s)", pkg.Repository)
if pkg.Registry != "inline" {
return fmt.Errorf("only inline registry is supported (%s)", pkg.Registry)
}
pkgInfo, ok := inlineRepo[pkg.Name]
pkgInfo, ok := inlineRegistry[pkg.Name]
if !ok {
return fmt.Errorf("repository isn't found %s", pkg.Name)
return fmt.Errorf("registry isn't found %s", pkg.Name)
}

assetName, err := pkgInfo.RenderAsset(pkg)
Expand Down
9 changes: 4 additions & 5 deletions pkg/controller/install_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (

func (ctrl *Controller) installProxy(ctx context.Context) error {
pkg := &Package{
Name: "aqua-proxy",
Version: "v0.1.0-1",
Repository: "inline",
Name: "aqua-proxy",
Version: "v0.1.0-1",
Registry: "inline",
}
logE := logrus.WithFields(logrus.Fields{
"package_name": pkg.Name,
"package_version": pkg.Version,
"repository": pkg.Repository,
"registry": pkg.Registry,
})

logE.Debug("install the proxy")
Expand All @@ -39,7 +39,6 @@ func (ctrl *Controller) installProxy(ctx context.Context) error {
assetName := "aqua-proxy_" + runtime.GOOS + "_" + runtime.GOARCH + ".tar.gz"

pkgPath := getPkgPath(ctrl.RootDir, pkg, pkgInfo, assetName)
// check if the repository exists
logE.Debug("check if the package is already installed")
finfo, err := os.Stat(pkgPath)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ Please see `aqua.yaml`.
```yaml
packages:
- name: akoi
repository: inline
registry: inline
version: v2.2.0
inline_repository:
inline_registry:
- name: akoi
type: github_release
repo_owner: suzuki-shunsuke
Expand All @@ -60,9 +60,9 @@ Let's install tools with aqua.

```console
bash-5.1# aqua install
INFO[0000] download and unarchive the package package_name=aqua-proxy package_version=v0.1.0-0 repository=inline
INFO[0000] download and unarchive the package package_name=aqua-proxy package_version=v0.1.0-0 registry=inline
INFO[0001] create a symbolic link link_file=/workspace/.aqua/bin/akoi new=/root/.aqua/bin/aqua-proxy
INFO[0001] download and unarchive the package package_name=akoi package_version=v2.2.0 repository=inline
INFO[0001] download and unarchive the package package_name=akoi package_version=v2.2.0 registry=inline
```

In addition to akoi, [aqua-proxy](https://github.com/suzuki-shunsuke/aqua-proxy) is installed. aqua-proxy is required for aqua.
Expand Down Expand Up @@ -164,7 +164,7 @@ Run `aqua i` again, then akoi v2.2.1 is installed.

```console
bash-5.1# aqua i
INFO[0000] download and unarchive the package package_name=akoi package_version=v2.2.1 repository=inline
INFO[0000] download and unarchive the package package_name=akoi package_version=v2.2.1 registry=inline
```

```console
Expand Down Expand Up @@ -216,6 +216,6 @@ You don't have to run `aqua i` in advance.

```console
bash-5.1# akoi -v
INFO[0000] download and unarchive the package package_name=akoi package_version=v2.1.0 repository=inline
INFO[0000] download and unarchive the package package_name=akoi package_version=v2.1.0 registry=inline
akoi version 2.1.0
```
4 changes: 2 additions & 2 deletions tutorial/aqua.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
packages:
- name: akoi
repository: inline
registry: inline
version: v2.2.0
inline_repository:
inline_registry:
- name: akoi
type: github_release
repo_owner: suzuki-shunsuke
Expand Down

0 comments on commit 172a591

Please sign in to comment.