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

Issue #1300 - nb_inventory injecting a variable as api_endpoint #1301

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions changelogs/fragments/fix_issue_1300.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Allows templating of api_endpoint in nb_inventory plugin
4 changes: 3 additions & 1 deletion plugins/inventory/nb_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,9 @@ def fetch_api_docs(self):
except Exception:
cached_api_version = None
cache = None

self.api_endpoint = self.templar.template(
self.get_option("api_endpoint"), fail_on_undefined=False
)
status = self._fetch_information(self.api_endpoint + "/api/status")
netbox_api_version = ".".join(status["netbox-version"].split(".")[:2])

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/inventory/test_nb_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def test_get_resource_list_chunked(
"/fake/path/asdasd3456",
)
@pytest.mark.parametrize("netbox_ver", ["2.0.2", "3.0.0"])
def test_fetch_api_docs(inventory_fixture, netbox_ver):
def test_fetch_api_docs(inventory_fixture, netbox_ver, templar_fixture):
mock_fetch_information = Mock()
mock_fetch_information.side_effect = [
{"netbox-version": netbox_ver},
Expand Down
Loading