Skip to content

Commit

Permalink
Switch to Go modules
Browse files Browse the repository at this point in the history
Signed-off-by: Mikkel Oscar Lyderik Larsen <m@moscar.net>
  • Loading branch information
mikkeloscar committed Aug 25, 2018
1 parent cf1b85e commit ef1a27c
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build/
vendor/

# ignored for now: https://github.com/golang/go/issues/25525
go.sum
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
language: go

go:
- 1.x
- "1.11"

before_install:
# - go get github.com/mattn/goveralls
- go get -u github.com/golang/dep/cmd/dep

install:
- dep ensure -v -vendor-only
env:
- GO111MODULE=on

script:
# - goveralls -service=travis-ci
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ default: build.local
clean:
rm -rf build

test:
test: go.mod
go test -v $(GOPKGS)

check:
check: go.mod
golint $(GOPKGS)
go vet -v $(GOPKGS)

build.local: build/$(BINARY)
build.linux: build/linux/$(BINARY)
build.osx: build/osx/$(BINARY)

build/$(BINARY): $(SOURCES)
build/$(BINARY): go.mod $(SOURCES)
CGO_ENABLED=0 go build -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .

build/linux/$(BINARY): $(SOURCES)
build/linux/$(BINARY): go.mod $(SOURCES)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/$(BINARY) -ldflags "$(LDFLAGS)" .

build/osx/$(BINARY): $(SOURCES)
build/osx/$(BINARY): go.mod $(SOURCES)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/osx/$(BINARY) -ldflags "$(LDFLAGS)" .

build.docker: build.linux
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,14 @@ continue to refresh the credentials automatically.

## Building

In order to build you first get the dependencies which are managed by
[dep](https://github.com/golang/dep):
This project uses [Go modules](https://github.com/golang/go/wiki/Modules) as
introduced in Go 1.11 therefore you need Go >=1.11 installed in order to build.
If using Go 1.11 you also need to [activate Module
support](https://github.com/golang/go/wiki/Modules#installing-and-activating-module-support).

```bash
$ go get -u github.com/golang/dep/cmd/dep
$ dep ensure -vendor-only # install all dependencies
```

After dependencies are installed the controller can be built simply by running:
Assuming Go has been setup with module support it can be built simply by running:

```bash
```sh
export GO111MODULE=on # needed if the project is checked out in your $GOPATH.
$ make
```
55 changes: 55 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module github.com/mikkeloscar/kube-aws-iam-controller

require (
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/aws/aws-sdk-go v1.15.21
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-ini/ini v1.33.0 // indirect
github.com/gogo/protobuf v1.0.0 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7 // indirect
github.com/golang/protobuf v1.0.0 // indirect
github.com/google/btree v0.0.0-20180124185431-e89373fe6b4a // indirect
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
github.com/googleapis/gnostic v0.1.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20180820052304-89baedc74dd7 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47 // indirect
github.com/hpcloud/tail v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 // indirect
github.com/json-iterator/go v0.0.0-20180315132816-ca39e5af3ece // indirect
github.com/jtolds/gls v4.2.1+incompatible // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v0.0.0-20180228065516-1df9eeb2bb81 // indirect
github.com/onsi/ginkgo v1.6.0 // indirect
github.com/onsi/gomega v1.4.1 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.0.5
github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf // indirect
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a // indirect
github.com/spf13/pflag v1.0.0 // indirect
github.com/stretchr/testify v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20180330210355-12892e8c234f // indirect
golang.org/x/net v0.0.0-20180330215511-b68f30494add // indirect
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect
golang.org/x/sys v0.0.0-20180329131831-378d26f46672 // indirect
golang.org/x/text v0.3.0 // indirect
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.38.2 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.2.1 // indirect
k8s.io/api v0.0.0-20180824172530-dd5c735cbff9
k8s.io/apimachinery v0.0.0-20180328184639-0ed326127d30
k8s.io/client-go v8.0.0+incompatible
)

replace github.com/aws/aws-sdk-go => github.com/mikkeloscar/aws-sdk-go v1.4.21-0.20180323205119-1290f149475c
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (

var (
config struct {
Debug bool
Interval time.Duration
RefreshLimit time.Duration
EventQueueSize int
Expand All @@ -31,6 +32,7 @@ var (
)

func main() {
kingpin.Flag("debug", "Enable debug logging.").BoolVar(&config.Debug)
kingpin.Flag("interval", "Interval between syncing secrets.").
Default(defaultInterval).DurationVar(&config.Interval)
kingpin.Flag("refresh-limit", "Time limit when AWS IAM credentials should be refreshed. I.e. 15 min. before they expire.").
Expand All @@ -42,6 +44,10 @@ func main() {
kingpin.Flag("apiserver", "API server url.").URLVar(&config.APIServer)
kingpin.Parse()

if config.Debug {
log.SetLevel(log.DebugLevel)
}

var kubeConfig *rest.Config

if config.APIServer != nil {
Expand Down

0 comments on commit ef1a27c

Please sign in to comment.