Skip to content

Add method to provide plugin information that is included in artifact zip #153

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

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions python/rpdk/python/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from rpdk.core.jsonutils.resolver import ContainerType, resolve_models
from rpdk.core.plugin_base import LanguagePlugin

from . import __version__
from .resolver import contains_model, translate_type

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -157,6 +158,10 @@ def generate(self, project):

LOG.debug("Generate complete")

# pylint: disable=unused-argument
def get_plugin_information(self, project):
return self._get_plugin_information()

def _pre_package(self, build_path):
f = TemporaryFile("w+b")

Expand Down Expand Up @@ -221,6 +226,10 @@ def _make_pip_command(base_path):
str(base_path / "build"),
]

@staticmethod
def _get_plugin_information():
return {"plugin-tool-version": __version__, "plugin-name": "python"}

@classmethod
def _docker_build(cls, external_path):
internal_path = PurePosixPath("/project")
Expand Down
8 changes: 8 additions & 0 deletions tests/plugin/codegen_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from requests.exceptions import ConnectionError as RequestsConnectionError
from rpdk.core.exceptions import DownstreamError
from rpdk.core.project import Project
from rpdk.python.__init__ import __version__
from rpdk.python.codegen import (
SUPPORT_LIB_NAME,
SUPPORT_LIB_PKG,
Expand Down Expand Up @@ -239,6 +240,13 @@ def test__docker_build_good_path(plugin, tmp_path):
)


def test_get_plugin_information(project):
plugin_information = project._plugin.get_plugin_information(project)

assert plugin_information["plugin-tool-version"] == __version__
assert plugin_information["plugin-name"] == "python"


@pytest.mark.parametrize(
"exception",
[
Expand Down