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

feat: add several fields to manage state of database encryption update #1904

Merged
merged 6 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion protos/google/pubsub/v1/pubsub.proto
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ message IngestionDataSourceSettings {
KINESIS_PERMISSION_DENIED = 2;

// Permission denied encountered while publishing to the topic. This can
// happen due to Pub/Sub SA has not been granted the [appropriate publish
// happen if the Pub/Sub SA has not been granted the [appropriate publish
// permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
PUBLISH_PERMISSION_DENIED = 3;

Expand Down Expand Up @@ -1197,6 +1197,11 @@ message CloudStorageConfig {
// Must not end in "/".
string filename_suffix = 3 [(google.api.field_behavior) = OPTIONAL];

// Optional. User-provided format string specifying how to represent datetimes
// in Cloud Storage filenames. See the [datetime format
// guidance](https://cloud.google.com/pubsub/docs/create-cloudstorage-subscription#file_names).
string filename_datetime_format = 10 [(google.api.field_behavior) = OPTIONAL];

// Defaults to text format.
oneof output_format {
// Optional. If set, message data will be written to Cloud Storage in text
Expand Down
6 changes: 6 additions & 0 deletions protos/protos.d.ts

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

23 changes: 23 additions & 0 deletions protos/protos.js

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

7 changes: 7 additions & 0 deletions protos/protos.json

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

15 changes: 11 additions & 4 deletions src/v1/publisher_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,15 @@ export class PublisherClient {
'Please set either universe_domain or universeDomain, but not both.'
);
}
const universeDomainEnvVar =
typeof process === 'object' && typeof process.env === 'object'
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
: undefined;
this._universeDomain =
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
opts?.universeDomain ??
opts?.universe_domain ??
universeDomainEnvVar ??
'googleapis.com';
this._servicePath = 'pubsub.' + this._universeDomain;
const servicePath =
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
Expand Down Expand Up @@ -177,7 +184,7 @@ export class PublisherClient {

// Determine the client header string.
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {
if (typeof process === 'object' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
} else {
clientHeader.push(`gl-web/${this._gaxModule.version}`);
Expand Down Expand Up @@ -350,7 +357,7 @@ export class PublisherClient {
*/
static get servicePath() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand All @@ -368,7 +375,7 @@ export class PublisherClient {
*/
static get apiEndpoint() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand Down
15 changes: 11 additions & 4 deletions src/v1/schema_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,15 @@ export class SchemaServiceClient {
'Please set either universe_domain or universeDomain, but not both.'
);
}
const universeDomainEnvVar =
typeof process === 'object' && typeof process.env === 'object'
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
: undefined;
this._universeDomain =
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
opts?.universeDomain ??
opts?.universe_domain ??
universeDomainEnvVar ??
'googleapis.com';
this._servicePath = 'pubsub.' + this._universeDomain;
const servicePath =
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
Expand Down Expand Up @@ -176,7 +183,7 @@ export class SchemaServiceClient {

// Determine the client header string.
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {
if (typeof process === 'object' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
} else {
clientHeader.push(`gl-web/${this._gaxModule.version}`);
Expand Down Expand Up @@ -326,7 +333,7 @@ export class SchemaServiceClient {
*/
static get servicePath() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand All @@ -344,7 +351,7 @@ export class SchemaServiceClient {
*/
static get apiEndpoint() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand Down
15 changes: 11 additions & 4 deletions src/v1/subscriber_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,15 @@ export class SubscriberClient {
'Please set either universe_domain or universeDomain, but not both.'
);
}
const universeDomainEnvVar =
typeof process === 'object' && typeof process.env === 'object'
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
: undefined;
this._universeDomain =
opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com';
opts?.universeDomain ??
opts?.universe_domain ??
universeDomainEnvVar ??
'googleapis.com';
this._servicePath = 'pubsub.' + this._universeDomain;
const servicePath =
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
Expand Down Expand Up @@ -178,7 +185,7 @@ export class SubscriberClient {

// Determine the client header string.
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {
if (typeof process === 'object' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
} else {
clientHeader.push(`gl-web/${this._gaxModule.version}`);
Expand Down Expand Up @@ -359,7 +366,7 @@ export class SubscriberClient {
*/
static get servicePath() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand All @@ -377,7 +384,7 @@ export class SubscriberClient {
*/
static get apiEndpoint() {
if (
typeof process !== undefined &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
Expand Down
34 changes: 33 additions & 1 deletion test/gapic_publisher_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('v1.PublisherClient', () => {
});

if (
typeof process !== 'undefined' &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
it('throws DeprecationWarning if static servicePath is used', () => {
Expand Down Expand Up @@ -176,6 +176,38 @@ describe('v1.PublisherClient', () => {
const servicePath = client.apiEndpoint;
assert.strictEqual(servicePath, 'pubsub.example.com');
});

if (typeof process === 'object' && 'env' in process) {
describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => {
it('sets apiEndpoint from environment variable', () => {
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
const client = new publisherModule.v1.PublisherClient();
const servicePath = client.apiEndpoint;
assert.strictEqual(servicePath, 'pubsub.example.com');
if (saved) {
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
} else {
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
}
});

it('value configured in code has priority over environment variable', () => {
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
const client = new publisherModule.v1.PublisherClient({
universeDomain: 'configured.example.com',
});
const servicePath = client.apiEndpoint;
assert.strictEqual(servicePath, 'pubsub.configured.example.com');
if (saved) {
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
} else {
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
}
});
});
}
it('does not allow setting both universeDomain and universe_domain', () => {
assert.throws(() => {
new publisherModule.v1.PublisherClient({
Expand Down
34 changes: 33 additions & 1 deletion test/gapic_schema_service_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('v1.SchemaServiceClient', () => {
});

if (
typeof process !== 'undefined' &&
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
it('throws DeprecationWarning if static servicePath is used', () => {
Expand Down Expand Up @@ -178,6 +178,38 @@ describe('v1.SchemaServiceClient', () => {
const servicePath = client.apiEndpoint;
assert.strictEqual(servicePath, 'pubsub.example.com');
});

if (typeof process === 'object' && 'env' in process) {
describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => {
it('sets apiEndpoint from environment variable', () => {
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
const client = new schemaserviceModule.v1.SchemaServiceClient();
const servicePath = client.apiEndpoint;
assert.strictEqual(servicePath, 'pubsub.example.com');
if (saved) {
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
} else {
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
}
});

it('value configured in code has priority over environment variable', () => {
const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com';
const client = new schemaserviceModule.v1.SchemaServiceClient({
universeDomain: 'configured.example.com',
});
const servicePath = client.apiEndpoint;
assert.strictEqual(servicePath, 'pubsub.configured.example.com');
if (saved) {
process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved;
} else {
delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'];
}
});
});
}
it('does not allow setting both universeDomain and universe_domain', () => {
assert.throws(() => {
new schemaserviceModule.v1.SchemaServiceClient({
Expand Down
Loading
Loading