-
Notifications
You must be signed in to change notification settings - Fork 104
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
0 parents
commit 565d148
Showing
52 changed files
with
7,968 additions
and
0 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,2 @@ | ||
config/* | ||
build/* |
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,19 @@ | ||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
### Go Patch ### | ||
/vendor/ | ||
/Godeps/ | ||
/build/ | ||
/.terraform/ |
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,33 @@ | ||
--- | ||
language: minimal | ||
|
||
services: | ||
- docker | ||
|
||
matrix: | ||
include: | ||
- stage: Test | ||
language: go | ||
go: "1.14.x" | ||
script: make unit-test | ||
env: GO_UNIT_TESTS=TRUE | ||
after_success: bash <(curl -s https://codecov.io/bash) -v | ||
- stage: Test | ||
script: make go-report-card-test | ||
env: GO_REPORT_CARD=true | ||
- stage: Test | ||
script: make output-validation-test | ||
env: CFN_AND_TERRAFORM_OUTPUT_VALIDATION_TESTS=true | ||
- stage: Test | ||
if: type = push AND branch = master AND env(GITHUB_TOKEN) IS present | ||
script: test/license-test/run-license-test.sh | ||
env: LICENSE_TEST=true | ||
- stage: Deploy | ||
if: type = push AND env(DOCKER_USERNAME) IS present | ||
script: make sync-readme-to-dockerhub | ||
env: SYNC_README_TO_DOCKERHUB=true | ||
- stage: Deploy | ||
if: type = push AND tag =~ /^v\d+\.\d+(\.\d+)?(-\S*)?$/ AND env(DOCKER_USERNAME) IS present | ||
script: make release | ||
env: RELEASE_ASSETS=true | ||
|
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,106 @@ | ||
# Instance Selector: 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 | ||
|
||
## Compile | ||
|
||
This project uses `make` to organize compilation, build, and test targets. | ||
|
||
To compile cmd/main.go, which will build the full static binary and pull in depedent packages, run: | ||
``` | ||
$ make compile | ||
``` | ||
|
||
The resulting binary will be in the generated `build/` dir | ||
|
||
``` | ||
$ make compile | ||
/Users/$USER/git/amazon-ec2-instance-selector/ | ||
go build -a -ldflags "-X main.versionID=v0.9.0" -tags="aeislinux" -o /Users/$USER/git/amazon-ec2-instance-selector/build/ec2-instance-selector /Users/$USER/git/amazon-ec2-instance-selector/cmd/main.go | ||
$ ls build/ | ||
ec2-instance-selector | ||
``` | ||
|
||
## Test | ||
|
||
You can execute the unit tests for the instance selector with `make`: | ||
|
||
``` | ||
$ make unit-test | ||
``` | ||
|
||
### Install Docker | ||
|
||
The full test suite requires Docker to be installed. You can install docker from here: https://docs.docker.com/get-docker/ | ||
|
||
### Run All Tests | ||
|
||
The full suite includes license-test, go-report-card, and more. See the full list in the [makefile](https://github.com/aws/amazon-ec2-instance-selector/blob/master/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 | ||
``` | ||
|
||
## Generate all Platform Binaries | ||
|
||
To generate binaries for all supported platforms (linx/amd64, linux/arm64, windows/amd64, etc.) run: | ||
|
||
``` | ||
$ make build-binaries | ||
``` | ||
|
||
The binaries are built using a docker container and are then `cp`'d out of the container and placed in `build/bin` | ||
|
||
``` | ||
$ ls build/bin | ||
ec2-instance-selector-darwin-amd64 ec2-instance-selector-linux-amd64 ec2-instance-selector-linux-arm ec2-instance-selector-linux-arm64 ec2-instance-selector-windows-amd64 | ||
``` | ||
|
||
## See All Make Targets | ||
|
||
To see all possible make targets and dependent targets, run: | ||
|
||
``` | ||
$ make help | ||
build-binaries: create-build-dir | ||
build-docker-images: | ||
build: create-build-dir compile | ||
clean: | ||
compile: | ||
create-build-dir: | ||
docker-build: | ||
docker-push: | ||
docker-run: | ||
fmt: | ||
go-report-card-test: | ||
help: | ||
image: | ||
license-test: | ||
output-validation-test: create-build-dir | ||
push-docker-images: | ||
readme-codeblock-test: | ||
release: create-build-dir build-binaries build-docker-images push-docker-images upload-resources-to-github | ||
spellcheck: | ||
sync-readme-to-dockerhub: | ||
test: spellcheck unit-test license-test go-report-card-test output-validation-test readme-codeblock-test | ||
unit-test: create-build-dir | ||
upload-resources-to-github: | ||
version: | ||
``` |
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,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. |
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,61 @@ | ||
# Contributing Guidelines | ||
|
||
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional | ||
documentation, we greatly value feedback and contributions from our community. | ||
|
||
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary | ||
information to effectively respond to your bug report or contribution. | ||
|
||
|
||
## Reporting Bugs/Feature Requests | ||
|
||
We welcome you to use the GitHub issue tracker to report bugs or suggest features. | ||
|
||
When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already | ||
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: | ||
|
||
* A reproducible test case or series of steps | ||
* The version of our code being used | ||
* Any modifications you've made relevant to the bug | ||
* Anything unusual about your environment or deployment | ||
|
||
|
||
## Contributing via Pull Requests | ||
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: | ||
|
||
1. You are working against the latest source on the *master* branch. | ||
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. | ||
3. You open an issue to discuss any significant work - we would hate for your time to be wasted. | ||
|
||
To send us a pull request, please: | ||
|
||
1. Fork the repository. | ||
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. | ||
3. Ensure local tests pass. | ||
4. Commit to your fork using clear commit messages. | ||
5. Send us a pull request, answering any default questions in the pull request interface. | ||
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. | ||
|
||
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and | ||
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/). | ||
|
||
|
||
## Finding contributions to work on | ||
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. | ||
|
||
|
||
## 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. | ||
|
||
|
||
## Security issue notifications | ||
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. | ||
|
||
|
||
## Licensing | ||
|
||
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. | ||
|
||
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. |
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,32 @@ | ||
# Build the manager binary | ||
FROM golang:1.14 as builder | ||
|
||
## GOLANG env | ||
ARG GOPROXY="https://proxy.golang.org,direct" | ||
ARG GO111MODULE="on" | ||
ARG CGO_ENABLED=0 | ||
ARG GOOS=linux | ||
ARG GOARCH=amd64 | ||
|
||
# Copy go.mod and download dependencies | ||
WORKDIR /amazon-ec2-instance-selector | ||
COPY go.mod . | ||
COPY go.sum . | ||
RUN go mod download | ||
|
||
# Build | ||
COPY . . | ||
RUN make build | ||
# In case the target is build for testing: | ||
# $ docker build --target=builder -t test . | ||
CMD ["/amazon-ec2-instance-selector/build/ec2-instance-selector"] | ||
|
||
# Copy the binary into a thin image | ||
FROM amazonlinux:2 as amazonlinux | ||
FROM scratch | ||
WORKDIR / | ||
COPY --from=builder /amazon-ec2-instance-selector/build/ec2-instance-selector . | ||
COPY --from=amazonlinux /etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/ | ||
COPY THIRD_PARTY_LICENSES . | ||
USER 1000 | ||
ENTRYPOINT ["/ec2-instance-selector"] |
Oops, something went wrong.