Skip to content

Commit

Permalink
[revert_gce_call_creds] Revert "credentials/google: introduce a new A…
Browse files Browse the repository at this point in the history
…PI `NewComputeEngineCredsWithOptions` (grpc#4767)"

This reverts commit 127c052.
  • Loading branch information
menghanl committed Oct 1, 2021
1 parent 127c052 commit c6c278f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
22 changes: 2 additions & 20 deletions credentials/google/google.go
Expand Up @@ -64,32 +64,14 @@ func NewDefaultCredentials() credentials.Bundle {
//
// This API is experimental.
func NewComputeEngineCredentials() credentials.Bundle {
return NewComputeEngineCredsWithOptions(ComputeEngineCredsOptions{})
}

// ComputeEngineCredsOptions constructs compite engine credentials with options.
type ComputeEngineCredsOptions struct {
// PerRPCCreds is a per RPC credentials that is passed to a bundle.
PerRPCCreds credentials.PerRPCCredentials
}

// NewComputeEngineCredsWithOptions returns a credentials bundle that is configured to work
// with google services. This API must only be used when running on GCE.
//
// This API is experimental.
func NewComputeEngineCredsWithOptions(perRPCOpts ComputeEngineCredsOptions) credentials.Bundle {
perRPC := oauth.NewComputeEngine()
if perRPCOpts.PerRPCCreds != nil {
perRPC = perRPCOpts.PerRPCCreds
}
c := &creds{
newPerRPCCreds: func() credentials.PerRPCCredentials {
return perRPC
return oauth.NewComputeEngine()
},
}
bundle, err := c.NewWithMode(internal.CredsBundleModeFallback)
if err != nil {
logger.Warningf("compute engine creds with per rpc: failed to create new creds: %v", err)
logger.Warningf("compute engine creds: failed to create new creds: %v", err)
}
return bundle
}
Expand Down
5 changes: 2 additions & 3 deletions credentials/google/google_test.go
Expand Up @@ -76,9 +76,8 @@ func overrideNewCredsFuncs() func() {
func TestClientHandshakeBasedOnClusterName(t *testing.T) {
defer overrideNewCredsFuncs()()
for bundleTyp, tc := range map[string]credentials.Bundle{
"defaultCreds": NewDefaultCredentials(),
"computeCreds": NewComputeEngineCredentials(),
"computeCredsPerRPC": NewComputeEngineCredsWithOptions(ComputeEngineCredsOptions{}),
"defaultCreds": NewDefaultCredentials(),
"computeCreds": NewComputeEngineCredentials(),
} {
tests := []struct {
name string
Expand Down

0 comments on commit c6c278f

Please sign in to comment.