-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
13 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import TYPE_CHECKING | ||
|
||
from infrahub.database import get_db | ||
|
||
if TYPE_CHECKING: | ||
from infrahub.database import InfrahubDatabase | ||
from infrahub.database import InfrahubDatabase, get_db | ||
|
||
|
||
@dataclass | ||
class CliContext: | ||
database_class: type[InfrahubDatabase] | ||
application: str = "infrahub.server:app" | ||
|
||
async def get_db(self, retry: int = 0) -> InfrahubDatabase: | ||
return self.database_class(driver=await get_db(retry=retry)) | ||
# This method is inherited for Infrahub Enterprise. | ||
@staticmethod | ||
async def init_db(retry: int) -> InfrahubDatabase: | ||
return InfrahubDatabase(driver=await get_db(retry=retry)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters