Skip to content

Commit

Permalink
Fix importpath backward incompatible change (#178)
Browse files Browse the repository at this point in the history
* Fix importpath backward incompatible change

 - importpath was changed to import_path in a recent change
   to receive argument from the cfn cli. This change breaks
   existing resources. Adding support for both "import_path" and "importpath"
  • Loading branch information
omkhegde authored Oct 22, 2020
1 parent 93e9ce5 commit a01aa55
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions python/rpdk/go/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def __init__(self):

def _prompt_for_go_path(self, project):
path_validator = validate_path("")
import_path = path_validator(project.settings.get("import_path"))
import_path = path_validator(
project.settings.get("import_path", project.settings.get("importpath"))
)

if not import_path:
prompt = "Enter the GO Import path"
Expand Down Expand Up @@ -88,7 +90,11 @@ 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["import_path"]))
contents = template.render(
path=Path(
project.settings.get("import_path", project.settings.get("importpath"))
)
)
project.safewrite(path, contents)

# CloudFormation/SAM template for handler lambda
Expand Down Expand Up @@ -169,7 +175,9 @@ 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["import_path"])
importpath = Path(
project.settings.get("import_path", project.settings.get("importpath"))
)
contents = template.render(path=(importpath / "cmd" / "resource").as_posix())
project.overwrite(path, contents)
format_paths.append(path)
Expand Down

0 comments on commit a01aa55

Please sign in to comment.