Skip to content

Commit

Permalink
Switch to service account key
Browse files Browse the repository at this point in the history
Change-Id: I33d0eccb3f9087d339323ca35a425dff2416b9d4
  • Loading branch information
dims committed May 2, 2019
1 parent 55b1a5f commit 95a62e7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
@@ -1 +1 @@
groups/client_id.json filter=git-crypt diff=git-crypt
groups/*.json filter=git-crypt diff=git-crypt
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

Binary file removed groups/client_id.json
Binary file not shown.
Binary file added groups/k8s-infra-test-project-1896690daeb3.json
Binary file not shown.
15 changes: 9 additions & 6 deletions groups/reconcile.go
Expand Up @@ -76,21 +76,24 @@ func saveToken(path string, token *oauth2.Token) {
}

func main() {
b, err := ioutil.ReadFile("client_id.json")
jsonCredentials, err := ioutil.ReadFile("k8s-infra-test-project-1896690daeb3.json")
if err != nil {
log.Fatalf("Unable to read client secret file: %v", err)
panic(fmt.Sprintf("error reading credentials from file: %v", err))
}

// If modifying these scopes, delete your previously saved token.json.
config, err := google.ConfigFromJSON(b, admin.AdminDirectoryUserReadonlyScope,
config, err := google.JWTConfigFromJSON(jsonCredentials, admin.AdminDirectoryUserReadonlyScope,
admin.AdminDirectoryGroupScope,
admin.AdminDirectoryGroupMemberScope,
groupssettings.AppsGroupsSettingsScope)
if err != nil {
log.Fatalf("Unable to parse client secret file to config: %v", err)
panic(fmt.Sprintf("Unable to parse client secret file to config: %v\n. " +
"Please run 'git-crypt unlock'", err))
}
client := getClient(config)
config.Subject = "wg-k8s-infra-api-test@kubernetes.io"

ctx := context.Background()

client := config.Client(ctx)
srv, err := admin.New(client)
if err != nil {
log.Fatalf("Unable to retrieve directory Client %v", err)
Expand Down

0 comments on commit 95a62e7

Please sign in to comment.