Skip to content
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
18 changes: 11 additions & 7 deletions python/rpdk/go/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ def __init__(self):
)
self.env.filters["translate_type"] = translate_type
self.env.filters["safe_reserved"] = safe_reserved
self.namespace = None

def _prompt_for_go_path(self, project):
namespace = project.root
prompt = "Enter the GO Import path"
self.import_path = input_with_validation(prompt, validate_path(""))
project.settings["importpath"] = str(self.import_path)
path_validator = validate_path("")
import_path = path_validator(project.settings.get("import_path"))

if not import_path:
prompt = "Enter the GO Import path"
import_path = input_with_validation(prompt, path_validator)

self.import_path = import_path
project.settings["import_path"] = str(self.import_path)

def init(self, project):
LOG.debug("Init started")
Expand All @@ -77,7 +81,7 @@ def init(self, project):
path = project.root / "go.mod"
LOG.debug("Writing go.mod: %s", path)
template = self.env.get_template("go.mod.tple")
contents = template.render(path=Path(project.settings["importpath"]))
contents = template.render(path=Path(project.settings["import_path"]))
project.safewrite(path, contents)

# CloudFormation/SAM template for handler lambda
Expand Down Expand Up @@ -158,7 +162,7 @@ def generate(self, project):
path = root / "main.go"
LOG.debug("Writing project: %s", path)
template = self.env.get_template("main.go.tple")
importpath = Path(project.settings["importpath"])
importpath = Path(project.settings["import_path"])
contents = template.render(path=importpath / "cmd" / "resource")
project.overwrite(path, contents)
format_paths.append(path)
Expand Down
15 changes: 15 additions & 0 deletions python/rpdk/go/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def setup_subparser(subparsers, parents):
parser = subparsers.add_parser(
"go",
description="This sub command generates IDE and build files for Go",
parents=parents,
)
parser.set_defaults(language="go")

parser.add_argument(
"-p",
"--import-path",
help="Select the go language import path.",
)

return parser
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def find_version(*file_paths):
zip_safe=True,
install_requires=["cloudformation-cli>=0.1.2,<0.2", "semver>=2.9.0"],
python_requires=">=3.6",
entry_points={"rpdk.v1.languages": ["go = rpdk.go.codegen:GoLanguagePlugin"]},
entry_points={
"rpdk.v1.languages": ["go = rpdk.go.codegen:GoLanguagePlugin"],
"rpdk.v1.parsers": ["go = rpdk.go.parser:setup_subparser"],
},
license="Apache License 2.0",
classifiers=[
"Development Status :: 4 - Beta",
Expand Down