aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.61k stars 3.91k forks source link

cdk go template files break go commands #23222

Open natemarks opened 1 year ago

natemarks commented 1 year ago

Describe the bug

It's hard to use the CDK as a deployment tool in go projects because the node_modules/ directory contains go files with invalid names: node_modules/aws-cdk/lib/init-templates/app/go: invalid input file name "%name%.template.go" node_modules/aws-cdk/lib/init-templates/sample-app/go: invalid input file name "%name%.template.go"

These look like template files, so in don't think the names are important. If they had some extension other than '.go', they wouldn't interfere with go fmt, lint, test, etc.

Expected Behavior

go test -v ./... -tags unit ? github.com/gg-cloud/lambda-bootstrap-rds [no test files] === RUN TestGetLogger === RUN TestGetLogger/sdf {"level":"info","version":"my_version","message":"my_message"} --- PASS: TestGetLogger (0.00s) --- PASS: TestGetLogger/sdf (0.00s) PASS ok github.com/gg-cloud/lambda-bootstrap-rds/log (cached) === RUN TestGetDbConnection === RUN TestGetDbConnection/local-docker:valid_postgres_db --- PASS: TestGetDbConnection (0.00s) --- PASS: TestGetDbConnection/local-docker:valid_postgres_db (0.00s) PASS ok github.com/gg-cloud/lambda-bootstrap-rds/sql (cached)

Current Behavior

make unittest package github.com/gg-cloud/lambda-bootstrap-rds/node_modules/aws-cdk/lib/init-templates/app/go: invalid input file name "%name%.template.go" package github.com/gg-cloud/lambda-bootstrap-rds/node_modules/aws-cdk/lib/init-templates/sample-app/go: invalid input file name "%name%.template.go" go test -v -tags unit ? github.com/gg-cloud/lambda-bootstrap-rds [no test files]

Reproduction Steps

gofmt -w -s .

Possible Solution

rename those files from .go to .gotemplate

Additional Information/Context

No response

CDK CLI Version

2.52.0

Framework Version

2.52.0

Node.js Version

16

OS

linux

Language

Python

Language Version

3.10

Other information

No response

peterwoodworth commented 1 year ago

These files are named as such because when you run cdk init these files are going to be generated and become your project files. So I don't think we'll want to change these unless we convert the file type at some point.

I've done some work in CDK Go before, and haven't run into this issue when running tests. Could you post full reproduction steps from cdk init to when you run the test please?

natemarks commented 1 year ago

if you installed cdk with npm -g it's not in your project directory. that's the only way this could be easily avoided. If you install without the global option it ends up in your project and you can reproduce this every time.