Skip to content

Commit

Permalink
Merge pull request #16 from nytimes/go11
Browse files Browse the repository at this point in the history
Migrate to go 1.12 and clean up repo
  • Loading branch information
jimbydamonk authored Jun 19, 2019
2 parents 849ea1b + cf33356 commit fcc9277
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: go
go:
- 1.8.x
- 1.11.x
env:
- "PATH=/home/travis/gopath/bin:$PATH"
- "PATH=/home/travis/gopath/bin:$PATH" GO111MODULE=on
before_install:
- make deps
script:
Expand Down
1 change: 0 additions & 1 deletion Godeps

This file was deleted.

19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

# Program version
VERSION := $(shell grep "const Version " version.go | sed -E 's/.*"(.+)"$$/\1/')

INSTALL_PATH=$(GOPATH)/src/github.com/NYTimes/mock-ec2-metadata
GOPATH := $(shell go env GOPATH)

default: build

Expand All @@ -23,14 +22,18 @@ help:
@echo

deps:
go get github.com/mtibben/gogpm
go get github.com/tcnksm/ghr
go get github.com/mitchellh/gox
go get github.com/Sirupsen/logrus
$(GOPATH)/bin/gogpm install
@go get github.com/mitchellh/gox
@go get github.com/tcnksm/ghr
@go get -v .;
@go mod tidy;

# Runs the go vet command, will be a dependency for any test.
vet:
@go vet .
@go vet ./...

build:
$(GOPATH)/bin/gox -output "bin/{{.Dir}}_${VERSION}_{{.OS}}_{{.Arch}}" -os="linux" -os="darwin" -arch="386" -arch="amd64" ./
$(GOPATH)/bin/gox -verbose -output "bin/{{.Dir}}_${VERSION}_{{.OS}}_{{.Arch}}" -os="linux" -os="darwin" -arch="386" -arch="amd64" ./cmd/server

release:
$(GOPATH)/bin/ghr --username NYTimes --token ${GITHUB_TOKEN} -r mock-ec2-metadata --replace ${VERSION} bin/
Expand Down
6 changes: 3 additions & 3 deletions main.go → cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (

"github.com/NYTimes/gizmo/config"
"github.com/NYTimes/gizmo/server"
"github.com/NYTimes/mock-ec2-metadata/service"
metadata "github.com/NYTimes/mock-ec2-metadata"
)

func main() {
var cfg *service.Config
var cfg *metadata.Config

if _, err := os.Stat("./mock-ec2-metadata-config.json"); err == nil {
config.LoadJSONFile("./mock-ec2-metadata-config.json", &cfg)
Expand All @@ -20,7 +20,7 @@ func main() {
}

server.Init("mock-ec2-metadata", cfg.Server)
err := server.Register(service.NewMetadataService(cfg))
err := server.Register(metadata.NewMetadataService(cfg))
if err != nil {
server.Log.Fatal("unable to register service: ", err)
}
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/NYTimes/mock-ec2-metadata

go 1.12

require github.com/NYTimes/gizmo v1.2.8
232 changes: 232 additions & 0 deletions go.sum

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions service/service.go → service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package service
package metadata

import (
"encoding/json"
Expand All @@ -7,7 +7,6 @@ import (
"strings"

"github.com/NYTimes/gizmo/server"
"github.com/NYTimes/gizmo/web"
)

type (
Expand Down Expand Up @@ -138,7 +137,7 @@ func (s *MetadataService) GetSecurityGroups(w http.ResponseWriter, r *http.Reque
}

func (s *MetadataService) GetSecurityCredentialDetails(w http.ResponseWriter, r *http.Request) {
username := web.Vars(r)["username"]
username := server.Vars(r)["username"]

if username != s.config.MetadataValues.SecurityCredentials.User {
server.Log.Error("error, IAM user not found")
Expand Down
4 changes: 2 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package main
package metadata

// The git commit that was compiled. This will be filled in by the compiler.
var GitCommit string

// The main version number that is being run at the moment.
const Version = "0.3.1"
const Version = "0.4.0"

// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
Expand Down

0 comments on commit fcc9277

Please sign in to comment.