Skip to content

Commit

Permalink
fix(update): read import recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Oct 15, 2023
1 parent bf33757 commit 8b81fe8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pkg/config-reader/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ func (r *ConfigReaderImpl) readImportsToUpdate(configFilePath string, cfg *aqua.
sort.Strings(filePaths)
for _, filePath := range filePaths {
subCfg := &aqua.Config{}
if err := r.Read(filePath, subCfg); err != nil {
subCfgs, err := r.ReadToUpdate(filePath, subCfg)
if err != nil {
return nil, err
}
subCfg.Registries = cfg.Registries
cfgs[filePath] = subCfg
for k, subCfg := range subCfgs {
cfgs[k] = subCfg
}
}
}
cfg.Packages = pkgs
Expand Down
4 changes: 2 additions & 2 deletions pkg/config-reader/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ packages:
t.Fatal("error must be returned")
}
if diff := cmp.Diff(d.cfg, cfg); diff != "" {
t.Fatal(diff)
t.Fatal("cfg:", diff)
}
if diff := cmp.Diff(d.cfgs, cfgs); diff != "" {
t.Fatal(diff)
t.Fatal("cfgs:", diff)
}
})
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/update/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func (c *Controller) updateRegistries(ctx context.Context, logE *logrus.Entry, c
for _, rgst := range cfg.Registries {
if commitHashPattern.MatchString(rgst.Ref) {
// Skip updating commit hashes
logE.WithFields(logrus.Fields{
"registry_name": rgst.Name,
"registry_version": rgst.Ref,
}).Debug("skip a registry whose version is a commit hash")
continue
}
newVersion, err := c.newRegistryVersion(ctx, logE, rgst)
Expand Down

0 comments on commit 8b81fe8

Please sign in to comment.