Skip to content

Commit 074459b

Browse files
committed
Add project code
1 parent 890af79 commit 074459b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+10955
-12
lines changed

BUILD.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# AWS Simple EC2 CLI: Build Instructions
2+
3+
## Install Go version 1.13+
4+
5+
There are several options for installing go:
6+
7+
1. If you're on mac, you can simply `brew install go`
8+
2. If you'd like a flexible go installation manager consider using gvm https://github.com/moovweb/gvm
9+
3. For all other situations use the official go getting started guide: https://golang.org/doc/install
10+
11+
## Build
12+
13+
This project uses `make` to organize compilation, build, and test targets.
14+
15+
To build cmd/main.go, which will build the full static binary and pull in depedent packages, run:
16+
```
17+
$ make build
18+
```
19+
20+
The resulting binary will be in the generated `build/` dir
21+
22+
```
23+
$ make build
24+
25+
$ ls build/
26+
ez-ec2
27+
```
28+
29+
## Test
30+
31+
You can execute the unit tests for the instance selector with `make`:
32+
33+
```
34+
$ make unit-test
35+
```
36+
37+
### Run All Tests
38+
39+
The full suite includes license-test, go-report-card, and more. See the full list in the [makefile](./Makefile). NOTE: some tests require AWS Credentials to be configured on the system:
40+
41+
```
42+
$ make test
43+
```
44+
45+
## Format
46+
47+
To keep our code readable with go conventions, we use `goimports` to format the source code.
48+
Make sure to run `goimports` before you submit a PR or you'll be caught by our tests!
49+
50+
You can use the `make fmt` target as a convenience
51+
```
52+
$ make fmt
53+
```

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
## Code of Conduct
22
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
33
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4-
[email protected] with any additional questions or comments.
4+
[email protected] with any additional questions or comments.

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ If you discover a potential security issue in this project we ask that you notif
5858

5959
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
6060

61-
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
61+
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.

Config

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package.Aws-simple-ec2-cli = {
2+
interfaces = (1.0);
3+
4+
# Use NoOpBuild. See https://w.amazon.com/index.php/BrazilBuildSystem/NoOpBuild
5+
build-system = no-op;
6+
build-tools = {
7+
1.0 = {
8+
NoOpBuild = 1.0;
9+
};
10+
};
11+
12+
# Use runtime-dependencies for when you want to bring in additional
13+
# packages when deploying.
14+
# Use dependencies instead if you intend for these dependencies to
15+
# be exported to other packages that build against you.
16+
dependencies = {
17+
1.0 = {
18+
};
19+
};
20+
21+
runtime-dependencies = {
22+
1.0 = {
23+
};
24+
};
25+
26+
};

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,4 @@
172172
of any other Contributor, and only if You agree to indemnify,
173173
defend, and hold each Contributor harmless for any liability
174174
incurred by, or claims asserted against, such Contributor by reason
175-
of your accepting any such warranty or additional liability.
175+
of your accepting any such warranty or additional liability.

Makefile

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
MAKEFILE_PATH = $(dir $(realpath -s $(firstword $(MAKEFILE_LIST))))
2+
PROJECT_IMPORT_DIR = ez-ec2
3+
BUILD_DIR_PATH = ${MAKEFILE_PATH}/build
4+
CLI_BINARY_NAME = ez-ec2
5+
6+
# The main CloudFormation template for creating a new stack during launch
7+
EZEC2_CLOUDFORMATION_TEMPLATE_FILE=${MAKEFILE_PATH}/cloudformation_template.json
8+
EZEC2_CLOUDFORMATION_TEMPLATE_ENCODED=$(shell cat ${EZEC2_CLOUDFORMATION_TEMPLATE_FILE} | base64 | tr -d \\n)
9+
EZEC2_CLOUDFORMATION_TEMPLATE_VAR=${PROJECT_IMPORT_DIR}/pkg/cfn.Ezec2CloudformationTemplateEncoded
10+
11+
# The CloudFormation template for e2e cfn test
12+
E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_FILE=${MAKEFILE_PATH}/test/e2e/e2e-cfn-test/cloudformation_template.json
13+
E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_ENCODED=$(shell cat ${E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_FILE} | base64 | tr -d \\n)
14+
E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_VAR=${PROJECT_IMPORT_DIR}/pkg/cfn.E2eCfnTestCloudformationTemplateEncoded
15+
16+
# The CloudFormation template for e2e connect test
17+
E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_FILE=${MAKEFILE_PATH}/test/e2e/e2e-connect-test/cloudformation_template.json
18+
E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_ENCODED=$(shell cat ${E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_FILE} | base64 | tr -d \\n)
19+
E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_VAR=${PROJECT_IMPORT_DIR}/pkg/cfn.E2eConnectTestCloudformationTemplateEncoded
20+
21+
# The CloudFormation template for e2e ec2helper test
22+
E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_FILE=${MAKEFILE_PATH}/test/e2e/e2e-ec2helper-test/cloudformation_template.json
23+
E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_ENCODED=$(shell cat ${E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_FILE} | base64 | tr -d \\n)
24+
E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_VAR=${PROJECT_IMPORT_DIR}/pkg/cfn.E2eEc2helperTestCloudformationTemplateEncoded
25+
26+
EMBED_TEMPLATE_FLAG=-ldflags '-X "${EZEC2_CLOUDFORMATION_TEMPLATE_VAR}=${EZEC2_CLOUDFORMATION_TEMPLATE_ENCODED}"\
27+
-X "${E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_VAR}=${E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_ENCODED}"\
28+
-X "${E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_VAR}=${E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_ENCODED}"\
29+
-X "${E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_VAR}=${E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_ENCODED}"'
30+
31+
E2E_TEST_PACKAGES=ez-ec2/test/e2e/...
32+
33+
GO_TEST=go test ${EMBED_TEMPLATE_FLAG} -bench=. ${MAKEFILE_PATH}
34+
DELETE_STACK=aws cloudformation delete-stack --stack-name
35+
36+
$(shell mkdir -p ${BUILD_DIR_PATH} && touch ${BUILD_DIR_PATH}/_go.mod)
37+
38+
clean:
39+
rm -rf ${BUILD_DIR_PATH}/ && go clean -testcache ./...
40+
41+
compile:
42+
go build ${EMBED_TEMPLATE_FLAG} -o ${BUILD_DIR_PATH}/${CLI_BINARY_NAME} ${MAKEFILE_PATH}/main.go
43+
44+
build: clean compile
45+
46+
unit-test:
47+
${GO_TEST}/pkg/... -v -coverprofile=coverage.out -covermode=atomic -outputdir=${BUILD_DIR_PATH}; go tool cover -func ${BUILD_DIR_PATH}/coverage.out
48+
49+
e2e-test:
50+
${GO_TEST}/test/e2e/... -v
51+
${DELETE_STACK}ez-ec2-e2e-cfn-test
52+
${DELETE_STACK}ez-ec2-e2e-connect-test
53+
${DELETE_STACK}ez-ec2-e2e-ec2helper-test
54+
55+
e2e-cfn-test:
56+
${GO_TEST}/test/e2e/e2e-cfn-test/... -v
57+
${DELETE_STACK}ez-ec2-e2e-cfn-test
58+
59+
e2e-connect-test:
60+
${GO_TEST}/test/e2e/e2e-connect-test/... -v
61+
${DELETE_STACK}ez-ec2-e2e-connect-test
62+
63+
e2e-ec2helper-test:
64+
${GO_TEST}/test/e2e/e2e-ec2helper-test/... -v
65+
${DELETE_STACK}ez-ec2-e2e-ec2helper-test
66+
67+
test: unit-test e2e-test

0 commit comments

Comments
 (0)