From 2cd1665a72f39c2c92659d336ba5747b448c3b80 Mon Sep 17 00:00:00 2001 From: BrunoReboul Date: Mon, 30 Mar 2020 18:41:07 +0200 Subject: [PATCH] getgroupsettings fix topic name --- services/getgroupsettings/getgroupsettings.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/getgroupsettings/getgroupsettings.go b/services/getgroupsettings/getgroupsettings.go index 4a56c57..e353ada 100644 --- a/services/getgroupsettings/getgroupsettings.go +++ b/services/getgroupsettings/getgroupsettings.go @@ -37,6 +37,7 @@ type Global struct { initFailed bool outputTopicName string // pubSubClient *pubsubold.Client + projectID string pubsubPublisherClient *pubsub.PublisherClient retryTimeOutSeconds int64 } @@ -52,20 +53,19 @@ func Initialize(ctx context.Context, global *Global) { var gciAdminUserToImpersonate string var keyJSONFilePath string var ok bool - var projectID string var serviceAccountEmail string gciAdminUserToImpersonate = os.Getenv("GCIADMINUSERTOIMPERSONATE") global.outputTopicName = os.Getenv("OUTPUTTOPICNAME") keyJSONFilePath = "./" + os.Getenv("KEYJSONFILENAME") - projectID = os.Getenv("GCP_PROJECT") + global.projectID = os.Getenv("GCP_PROJECT") serviceAccountEmail = os.Getenv("SERVICEACCOUNTNAME") log.Println("Function COLD START") if global.retryTimeOutSeconds, ok = ram.GetEnvVarInt64("RETRYTIMEOUTSECONDS"); !ok { return } - if clientOption, ok = ram.GetClientOptionAndCleanKeys(ctx, serviceAccountEmail, keyJSONFilePath, projectID, gciAdminUserToImpersonate, []string{"https://www.googleapis.com/auth/apps.groups.settings"}); !ok { + if clientOption, ok = ram.GetClientOptionAndCleanKeys(ctx, serviceAccountEmail, keyJSONFilePath, global.projectID, gciAdminUserToImpersonate, []string{"https://www.googleapis.com/auth/apps.groups.settings"}); !ok { return } global.groupsSettingsService, err = groupssettings.NewService(ctx, clientOption) @@ -143,7 +143,7 @@ func EntryPoint(ctxEvent context.Context, PubSubMessage ram.PubSubMessage, globa pubsubMessages = append(pubsubMessages, &pubSubMessage) var publishRequestv1 pubsubpb.PublishRequest - publishRequestv1.Topic = global.outputTopicName + publishRequestv1.Topic = fmt.Sprintf("projects/%s/topics/%s", global.projectID, global.outputTopicName) publishRequestv1.Messages = pubsubMessages pubsubResponse, err := global.pubsubPublisherClient.Publish(global.ctx, &publishRequestv1)