-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
10,955 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# AWS Simple EC2 CLI: Build Instructions | ||
|
||
## Install Go version 1.13+ | ||
|
||
There are several options for installing go: | ||
|
||
1. If you're on mac, you can simply `brew install go` | ||
2. If you'd like a flexible go installation manager consider using gvm https://github.com/moovweb/gvm | ||
3. For all other situations use the official go getting started guide: https://golang.org/doc/install | ||
|
||
## Build | ||
|
||
This project uses `make` to organize compilation, build, and test targets. | ||
|
||
To build cmd/main.go, which will build the full static binary and pull in depedent packages, run: | ||
``` | ||
$ make build | ||
``` | ||
|
||
The resulting binary will be in the generated `build/` dir | ||
|
||
``` | ||
$ make build | ||
$ ls build/ | ||
ez-ec2 | ||
``` | ||
|
||
## Test | ||
|
||
You can execute the unit tests for the instance selector with `make`: | ||
|
||
``` | ||
$ make unit-test | ||
``` | ||
|
||
### Run All Tests | ||
|
||
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: | ||
|
||
``` | ||
$ make test | ||
``` | ||
|
||
## Format | ||
|
||
To keep our code readable with go conventions, we use `goimports` to format the source code. | ||
Make sure to run `goimports` before you submit a PR or you'll be caught by our tests! | ||
|
||
You can use the `make fmt` target as a convenience | ||
``` | ||
$ make fmt | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Code of Conduct | ||
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). | ||
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact | ||
[email protected] with any additional questions or comments. | ||
[email protected] with any additional questions or comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package.Aws-simple-ec2-cli = { | ||
interfaces = (1.0); | ||
|
||
# Use NoOpBuild. See https://w.amazon.com/index.php/BrazilBuildSystem/NoOpBuild | ||
build-system = no-op; | ||
build-tools = { | ||
1.0 = { | ||
NoOpBuild = 1.0; | ||
}; | ||
}; | ||
|
||
# Use runtime-dependencies for when you want to bring in additional | ||
# packages when deploying. | ||
# Use dependencies instead if you intend for these dependencies to | ||
# be exported to other packages that build against you. | ||
dependencies = { | ||
1.0 = { | ||
}; | ||
}; | ||
|
||
runtime-dependencies = { | ||
1.0 = { | ||
}; | ||
}; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
MAKEFILE_PATH = $(dir $(realpath -s $(firstword $(MAKEFILE_LIST)))) | ||
PROJECT_IMPORT_DIR = ez-ec2 | ||
BUILD_DIR_PATH = ${MAKEFILE_PATH}/build | ||
CLI_BINARY_NAME = ez-ec2 | ||
|
||
# The main CloudFormation template for creating a new stack during launch | ||
EZEC2_CLOUDFORMATION_TEMPLATE_FILE=${MAKEFILE_PATH}/cloudformation_template.json | ||
EZEC2_CLOUDFORMATION_TEMPLATE_ENCODED=$(shell cat ${EZEC2_CLOUDFORMATION_TEMPLATE_FILE} | base64 | tr -d \\n) | ||
EZEC2_CLOUDFORMATION_TEMPLATE_VAR=${PROJECT_IMPORT_DIR}/pkg/cfn.Ezec2CloudformationTemplateEncoded | ||
|
||
# The CloudFormation template for e2e cfn test | ||
E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_FILE=${MAKEFILE_PATH}/test/e2e/e2e-cfn-test/cloudformation_template.json | ||
E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_ENCODED=$(shell cat ${E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_FILE} | base64 | tr -d \\n) | ||
E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_VAR=${PROJECT_IMPORT_DIR}/pkg/cfn.E2eCfnTestCloudformationTemplateEncoded | ||
|
||
# The CloudFormation template for e2e connect test | ||
E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_FILE=${MAKEFILE_PATH}/test/e2e/e2e-connect-test/cloudformation_template.json | ||
E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_ENCODED=$(shell cat ${E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_FILE} | base64 | tr -d \\n) | ||
E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_VAR=${PROJECT_IMPORT_DIR}/pkg/cfn.E2eConnectTestCloudformationTemplateEncoded | ||
|
||
# The CloudFormation template for e2e ec2helper test | ||
E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_FILE=${MAKEFILE_PATH}/test/e2e/e2e-ec2helper-test/cloudformation_template.json | ||
E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_ENCODED=$(shell cat ${E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_FILE} | base64 | tr -d \\n) | ||
E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_VAR=${PROJECT_IMPORT_DIR}/pkg/cfn.E2eEc2helperTestCloudformationTemplateEncoded | ||
|
||
EMBED_TEMPLATE_FLAG=-ldflags '-X "${EZEC2_CLOUDFORMATION_TEMPLATE_VAR}=${EZEC2_CLOUDFORMATION_TEMPLATE_ENCODED}"\ | ||
-X "${E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_VAR}=${E2E_CFN_TEST_CLOUDFORMATION_TEMPLATE_ENCODED}"\ | ||
-X "${E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_VAR}=${E2E_CONNECT_TEST_CLOUDFORMATION_TEMPLATE_ENCODED}"\ | ||
-X "${E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_VAR}=${E2E_EC2HELPER_TEST_CLOUDFORMATION_TEMPLATE_ENCODED}"' | ||
|
||
E2E_TEST_PACKAGES=ez-ec2/test/e2e/... | ||
|
||
GO_TEST=go test ${EMBED_TEMPLATE_FLAG} -bench=. ${MAKEFILE_PATH} | ||
DELETE_STACK=aws cloudformation delete-stack --stack-name | ||
|
||
$(shell mkdir -p ${BUILD_DIR_PATH} && touch ${BUILD_DIR_PATH}/_go.mod) | ||
|
||
clean: | ||
rm -rf ${BUILD_DIR_PATH}/ && go clean -testcache ./... | ||
|
||
compile: | ||
go build ${EMBED_TEMPLATE_FLAG} -o ${BUILD_DIR_PATH}/${CLI_BINARY_NAME} ${MAKEFILE_PATH}/main.go | ||
|
||
build: clean compile | ||
|
||
unit-test: | ||
${GO_TEST}/pkg/... -v -coverprofile=coverage.out -covermode=atomic -outputdir=${BUILD_DIR_PATH}; go tool cover -func ${BUILD_DIR_PATH}/coverage.out | ||
|
||
e2e-test: | ||
${GO_TEST}/test/e2e/... -v | ||
${DELETE_STACK}ez-ec2-e2e-cfn-test | ||
${DELETE_STACK}ez-ec2-e2e-connect-test | ||
${DELETE_STACK}ez-ec2-e2e-ec2helper-test | ||
|
||
e2e-cfn-test: | ||
${GO_TEST}/test/e2e/e2e-cfn-test/... -v | ||
${DELETE_STACK}ez-ec2-e2e-cfn-test | ||
|
||
e2e-connect-test: | ||
${GO_TEST}/test/e2e/e2e-connect-test/... -v | ||
${DELETE_STACK}ez-ec2-e2e-connect-test | ||
|
||
e2e-ec2helper-test: | ||
${GO_TEST}/test/e2e/e2e-ec2helper-test/... -v | ||
${DELETE_STACK}ez-ec2-e2e-ec2helper-test | ||
|
||
test: unit-test e2e-test |
Oops, something went wrong.