opsmill / infrahub

Infrahub - A new approach to Infrastructure Management
https://opsmill.com/
GNU Affero General Public License v3.0
212 stars 18 forks source link

task: Move strings referring to file system paths to `pathlib.Path` objects #3545

Open gmazoyer opened 6 months ago

gmazoyer commented 6 months ago

Component

API Server / GraphQL, Git Integration, Python SDK

Task Description

We use strings to refer to file system directories and files across the code base. These strings can be found in functions as well as in classes (data classes, Pydantic models, configurations), as properties. Some examples below:

class MainSettings(BaseSettings):
    model_config = SettingsConfigDict(env_prefix="INFRAHUB_")
    docs_index_path: str = Field(
        default="/opt/infrahub/docs/build/search-index.json",
        description="Full path of saved json containing pre-indexed documentation",
    )
class Worktree(BaseModel):
    identifier: str
    directory: str # Directory in the FS
    commit: str
    branch: Optional[str] = None

In an effort to consolidate the code base and make it consistent with using the pathlib module where appropriate, we should do the same for class properties referring to directories or files.

PhillSimonds commented 2 weeks ago

I'll take this

gmazoyer commented 2 weeks ago

Thanks. Do ont spend time on git related code though, there already is a PR for it https://github.com/opsmill/infrahub/pull/4857.

PhillSimonds commented 2 weeks ago

Ahh, OK cool, I'll move to a different section of the code :).