Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: [gkeconnect] remove redundant gRPC service config file #5798

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/google-cloud-gkeconnect-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
1. [Select or create a Cloud Platform project][projects].
1. [Enable billing for your project][billing].
1. [Enable the GKE Connect Gateway API][enable_api].
1. [Set up authentication with a service account][auth] so you can access the
1. [Set up authentication][auth] so you can access the
API from your local workstation.

### Installing the client library
Expand Down Expand Up @@ -150,4 +150,4 @@ See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE)
[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=connectgateway.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started
[auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local
3 changes: 3 additions & 0 deletions packages/google-cloud-gkeconnect-gateway/protos/protos.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ export class GatewayControlClient {
);
const port = opts?.port || staticMembers.port;
const clientConfig = opts?.clientConfig ?? {};
// Implicitly enable HTTP transport for the APIs that use REST as transport (e.g. Google Cloud Compute).
if (!opts) {
opts = {fallback: true};
} else {
opts.fallback = opts.fallback ?? true;
}
const fallback =
opts?.fallback ??
(typeof window !== 'undefined' && typeof window?.fetch === 'function');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ export class GatewayControlClient {
);
const port = opts?.port || staticMembers.port;
const clientConfig = opts?.clientConfig ?? {};
// Implicitly enable HTTP transport for the APIs that use REST as transport (e.g. Google Cloud Compute).
if (!opts) {
opts = {fallback: true};
} else {
opts.fallback = opts.fallback ?? true;
}
const fallback =
opts?.fallback ??
(typeof window !== 'undefined' && typeof window?.fetch === 'function');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import * as protos from '../protos/protos';
import * as assert from 'assert';
import * as sinon from 'sinon';
import {SinonStub} from 'sinon';
import {describe, it} from 'mocha';
import {describe, it, beforeEach, afterEach} from 'mocha';
import * as gatewaycontrolModule from '../src';

import {protobuf} from 'google-gax';
import {GoogleAuth, protobuf} from 'google-gax';

// Dynamically loaded proto JSON is needed to get the type information
// to fill in default values for request objects
Expand Down Expand Up @@ -65,6 +65,19 @@ function stubSimpleCallWithCallback<ResponseType>(
}

describe('v1.GatewayControlClient', () => {
let googleAuth: GoogleAuth;
beforeEach(() => {
googleAuth = {
getClient: sinon.stub().resolves({
getRequestHeaders: sinon
.stub()
.resolves({Authorization: 'Bearer SOME_TOKEN'}),
}),
} as unknown as GoogleAuth;
});
afterEach(() => {
sinon.restore();
});
describe('Common methods', () => {
it('has apiEndpoint', () => {
const client = new gatewaycontrolModule.v1.GatewayControlClient();
Expand Down Expand Up @@ -179,7 +192,7 @@ describe('v1.GatewayControlClient', () => {

it('has initialize method and supports deferred initialization', async () => {
const client = new gatewaycontrolModule.v1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
assert.strictEqual(client.gatewayControlStub, undefined);
Expand All @@ -189,7 +202,7 @@ describe('v1.GatewayControlClient', () => {

it('has close method for the initialized client', done => {
const client = new gatewaycontrolModule.v1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand All @@ -201,7 +214,7 @@ describe('v1.GatewayControlClient', () => {

it('has close method for the non-initialized client', done => {
const client = new gatewaycontrolModule.v1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
assert.strictEqual(client.gatewayControlStub, undefined);
Expand All @@ -213,7 +226,7 @@ describe('v1.GatewayControlClient', () => {
it('has getProjectId method', async () => {
const fakeProjectId = 'fake-project-id';
const client = new gatewaycontrolModule.v1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.auth.getProjectId = sinon.stub().resolves(fakeProjectId);
Expand All @@ -225,7 +238,7 @@ describe('v1.GatewayControlClient', () => {
it('has getProjectId method with callback', async () => {
const fakeProjectId = 'fake-project-id';
const client = new gatewaycontrolModule.v1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.auth.getProjectId = sinon
Expand All @@ -248,7 +261,7 @@ describe('v1.GatewayControlClient', () => {
describe('generateCredentials', () => {
it('invokes generateCredentials without error', async () => {
const client = new gatewaycontrolModule.v1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand Down Expand Up @@ -280,7 +293,7 @@ describe('v1.GatewayControlClient', () => {

it('invokes generateCredentials without error using callback', async () => {
const client = new gatewaycontrolModule.v1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand Down Expand Up @@ -327,7 +340,7 @@ describe('v1.GatewayControlClient', () => {

it('invokes generateCredentials with error', async () => {
const client = new gatewaycontrolModule.v1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand Down Expand Up @@ -358,7 +371,7 @@ describe('v1.GatewayControlClient', () => {

it('invokes generateCredentials with closed client', async () => {
const client = new gatewaycontrolModule.v1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import * as protos from '../protos/protos';
import * as assert from 'assert';
import * as sinon from 'sinon';
import {SinonStub} from 'sinon';
import {describe, it} from 'mocha';
import {describe, it, beforeEach, afterEach} from 'mocha';
import * as gatewaycontrolModule from '../src';

import {protobuf} from 'google-gax';
import {GoogleAuth, protobuf} from 'google-gax';

// Dynamically loaded proto JSON is needed to get the type information
// to fill in default values for request objects
Expand Down Expand Up @@ -65,6 +65,19 @@ function stubSimpleCallWithCallback<ResponseType>(
}

describe('v1beta1.GatewayControlClient', () => {
let googleAuth: GoogleAuth;
beforeEach(() => {
googleAuth = {
getClient: sinon.stub().resolves({
getRequestHeaders: sinon
.stub()
.resolves({Authorization: 'Bearer SOME_TOKEN'}),
}),
} as unknown as GoogleAuth;
});
afterEach(() => {
sinon.restore();
});
describe('Common methods', () => {
it('has apiEndpoint', () => {
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient();
Expand Down Expand Up @@ -180,7 +193,7 @@ describe('v1beta1.GatewayControlClient', () => {

it('has initialize method and supports deferred initialization', async () => {
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
assert.strictEqual(client.gatewayControlStub, undefined);
Expand All @@ -190,7 +203,7 @@ describe('v1beta1.GatewayControlClient', () => {

it('has close method for the initialized client', done => {
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand All @@ -202,7 +215,7 @@ describe('v1beta1.GatewayControlClient', () => {

it('has close method for the non-initialized client', done => {
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
assert.strictEqual(client.gatewayControlStub, undefined);
Expand All @@ -214,7 +227,7 @@ describe('v1beta1.GatewayControlClient', () => {
it('has getProjectId method', async () => {
const fakeProjectId = 'fake-project-id';
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.auth.getProjectId = sinon.stub().resolves(fakeProjectId);
Expand All @@ -226,7 +239,7 @@ describe('v1beta1.GatewayControlClient', () => {
it('has getProjectId method with callback', async () => {
const fakeProjectId = 'fake-project-id';
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.auth.getProjectId = sinon
Expand All @@ -249,7 +262,7 @@ describe('v1beta1.GatewayControlClient', () => {
describe('generateCredentials', () => {
it('invokes generateCredentials without error', async () => {
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand Down Expand Up @@ -281,7 +294,7 @@ describe('v1beta1.GatewayControlClient', () => {

it('invokes generateCredentials without error using callback', async () => {
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand Down Expand Up @@ -328,7 +341,7 @@ describe('v1beta1.GatewayControlClient', () => {

it('invokes generateCredentials with error', async () => {
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand Down Expand Up @@ -359,7 +372,7 @@ describe('v1beta1.GatewayControlClient', () => {

it('invokes generateCredentials with closed client', async () => {
const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
auth: googleAuth,
projectId: 'bogus',
});
client.initialize();
Expand Down
Loading