Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stable with latest PRs from opsmill/infrahub #5

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions infrahub_sdk/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,11 @@ def get_human_friendly_id(self) -> Optional[list[str]]:
if not self._schema.human_friendly_id:
return None

# If all components of an HFID are null, we cannot identify a single node
# If an HFID component is missing we assume that it is invalid and not usable for this node
hfid_components = [self.get_path_value(path=item) for item in self._schema.human_friendly_id]
if all(c is None for c in hfid_components):
if None in hfid_components:
return None

return [str(c) for c in hfid_components]
return [str(hfid) for hfid in hfid_components]

def get_human_friendly_id_as_string(self, include_kind: bool = False) -> Optional[str]:
hfid = self.get_human_friendly_id()
Expand Down
11 changes: 6 additions & 5 deletions infrahub_sdk/pytest_plugin/plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path
from typing import Optional, Union

Expand Down Expand Up @@ -34,6 +35,7 @@ def pytest_addoption(parser: Parser) -> None:
action="store",
dest="infrahub_key",
metavar="INFRAHUB_TESTS_API_KEY",
default=os.getenv("INFRAHUB_API_TOKEN"),
help="Key to use when querying the Infrahub instance for live testing",
)
group.addoption(
Expand Down Expand Up @@ -74,12 +76,11 @@ def pytest_sessionstart(session: Session) -> None:
"default_branch": session.config.option.infrahub_branch,
}
if hasattr(session.config.option, "infrahub_key"):
client_config = {"api_token": session.config.option.infrahub_key}
client_config["api_token"] = session.config.option.infrahub_key
elif hasattr(session.config.option, "infrahub_username") and hasattr(session.config.option, "infrahub_password"):
client_config = {
"username": session.config.option.infrahub_username,
"password": session.config.option.infrahub_password,
}
client_config.pop("api_token")
client_config["username"] = session.config.option.infrahub_username
client_config["password"] = session.config.option.infrahub_password

infrahub_client = InfrahubClientSync(config=client_config)
session.infrahub_client = infrahub_client # type: ignore[attr-defined]
Expand Down