Skip to content

Commit

Permalink
Add omitempty for groups & build/SDK updates (#9)
Browse files Browse the repository at this point in the history
* allow groups to omitempty

* remove vendor

* fix build to show version

* Add entrypoint and change default command

* Update Dockerfile

* Update Dockerfile

* update client-go to 1.16.9

* update go version

* Update .travis.yml
  • Loading branch information
eytan-avisror authored May 10, 2020
1 parent fefe83e commit dcb7aa6
Show file tree
Hide file tree
Showing 1,844 changed files with 150 additions and 888,389 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go

go:
- 1.12.x
- 1.13.x

git:
depth: 1
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
FROM golang:1.12-alpine AS builder
FROM golang:1.13-alpine

RUN apk add --update \
python \
python-dev \
py-pip \
build-base \
git \
&& pip install awscli

WORKDIR /go/src/github.com/keikoproj/aws-auth
COPY . .
RUN git rev-parse HEAD
RUN date +%FT%T%z
RUN make build
RUN cp ./bin/aws-auth /bin/aws-auth \
&& chmod +x /bin/aws-auth
ENV HOME /root

CMD ["/bin/aws-auth"]
ENTRYPOINT ["/bin/aws-auth"]
CMD ["help"]
24 changes: 14 additions & 10 deletions cmd/cli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,30 @@ var (
// buildDate in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
//It should be set during build via -ldflags.
buildDate string
// version is the aws-auth package version
pkgVersion string = "0.1.2"
)

// Info holds the information related to descheduler app version.
type Info struct {
GitCommit string `json:"gitCommit"`
BuildDate string `json:"buildDate"`
GoVersion string `json:"goVersion"`
Compiler string `json:"compiler"`
Platform string `json:"platform"`
PackageVersion string `json:"pkgVersion"`
GitCommit string `json:"gitCommit"`
BuildDate string `json:"buildDate"`
GoVersion string `json:"goVersion"`
Compiler string `json:"compiler"`
Platform string `json:"platform"`
}

// Get returns the overall codebase version. It's for detecting
// what code a binary was built from.
func Get() Info {
return Info{
GitCommit: gitCommit,
BuildDate: buildDate,
GoVersion: runtime.Version(),
Compiler: runtime.Compiler,
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
GitCommit: gitCommit,
BuildDate: buildDate,
GoVersion: runtime.Version(),
Compiler: runtime.Compiler,
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
PackageVersion: pkgVersion,
}
}

Expand Down
24 changes: 5 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
module github.com/keikoproj/aws-auth

go 1.12
go 1.13

require (
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/json-iterator/go v1.1.7 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/onsi/gomega v1.6.0
github.com/pkg/errors v0.8.1 // indirect
github.com/spf13/cobra v0.0.5
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
google.golang.org/appengine v1.5.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/inf.v0 v0.9.0 // indirect
gopkg.in/yaml.v2 v2.2.2
k8s.io/api v0.0.0-20190313235455-40a48860b5ab
k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
k8s.io/client-go v11.0.0+incompatible
k8s.io/klog v0.4.0 // indirect
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf // indirect
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.16.9
k8s.io/apimachinery v0.16.9
k8s.io/client-go v0.16.9
k8s.io/utils v0.0.0-20190809000727-6c36bc71fc4a // indirect
)
103 changes: 89 additions & 14 deletions go.sum

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions pkg/mapper/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ func (args *UpsertArguments) Validate() {
log.Fatal("error: --userarn not provided")
}

if len(args.Groups) == 0 {
log.Fatal("error: --groups not provided")
}

if args.Username == "" {
log.Fatal("error: --username not provided")
}
Expand All @@ -130,7 +126,7 @@ func (args *UpsertArguments) Validate() {
type RolesAuthMap struct {
RoleARN string `yaml:"rolearn"`
Username string `yaml:"username"`
Groups []string `yaml:"groups"`
Groups []string `yaml:"groups,omitempty"`
}

func (r *RolesAuthMap) String() string {
Expand All @@ -148,7 +144,7 @@ func (r *RolesAuthMap) String() string {
type UsersAuthMap struct {
UserARN string `yaml:"userarn"`
Username string `yaml:"username"`
Groups []string `yaml:"groups"`
Groups []string `yaml:"groups,omitempty"`
}

func (r *UsersAuthMap) String() string {
Expand Down
33 changes: 33 additions & 0 deletions pkg/mapper/upsert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,36 @@ func TestMapper_UpsertMultipleWithCreate(t *testing.T) {
g.Expect(auth.MapUsers[0].Username).To(gomega.Equal("this:is:a:test"))
g.Expect(auth.MapUsers[0].Groups).To(gomega.Equal([]string{"system:some-role"}))
}

func TestMapper_UpsertEmptyGroups(t *testing.T) {
g := gomega.NewWithT(t)
gomega.RegisterTestingT(t)
client := fake.NewSimpleClientset()
mapper := New(client, true)

role1 := &RolesAuthMap{
RoleARN: "arn:aws:iam::00000000000:role/node-1",
Username: "this:is:a:test",
Groups: []string{},
}

mapUser1 := &UsersAuthMap{
UserARN: "arn:aws:iam::00000000000:user/user-1",
Username: "this:is:a:test",
Groups: []string{},
}

err := mapper.UpsertMultiple([]*RolesAuthMap{role1}, []*UsersAuthMap{mapUser1})
g.Expect(err).NotTo(gomega.HaveOccurred())

auth, _, err := ReadAuthMap(client)
g.Expect(err).NotTo(gomega.HaveOccurred())
g.Expect(len(auth.MapRoles)).To(gomega.Equal(1))
g.Expect(len(auth.MapUsers)).To(gomega.Equal(1))
g.Expect(auth.MapRoles[0].RoleARN).To(gomega.Equal("arn:aws:iam::00000000000:role/node-1"))
g.Expect(auth.MapRoles[0].Username).To(gomega.Equal("this:is:a:test"))
g.Expect(auth.MapRoles[0].Groups).To(gomega.BeNil())
g.Expect(auth.MapUsers[0].UserARN).To(gomega.Equal("arn:aws:iam::00000000000:user/user-1"))
g.Expect(auth.MapUsers[0].Username).To(gomega.Equal("this:is:a:test"))
g.Expect(auth.MapUsers[0].Groups).To(gomega.BeNil())
}
15 changes: 0 additions & 15 deletions vendor/github.com/davecgh/go-spew/LICENSE

This file was deleted.

145 changes: 0 additions & 145 deletions vendor/github.com/davecgh/go-spew/spew/bypass.go

This file was deleted.

38 changes: 0 additions & 38 deletions vendor/github.com/davecgh/go-spew/spew/bypasssafe.go

This file was deleted.

Loading

0 comments on commit dcb7aa6

Please sign in to comment.