Skip to content

Commit

Permalink
samples: fix wording for preconditions to use correct operation inste… (
Browse files Browse the repository at this point in the history
#2130)

* samples: fix wording for preconditions to use correct operation instead of upload

* correct file.setmetadata related samples to reference ifMetagenerationMatch instead of ifGenerationMatch

* fix samples tests
  • Loading branch information
ddelgrosso1 authored Jan 24, 2023
1 parent f20c28c commit 68cd684
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion samples/changeFileCSEKToCMEK.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function main(
const rotateEncryptionKeyOptions = {
kmsKeyName,
// Optional: set a generation-match precondition to avoid potential race
// conditions and data corruptions. The request to upload is aborted if the
// conditions and data corruptions. The request to copy is aborted if the
// object's generation number does not match your precondition.
preconditionOpts: {
ifGenerationMatch: generationMatchPrecondition,
Expand Down
2 changes: 1 addition & 1 deletion samples/composeFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function main(

// Optional:
// Set a generation-match precondition to avoid potential race conditions
// and data corruptions. The request to upload is aborted if the object's
// and data corruptions. The request to compose is aborted if the object's
// generation number does not match your precondition. For a destination
// object that does not yet exist, set the ifGenerationMatch precondition to 0
// If the destination object already exists in your bucket, set instead a
Expand Down
2 changes: 1 addition & 1 deletion samples/copyFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function main(

// Optional:
// Set a generation-match precondition to avoid potential race conditions
// and data corruptions. The request to upload is aborted if the object's
// and data corruptions. The request to copy is aborted if the object's
// generation number does not match your precondition. For a destination
// object that does not yet exist, set the ifGenerationMatch precondition to 0
// If the destination object already exists in your bucket, set instead a
Expand Down
2 changes: 1 addition & 1 deletion samples/copyOldVersionOfFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function main(

// Optional:
// Set a generation-match precondition to avoid potential race conditions
// and data corruptions. The request to upload is aborted if the object's
// and data corruptions. The request to copy is aborted if the object's
// generation number does not match your precondition. For a destination
// object that does not yet exist, set the ifGenerationMatch precondition to 0
// If the destination object already exists in your bucket, set instead a
Expand Down
2 changes: 1 addition & 1 deletion samples/deleteFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function main(

// Optional:
// Set a generation-match precondition to avoid potential race conditions
// and data corruptions. The request to upload is aborted if the object's
// and data corruptions. The request to delete is aborted if the object's
// generation number does not match your precondition. For a destination
// object that does not yet exist, set the ifGenerationMatch precondition to 0
// If the destination object already exists in your bucket, set instead a
Expand Down
2 changes: 1 addition & 1 deletion samples/fileChangeStorageClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function main(
async function fileChangeStorageClass() {
// Optional:
// Set a generation-match precondition to avoid potential race conditions
// and data corruptions. The request to upload is aborted if the object's
// and data corruptions. The request to copy is aborted if the object's
// generation number does not match your precondition. For a destination
// object that does not yet exist, set the ifGenerationMatch precondition to 0
// If the destination object already exists in your bucket, set instead a
Expand Down
10 changes: 5 additions & 5 deletions samples/fileSetMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
function main(
bucketName = 'my-bucket',
fileName = 'file.txt',
generationMatchPrecondition = 0
metagenerationMatchPrecondition = 0
) {
// [START storage_set_metadata]
// Imports the Google Cloud client library
Expand All @@ -41,11 +41,11 @@ function main(
// const fileName = 'your-file-name';

async function setFileMetadata() {
// Optional: set a generation-match precondition to avoid potential race
// conditions and data corruptions. The request to upload is aborted if the
// object's generation number does not match your precondition.
// Optional: set a meta-generation-match precondition to avoid potential race
// conditions and data corruptions. The request to set metadata is aborted if the
// object's metageneration number does not match your precondition.
const options = {
ifGenerationMatch: generationMatchPrecondition,
ifMetagenerationMatch: metagenerationMatchPrecondition,
};

// Set file metadata.
Expand Down
2 changes: 1 addition & 1 deletion samples/moveFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function main(
async function moveFile() {
// Optional:
// Set a generation-match precondition to avoid potential race conditions
// and data corruptions. The request to upload is aborted if the object's
// and data corruptions. The request to copy is aborted if the object's
// generation number does not match your precondition. For a destination
// object that does not yet exist, set the ifGenerationMatch precondition to 0
// If the destination object already exists in your bucket, set instead a
Expand Down
10 changes: 5 additions & 5 deletions samples/releaseEventBasedHold.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
function main(
bucketName = 'my-bucket',
fileName = 'test.txt',
generationMatchPrecondition = 0
metagenerationMatchPrecondition = 0
) {
// [START storage_release_event_based_hold]
/**
Expand All @@ -42,11 +42,11 @@ function main(
const storage = new Storage();

async function releaseEventBasedHold() {
// Optional: set a generation-match precondition to avoid potential race
// conditions and data corruptions. The request to upload is aborted if the
// object's generation number does not match your precondition.
// Optional: set a meta-generation-match precondition to avoid potential race
// conditions and data corruptions. The request to set metadata is aborted if the
// object's metageneration number does not match your precondition.
const options = {
ifGenerationMatch: generationMatchPrecondition,
ifMetagenerationMatch: metagenerationMatchPrecondition,
};

await storage.bucket(bucketName).file(fileName).setMetadata(
Expand Down
10 changes: 5 additions & 5 deletions samples/releaseTemporaryHold.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
function main(
bucketName = 'my-bucket',
fileName = 'test.txt',
generationMatchPrecondition = 0
metagenerationMatchPrecondition = 0
) {
// [START storage_release_temporary_hold]
/**
Expand All @@ -42,11 +42,11 @@ function main(
const storage = new Storage();

async function releaseTemporaryHold() {
// Optional: set a generation-match precondition to avoid potential race
// conditions and data corruptions. The request to upload is aborted if the
// object's generation number does not match your precondition.
// Optional: set a meta-generation-match precondition to avoid potential race
// conditions and data corruptions. The request to set metadata is aborted if the
// object's metageneration number does not match your precondition.
const options = {
ifGenerationMatch: generationMatchPrecondition,
ifMetagenerationMatch: metagenerationMatchPrecondition,
};

await storage.bucket(bucketName).file(fileName).setMetadata(
Expand Down
2 changes: 1 addition & 1 deletion samples/rotateEncryptionKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function main(
encryptionKey: Buffer.from(newKey, 'base64'),

// Optional: set a generation-match precondition to avoid potential race
// conditions and data corruptions. The request to upload is aborted if the
// conditions and data corruptions. The request to copy is aborted if the
// object's generation number does not match your precondition.
preconditionOpts: {
ifGenerationMatch: generationMatchPrecondition,
Expand Down
10 changes: 5 additions & 5 deletions samples/setEventBasedHold.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
function main(
bucketName = 'my-bucket',
fileName = 'test.txt',
generationMatchPrecondition = 0
metagenerationMatchPrecondition = 0
) {
// [START storage_set_event_based_hold]
/**
Expand All @@ -42,11 +42,11 @@ function main(
const storage = new Storage();

async function setEventBasedHold() {
// Optional: set a generation-match precondition to avoid potential race
// conditions and data corruptions. The request to upload is aborted if the
// object's generation number does not match your precondition.
// Optional: set a meta-generation-match precondition to avoid potential race
// conditions and data corruptions. The request to set metadata is aborted if the
// object's metageneration number does not match your precondition.
const options = {
ifGenerationMatch: generationMatchPrecondition,
ifMetagenerationMatch: metagenerationMatchPrecondition,
};

// Set event-based hold
Expand Down
10 changes: 5 additions & 5 deletions samples/setTemporaryHold.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
function main(
bucketName = 'my-bucket',
fileName = 'test.txt',
generationMatchPrecondition = 0
metagenerationMatchPrecondition = 0
) {
// [START storage_set_temporary_hold]
/**
Expand All @@ -42,11 +42,11 @@ function main(
const storage = new Storage();

async function setTemporaryHold() {
// Optional: set a generation-match precondition to avoid potential race
// conditions and data corruptions. The request to upload is aborted if the
// object's generation number does not match your precondition.
// Optional: set a meta-generation-match precondition to avoid potential race
// conditions and data corruptions. The request to set metadata is aborted if the
// object's metageneration number does not match your precondition.
const options = {
ifGenerationMatch: generationMatchPrecondition,
ifMetagenerationMatch: metagenerationMatchPrecondition,
};

await storage.bucket(bucketName).file(fileName).setMetadata(
Expand Down
8 changes: 4 additions & 4 deletions samples/system-test/bucketLock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ it('should disable default event-based hold on a bucket', () => {
it('should set an event-based hold on a file', async () => {
const [metadata] = await bucket.file(fileName).getMetadata();
const output = execSync(
`node setEventBasedHold.js ${bucketName} ${fileName} ${metadata.generation}`
`node setEventBasedHold.js ${bucketName} ${fileName} ${metadata.metageneration}`
);
assert.match(output, new RegExp(`Event-based hold was set for ${fileName}`));
});

it('should release an event-based hold on a file', async () => {
const [metadata] = await bucket.file(fileName).getMetadata();
const output = execSync(
`node releaseEventBasedHold.js ${bucketName} ${fileName} ${metadata.generation}`
`node releaseEventBasedHold.js ${bucketName} ${fileName} ${metadata.metageneration}`
);
assert.match(
output,
Expand All @@ -118,15 +118,15 @@ it('should remove a retention policy on a bucket', () => {
it('should set an temporary hold on a file', async () => {
const [metadata] = await bucket.file(fileName).getMetadata();
const output = execSync(
`node setTemporaryHold.js ${bucketName} ${fileName} ${metadata.generation}`
`node setTemporaryHold.js ${bucketName} ${fileName} ${metadata.metageneration}`
);
assert.match(output, new RegExp(`Temporary hold was set for ${fileName}.`));
});

it('should release an temporary hold on a file', async () => {
const [metadata] = await bucket.file(fileName).getMetadata();
const output = execSync(
`node releaseTemporaryHold.js ${bucketName} ${fileName} ${metadata.generation}`
`node releaseTemporaryHold.js ${bucketName} ${fileName} ${metadata.metageneration}`
);
assert.match(
output,
Expand Down
2 changes: 1 addition & 1 deletion samples/system-test/files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ describe('file', () => {
modified: '1900-01-01',
};
const output = execSync(
`node fileSetMetadata.js ${bucketName} ${copiedFileName} ${metadata.generation} `
`node fileSetMetadata.js ${bucketName} ${copiedFileName} ${metadata.metageneration} `
);

assert.match(
Expand Down

0 comments on commit 68cd684

Please sign in to comment.