@@ -27,7 +27,9 @@ import (
2727 "github.com/sigstore/rekor/pkg/events"
2828 sigpubsub "github.com/sigstore/rekor/pkg/pubsub"
2929
30- "cloud.google.com/go/pubsub"
30+ iam "cloud.google.com/go/iam/apiv1"
31+ "cloud.google.com/go/iam/apiv1/iampb"
32+ "cloud.google.com/go/pubsub/v2"
3133 "google.golang.org/api/option"
3234)
3335
@@ -69,7 +71,14 @@ func New(ctx context.Context, topicResourceID string, opts ...option.ClientOptio
6971 // server start up if they are called. If the environment variable is set,
7072 // skip this check.
7173 if os .Getenv ("PUBSUB_EMULATOR_HOST" ) == "" {
72- if _ , err := client .Topic (topic ).IAM ().TestPermissions (ctx , requiredIAMPermissions ); err != nil {
74+ iamClient , err := iam .NewIamPolicyClient (ctx )
75+ if err != nil {
76+ return nil , fmt .Errorf ("getting IAM client: %w" , err )
77+ }
78+ if _ , err := iamClient .TestIamPermissions (ctx , & iampb.TestIamPermissionsRequest {
79+ Resource : client .Publisher (topic ).String (),
80+ Permissions : requiredIAMPermissions ,
81+ }); err != nil {
7382 return nil , fmt .Errorf ("insufficient permissions for topic %q: %w" , topic , err )
7483 }
7584 }
@@ -105,7 +114,7 @@ func (p *Publisher) Publish(ctx context.Context, event *events.Event, encoding e
105114 }
106115
107116 // The Publish call does not block.
108- res := p .client .Topic (p .topic ).Publish (ctx , msg )
117+ res := p .client .Publisher (p .topic ).Publish (ctx , msg )
109118
110119 // TODO: Consider making the timeout configurable.
111120 cctx , cancel := context .WithTimeout (ctx , pubsub .DefaultPublishSettings .Timeout )
0 commit comments