Skip to content

Commit

Permalink
Code review: Move AWS_META_ENDPOINT setting & update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
stuart-c committed Aug 7, 2017
1 parent b770275 commit 4d92a7a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 7 additions & 1 deletion aws/ec2meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"net/http"
"strings"
"time"

"github.com/hairyhenderson/gomplate/env"
)

// DefaultEndpoint -
const DefaultEndpoint = "http://169.254.169.254"
var DefaultEndpoint = "http://169.254.169.254"

// Ec2Meta -
type Ec2Meta struct {
Expand All @@ -23,6 +25,10 @@ type Ec2Meta struct {

// NewEc2Meta -
func NewEc2Meta(options ClientOptions) *Ec2Meta {
if endpoint := env.Getenv("AWS_META_ENDPOINT"); endpoint != "" {
DefaultEndpoint = endpoint
}

return &Ec2Meta{cache: make(map[string]string), options: options}
}

Expand Down
4 changes: 3 additions & 1 deletion test/integration/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:edge

ENV VAULT_VER 0.7.0
ENV VAULT_VER 0.7.3
ENV CONSUL_VER 0.9.0
RUN apk add --no-cache \
curl \
Expand All @@ -21,6 +21,8 @@ RUN mkdir /lib64 \

COPY gomplate /bin/gomplate
COPY mirror /bin/mirror
COPY meta /bin/meta
COPY aws /bin/aws
COPY *.sh /tests/
COPY *.bash /tests/
COPY *.bats /tests/
Expand Down
4 changes: 0 additions & 4 deletions vault/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ func (v *Vault) EC2Login() string {

meta := aws.NewEc2Meta(opts)

if endpoint := env.Getenv("AWS_META_ENDPOINT"); endpoint != "" {
meta.Endpoint = endpoint
}

vars["pkcs7"] = strings.Replace(strings.TrimSpace(meta.Dynamic("instance-identity/pkcs7")), "\n", "", -1)

if vars["pkcs7"] == "" {
Expand Down

0 comments on commit 4d92a7a

Please sign in to comment.