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

📦 Discover injectors through entrypoints #50

Open
wants to merge 2 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: 1 addition & 1 deletion dependencies/direct/py-constraints.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# #
###############################################################################

awx_plugins.interfaces @ git+https://github.com/ansible/awx_plugins.interfaces.git
awx_plugins.interfaces @ git+https://github.com/webknjaz/ansible--awx_plugins.interfaces.git@features/inventory-entry-points
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ thycotic_dsv = "awx_plugins.credentials.dsv:dsv_plugin"
thycotic_tss = "awx_plugins.credentials.tss:tss_plugin"
aws_secretsmanager_credential = "awx_plugins.credentials.aws_secretsmanager:aws_secretmanager_plugin"

[project.entry-points."awx_plugins.injector"]
aws = "awx_plugins.credential.injectors:aws"
azure_rm = "awx_plugins.credential.injectors:azure_rm"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
azure_rm = "awx_plugins.credential.injectors:azure_rm"
azure-rm = "awx_plugins.credential.injectors:azure_rm"

ec2 = "awx_plugins.credential.injectors:aws"
gce = "awx_plugins.credential.injectors:gce"
kubernetes_bearer_token = "awx_plugins.credential.injectors:kubernetes_bearer_token"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kubernetes_bearer_token = "awx_plugins.credential.injectors:kubernetes_bearer_token"
kubernetes-bearer-token = "awx_plugins.credential.injectors:kubernetes_bearer_token"

openstack = "awx_plugins.credential.injectors:openstack"
terraform = "awx_plugins.credential.injectors:terraform"
vmware = "awx_plugins.credential.injectors:vmware"

[project.entry-points."awx_plugins.inventory"] # new entry points group name
azure-rm = "awx_plugins.inventory.plugins:azure_rm"
ec2 = "awx_plugins.inventory.plugins:ec2"
Expand Down
20 changes: 12 additions & 8 deletions src/awx_plugins/inventory/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from awx_plugins.interfaces._temporary_private_container_api import ( # noqa: WPS436
get_incontainer_path,
)
from awx_plugins.interfaces._temporary_private_injector_api import ( # noqa: WPS436
load_injector_callable,
)

import yaml

Expand Down Expand Up @@ -102,15 +105,16 @@ def _get_shared_env(
inventory_update.pk,
), # so injector knows this is inventory
}

if self.base_injector == 'managed':
from awx_plugins.credentials import injectors as builtin_injectors

cred_kind = inventory_update.source.replace('ec2', 'aws')
if cred_kind in dir(builtin_injectors):
getattr(
builtin_injectors,
cred_kind,
)(
try:
inject_credential_into_env = load_injector_callable(
inventory_update.source,
)
except LookupError:
pass # noqa: WPS420
else:
inject_credential_into_env(
credential,
injected_env,
private_data_dir,
Expand Down
Loading