Skip to content

Commit 1c0ef79

Browse files
fix(network): stop loading other yamls in .config on the same level (#686)
There is a bug where loading the network configs will load other yamls under `.config/XXX` instead of just `.config/networks`. There are already tests that checks reading from `.config/networks`.
1 parent 4f51470 commit 1c0ef79

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.changeset/fuzzy-mice-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"chainlink-deployments-framework": patch
3+
---
4+
5+
fix(network): stop loading all yamls in .config

engine/cld/config/networks.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,31 @@ func LoadNetworks(
3939
return cfg.FilterWith(cfgnet.TypesFilter(networkTypes...)), nil
4040
}
4141

42-
// loadNetworkConfig loads the network config from the .config directory in the given fdomain.
42+
// loadNetworkConfig loads the network config from the .config/networks directory in the given fdomain.
4343
func loadNetworkConfig(domain fdomain.Domain) (*cfgnet.Config, error) {
44-
// Check if the .config directory exists in the domain
45-
configDir := filepath.Join(domain.DirPath(), ".config")
46-
if _, err := os.Stat(configDir); err != nil {
44+
// Check if the .config/networks directory exists in the domain
45+
configNetworkDir := domain.ConfigNetworksDirPath()
46+
if _, err := os.Stat(configNetworkDir); err != nil {
4747
return nil, fmt.Errorf("cannot find config directory: %w", err)
4848
}
4949

50-
// Find all yaml config files in the .config directory and any subdirectories
50+
// Find all yaml config files in the .config/networks directory
5151
var configFiles []string
5252

53-
yamlFiles, err := filepath.Glob(filepath.Join(configDir, "**", "*.yaml"))
53+
yamlFiles, err := filepath.Glob(filepath.Join(configNetworkDir, "*.yaml"))
5454
if err != nil {
5555
return nil, fmt.Errorf("failed to find config files: %w", err)
5656
}
5757
configFiles = append(configFiles, yamlFiles...)
5858

59-
ymlFiles, err := filepath.Glob(filepath.Join(configDir, "**", "*.yml"))
59+
ymlFiles, err := filepath.Glob(filepath.Join(configNetworkDir, "*.yml"))
6060
if err != nil {
6161
return nil, fmt.Errorf("failed to find config files: %w", err)
6262
}
6363
configFiles = append(configFiles, ymlFiles...)
6464

6565
if len(configFiles) == 0 {
66-
return nil, fmt.Errorf("no config files found in %s", configDir)
66+
return nil, fmt.Errorf("no config files found in %s", configNetworkDir)
6767
}
6868

6969
cfg, err := cfgnet.Load(configFiles)

0 commit comments

Comments
 (0)