Skip to content

Commit e12cc84

Browse files
authored
Merge pull request #478 from opsmill/ajtm-07222025-respect-file-order
respect ordering of files when loading
2 parents ef7fc07 + d227402 commit e12cc84

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

infrahub_sdk/yaml.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ def load_from_disk(cls, paths: list[Path]) -> list[Self]:
122122
yaml_files: list[Self] = []
123123
file_extensions = {".yaml", ".yml", ".json"} # FIXME: .json is not a YAML file, should be removed
124124

125-
paths = sorted(paths, key=lambda p: p.name) # Ensure order when processing paths
126-
127125
for file_path in paths:
128126
if not file_path.exists():
129127
# Check if the provided path exists, relevant for the first call coming from the user
@@ -135,6 +133,7 @@ def load_from_disk(cls, paths: list[Path]) -> list[Self]:
135133
elif file_path.is_dir():
136134
# Introduce recursion to handle sub-folders
137135
sub_paths = [Path(sub_file_path) for sub_file_path in file_path.glob("*")]
136+
sub_paths = sorted(sub_paths, key=lambda p: p.name)
138137
yaml_files.extend(cls.load_from_disk(paths=sub_paths))
139138
# else: skip non-file, non-dir (e.g., symlink...)
140139

0 commit comments

Comments
 (0)