Skip to content

Commit a01aa55

Browse files
authored
Fix importpath backward incompatible change (#178)
* 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"
1 parent 93e9ce5 commit a01aa55

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

python/rpdk/go/codegen.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def __init__(self):
4747

4848
def _prompt_for_go_path(self, project):
4949
path_validator = validate_path("")
50-
import_path = path_validator(project.settings.get("import_path"))
50+
import_path = path_validator(
51+
project.settings.get("import_path", project.settings.get("importpath"))
52+
)
5153

5254
if not import_path:
5355
prompt = "Enter the GO Import path"
@@ -88,7 +90,11 @@ def init(self, project):
8890
path = project.root / "go.mod"
8991
LOG.debug("Writing go.mod: %s", path)
9092
template = self.env.get_template("go.mod.tple")
91-
contents = template.render(path=Path(project.settings["import_path"]))
93+
contents = template.render(
94+
path=Path(
95+
project.settings.get("import_path", project.settings.get("importpath"))
96+
)
97+
)
9298
project.safewrite(path, contents)
9399

94100
# CloudFormation/SAM template for handler lambda
@@ -169,7 +175,9 @@ def generate(self, project):
169175
path = root / "main.go"
170176
LOG.debug("Writing project: %s", path)
171177
template = self.env.get_template("main.go.tple")
172-
importpath = Path(project.settings["import_path"])
178+
importpath = Path(
179+
project.settings.get("import_path", project.settings.get("importpath"))
180+
)
173181
contents = template.render(path=(importpath / "cmd" / "resource").as_posix())
174182
project.overwrite(path, contents)
175183
format_paths.append(path)

0 commit comments

Comments
 (0)