Skip to content

bug: Can't load folder that contains other type of file #462

Open
@BaptisteGi

Description

@BaptisteGi

Component

infrahubctl

Infrahub SDK version

1.13.3

Current Behavior

Assuming I have the following hierarchy:

└── vlan
    ├── README.md
    └── vlan.yml

Essentially a folder that contains my schema yaml file and a small md piece of documentation.

If I try to load this schema pointing to the folder I have the following output:

infrahubctl schema load vlan        

vlan/README.md does not exist!

Expected Behavior

I expect the command to ignore .md files (and everything which is not .yml)

Steps to Reproduce

  • Create a folder that contains both a .yml and a .md file
  • Try to schema load that folder

Additional Information

def load_from_disk(cls, paths: list[Path]) -> list[Self]:
yaml_files: list[Self] = []
for file_path in paths:
if file_path.is_file() and file_path.suffix in [".yaml", ".yml", ".json"]:
yaml_files.extend(cls.load_file_from_disk(path=file_path))
elif file_path.is_dir():
sub_paths = [Path(sub_file_path) for sub_file_path in file_path.glob("*")]
sub_files = cls.load_from_disk(paths=sub_paths)
sorted_sub_files = sorted(sub_files, key=lambda x: x.location)
yaml_files.extend(sorted_sub_files)
else:
raise FileNotValidError(name=str(file_path), message=f"{file_path} does not exist!")
return yaml_files

  • here having .json in a class that is called YAML tickles something
  • I believe we need to add an extra statement to differentiate user passes an invalid path from that path contains a file which is not a yaml file

Metadata

Metadata

Assignees

Labels

priority/2This issue stalls work on the project or its dependents, it's a blocker for a releasetype/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions