Skip to content

Commit 565d148

Browse files
committed
Initial commit
0 parents  commit 565d148

Some content is hidden

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

52 files changed

+7968
-0
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
config/*
2+
build/*

.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Go ###
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
# Test binary, built with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool, specifically when used with LiteIDE
13+
*.out
14+
15+
### Go Patch ###
16+
/vendor/
17+
/Godeps/
18+
/build/
19+
/.terraform/

.travis.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
language: minimal
3+
4+
services:
5+
- docker
6+
7+
matrix:
8+
include:
9+
- stage: Test
10+
language: go
11+
go: "1.14.x"
12+
script: make unit-test
13+
env: GO_UNIT_TESTS=TRUE
14+
after_success: bash <(curl -s https://codecov.io/bash) -v
15+
- stage: Test
16+
script: make go-report-card-test
17+
env: GO_REPORT_CARD=true
18+
- stage: Test
19+
script: make output-validation-test
20+
env: CFN_AND_TERRAFORM_OUTPUT_VALIDATION_TESTS=true
21+
- stage: Test
22+
if: type = push AND branch = master AND env(GITHUB_TOKEN) IS present
23+
script: test/license-test/run-license-test.sh
24+
env: LICENSE_TEST=true
25+
- stage: Deploy
26+
if: type = push AND env(DOCKER_USERNAME) IS present
27+
script: make sync-readme-to-dockerhub
28+
env: SYNC_README_TO_DOCKERHUB=true
29+
- stage: Deploy
30+
if: type = push AND tag =~ /^v\d+\.\d+(\.\d+)?(-\S*)?$/ AND env(DOCKER_USERNAME) IS present
31+
script: make release
32+
env: RELEASE_ASSETS=true
33+

BUILD.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Instance Selector: 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+
## Compile
12+
13+
This project uses `make` to organize compilation, build, and test targets.
14+
15+
To compile cmd/main.go, which will build the full static binary and pull in depedent packages, run:
16+
```
17+
$ make compile
18+
```
19+
20+
The resulting binary will be in the generated `build/` dir
21+
22+
```
23+
$ make compile
24+
/Users/$USER/git/amazon-ec2-instance-selector/
25+
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
26+
27+
$ ls build/
28+
ec2-instance-selector
29+
```
30+
31+
## Test
32+
33+
You can execute the unit tests for the instance selector with `make`:
34+
35+
```
36+
$ make unit-test
37+
```
38+
39+
### Install Docker
40+
41+
The full test suite requires Docker to be installed. You can install docker from here: https://docs.docker.com/get-docker/
42+
43+
### Run All Tests
44+
45+
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:
46+
47+
```
48+
$ make test
49+
```
50+
51+
## Format
52+
53+
To keep our code readable with go conventions, we use `goimports` to format the source code.
54+
Make sure to run `goimports` before you submit a PR or you'll be caught by our tests!
55+
56+
You can use the `make fmt` target as a convenience
57+
```
58+
$ make fmt
59+
```
60+
61+
## Generate all Platform Binaries
62+
63+
To generate binaries for all supported platforms (linx/amd64, linux/arm64, windows/amd64, etc.) run:
64+
65+
```
66+
$ make build-binaries
67+
```
68+
69+
The binaries are built using a docker container and are then `cp`'d out of the container and placed in `build/bin`
70+
71+
```
72+
$ ls build/bin
73+
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
74+
```
75+
76+
## See All Make Targets
77+
78+
To see all possible make targets and dependent targets, run:
79+
80+
```
81+
$ make help
82+
build-binaries: create-build-dir
83+
build-docker-images:
84+
build: create-build-dir compile
85+
clean:
86+
compile:
87+
create-build-dir:
88+
docker-build:
89+
docker-push:
90+
docker-run:
91+
fmt:
92+
go-report-card-test:
93+
help:
94+
image:
95+
license-test:
96+
output-validation-test: create-build-dir
97+
push-docker-images:
98+
readme-codeblock-test:
99+
release: create-build-dir build-binaries build-docker-images push-docker-images upload-resources-to-github
100+
spellcheck:
101+
sync-readme-to-dockerhub:
102+
test: spellcheck unit-test license-test go-report-card-test output-validation-test readme-codeblock-test
103+
unit-test: create-build-dir
104+
upload-resources-to-github:
105+
version:
106+
```

CODE_OF_CONDUCT.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Code of Conduct
2+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3+
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.

CONTRIBUTING.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Contributing Guidelines
2+
3+
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4+
documentation, we greatly value feedback and contributions from our community.
5+
6+
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7+
information to effectively respond to your bug report or contribution.
8+
9+
10+
## Reporting Bugs/Feature Requests
11+
12+
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13+
14+
When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15+
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16+
17+
* A reproducible test case or series of steps
18+
* The version of our code being used
19+
* Any modifications you've made relevant to the bug
20+
* Anything unusual about your environment or deployment
21+
22+
23+
## Contributing via Pull Requests
24+
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25+
26+
1. You are working against the latest source on the *master* branch.
27+
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28+
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29+
30+
To send us a pull request, please:
31+
32+
1. Fork the repository.
33+
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.
34+
3. Ensure local tests pass.
35+
4. Commit to your fork using clear commit messages.
36+
5. Send us a pull request, answering any default questions in the pull request interface.
37+
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38+
39+
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40+
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41+
42+
43+
## Finding contributions to work on
44+
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.
45+
46+
47+
## Code of Conduct
48+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50+
[email protected] with any additional questions or comments.
51+
52+
53+
## Security issue notifications
54+
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.
55+
56+
57+
## Licensing
58+
59+
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
60+
61+
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.

Dockerfile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Build the manager binary
2+
FROM golang:1.14 as builder
3+
4+
## GOLANG env
5+
ARG GOPROXY="https://proxy.golang.org,direct"
6+
ARG GO111MODULE="on"
7+
ARG CGO_ENABLED=0
8+
ARG GOOS=linux
9+
ARG GOARCH=amd64
10+
11+
# Copy go.mod and download dependencies
12+
WORKDIR /amazon-ec2-instance-selector
13+
COPY go.mod .
14+
COPY go.sum .
15+
RUN go mod download
16+
17+
# Build
18+
COPY . .
19+
RUN make build
20+
# In case the target is build for testing:
21+
# $ docker build --target=builder -t test .
22+
CMD ["/amazon-ec2-instance-selector/build/ec2-instance-selector"]
23+
24+
# Copy the binary into a thin image
25+
FROM amazonlinux:2 as amazonlinux
26+
FROM scratch
27+
WORKDIR /
28+
COPY --from=builder /amazon-ec2-instance-selector/build/ec2-instance-selector .
29+
COPY --from=amazonlinux /etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/
30+
COPY THIRD_PARTY_LICENSES .
31+
USER 1000
32+
ENTRYPOINT ["/ec2-instance-selector"]

0 commit comments

Comments
 (0)