Skip to content

Commit

Permalink
Last minute changes
Browse files Browse the repository at this point in the history
  • Loading branch information
williamleven committed Mar 21, 2018
1 parent d8cb093 commit 33d8e05
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
13 changes: 9 additions & 4 deletions admin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/cthit/goldapps"
"golang.org/x/net/context"
"golang.org/x/oauth2/google"
"time"
"strings"
)

type googleService struct {
Expand Down Expand Up @@ -60,14 +62,15 @@ func (s googleService) UpdateGroup(groupUpdate goldapps.GroupUpdate) error {
for _, member := range groupUpdate.After.Members {
exists := false
for _, existingMember := range groupUpdate.Before.Members {
if member == existingMember {
if strings.ToLower(member) == strings.ToLower(existingMember) {
exists = true
break
}
}
if !exists {
err := s.addMember(groupUpdate.Before.Email, member)
if err != nil {
fmt.Printf("Failed to add menber %s\n",member)
return err
}
}
Expand All @@ -77,7 +80,7 @@ func (s googleService) UpdateGroup(groupUpdate goldapps.GroupUpdate) error {
for _, existingMember := range groupUpdate.Before.Members {
keep := false
for _, member := range groupUpdate.After.Members {
if existingMember == member {
if strings.ToLower(existingMember) == strings.ToLower(member) {
keep = true
break
}
Expand All @@ -94,7 +97,7 @@ func (s googleService) UpdateGroup(groupUpdate goldapps.GroupUpdate) error {
for _, alias := range groupUpdate.After.Aliases {
exists := false
for _, existingAlias := range groupUpdate.Before.Aliases {
if alias == existingAlias {
if strings.ToLower(alias) == strings.ToLower(existingAlias) {
exists = true
break
}
Expand All @@ -111,7 +114,7 @@ func (s googleService) UpdateGroup(groupUpdate goldapps.GroupUpdate) error {
for _, existingAlias := range groupUpdate.Before.Aliases {
keep := false
for _, alias := range groupUpdate.After.Aliases {
if existingAlias == alias {
if strings.ToLower(existingAlias) == strings.ToLower(alias) {
keep = true
break
}
Expand All @@ -137,6 +140,8 @@ func (s googleService) AddGroup(group goldapps.Group) error {
return err
}

time.Sleep(time.Second*10)

// Add members
for _, member := range group.Members {
err = s.addMember(group.Email, member)
Expand Down
7 changes: 4 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ func main() {
return
} else {
fmt.Println("All actions could not be performed...")
fmt.Printf("/t Performed %d out of %d Additions/n", len(performed.Additions), len(changes.Additions))
fmt.Printf("/t Performed %d out of %d Deletions/n", len(performed.Deletions), len(changes.Deletions))
fmt.Printf("/t Performed %d out of %d Updates/n", len(performed.Updates), len(changes.Updates))
fmt.Printf("\t Performed %d out of %d Additions\n", len(performed.Additions), len(changes.Additions))
fmt.Printf("\t Performed %d out of %d Deletions\n", len(performed.Deletions), len(changes.Deletions))
fmt.Printf("\t Performed %d out of %d Updates\n", len(performed.Updates), len(changes.Updates))
fmt.Printf("Error: %s", err.Error())
}
}

Expand Down
8 changes: 5 additions & 3 deletions group.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package goldapps

import "strings"

// Represents a email group.
// Email is the id and main email for the group.
// Members is a lost of email addresses that are members of this group.
Expand All @@ -11,7 +13,7 @@ type Group struct {
}

func (group Group) equals(other Group) bool {
if group.Email != other.Email {
if strings.ToLower(group.Email) != strings.ToLower(other.Email) {
return false
}
if len(group.Members) != len(other.Members) {
Expand All @@ -24,7 +26,7 @@ func (group Group) equals(other Group) bool {
for _, member := range group.Members {
contains := false
for _, otherMember := range other.Members {
if member == otherMember {
if strings.ToLower(member) == strings.ToLower(otherMember) {
contains = true
break
}
Expand All @@ -37,7 +39,7 @@ func (group Group) equals(other Group) bool {
for _, alias := range group.Aliases {
contains := false
for _, otheralias := range other.Aliases {
if alias == otheralias {
if strings.ToLower(alias) == strings.ToLower(otheralias) {
contains = true
break
}
Expand Down

0 comments on commit 33d8e05

Please sign in to comment.