77 "time"
88
99 "google.golang.org/api/dns/v1"
10+ "google.golang.org/api/option"
1011
1112 "github.com/openshift/installer/pkg/asset/installconfig"
1213 gcpic "github.com/openshift/installer/pkg/asset/installconfig/gcp"
@@ -116,8 +117,12 @@ func createRecordSets(ctx context.Context, ic *installconfig.InstallConfig, clus
116117
117118// createDNSRecords will get the list of records to be created and execute their creation through the gcp dns api.
118119func createDNSRecords (ctx context.Context , ic * installconfig.InstallConfig , clusterID , apiIP , apiIntIP string ) error {
120+ ssn , err := gcpic .GetSession (ctx )
121+ if err != nil {
122+ return fmt .Errorf ("failed to get session: %w" , err )
123+ }
119124 // TODO: use the opts for the service to restrict scopes see google.golang.org/api/option.WithScopes
120- dnsService , err := dns .NewService (ctx )
125+ dnsService , err := dns .NewService (ctx , option . WithCredentials ( ssn . Credentials ) )
121126 if err != nil {
122127 return fmt .Errorf ("failed to create the gcp dns service: %w" , err )
123128 }
@@ -144,7 +149,11 @@ func createDNSRecords(ctx context.Context, ic *installconfig.InstallConfig, clus
144149// private managed zone should only be created when one is not specified in the install config.
145150func createPrivateManagedZone (ctx context.Context , ic * installconfig.InstallConfig , clusterID , network string ) error {
146151 // TODO: use the opts for the service to restrict scopes see google.golang.org/api/option.WithScopes
147- dnsService , err := dns .NewService (ctx )
152+ ssn , err := gcpic .GetSession (ctx )
153+ if err != nil {
154+ return fmt .Errorf ("failed to get session: %w" , err )
155+ }
156+ dnsService , err := dns .NewService (ctx , option .WithCredentials (ssn .Credentials ))
148157 if err != nil {
149158 return fmt .Errorf ("failed to create the gcp dns service: %w" , err )
150159 }
0 commit comments