Skip to content

Commit

Permalink
fix(update): update imported packages
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Oct 14, 2023
1 parent ccdab87 commit 6a18c71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
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/aqua/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Package struct {
Tags []string `yaml:",omitempty" json:"tags,omitempty"`
Description string `yaml:",omitempty" json:"description,omitempty"`
Link string `yaml:",omitempty" json:"link,omitempty"`
FilePath string `json:"-" yaml:"-"`
}

func (p *Package) UnmarshalYAML(unmarshal func(interface{}) error) error {
Expand Down
6 changes: 5 additions & 1 deletion pkg/controller/update/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ func (c *Controller) updatePackages(ctx context.Context, logE *logrus.Entry, par
newVersions[fmt.Sprintf("%s,%s", pkg.Package.Registry, pkg.PackageInfo.GetName())] = newVersion
newVersions[fmt.Sprintf("%s,%s", pkg.Package.Registry, pkg.Package.Name)] = newVersion
}
if err := c.updateFile(logE, cfgFilePath, newVersions); err != nil {
filePath := cfgFilePath
if pkg.Package.FilePath != "" {
filePath = pkg.Package.FilePath
}
if err := c.updateFile(logE, filePath, newVersions); err != nil {
return fmt.Errorf("update a package: %w", err)
}
}
Expand Down

0 comments on commit 6a18c71

Please sign in to comment.