@@ -96,7 +96,7 @@ void SetBucketEncryptionEnforcementConfig(
9696 gmek_encryption.customer_supplied_encryption_enforcement_config
9797 .restriction_mode = " FullyRestricted" ;
9898 std::cout << " Bucket "
99- << create_bucket (" gmek -" + bucket_name, gmek_encryption)->name ()
99+ << create_bucket (" g -" + bucket_name, gmek_encryption)->name ()
100100 << " created with GMEK-only enforcement policy.\n " ;
101101
102102 // In GCS, a single project cannot create or delete buckets more often than
@@ -112,7 +112,7 @@ void SetBucketEncryptionEnforcementConfig(
112112 cmek_encryption.customer_supplied_encryption_enforcement_config
113113 .restriction_mode = " FullyRestricted" ;
114114 std::cout << " Bucket "
115- << create_bucket (" cmek -" + bucket_name, cmek_encryption)->name ()
115+ << create_bucket (" c -" + bucket_name, cmek_encryption)->name ()
116116 << " created with CMEK-only enforcement policy.\n " ;
117117
118118 // In GCS, a single project cannot create or delete buckets more often than
@@ -124,7 +124,7 @@ void SetBucketEncryptionEnforcementConfig(
124124 csek_encryption.customer_supplied_encryption_enforcement_config
125125 .restriction_mode = " FullyRestricted" ;
126126 std::cout << " Bucket "
127- << create_bucket (" csek -" + bucket_name, csek_encryption)->name ()
127+ << create_bucket (" rc -" + bucket_name, csek_encryption)->name ()
128128 << " created with a policy to restrict CSEK.\n " ;
129129 }
130130 // ! [set bucket encryption enforcement config] [END
@@ -181,6 +181,17 @@ void RunAll(std::vector<std::string> const& argv) {
181181 examples::MakeRandomBucketName (generator).substr (0 , 50 );
182182 auto client = gcs::Client (examples::CreateBucketOptions ());
183183
184+ auto constexpr kBucketPeriod = std::chrono::seconds (2 );
185+
186+ // Clean up any potentially leaked buckets from a previous run before creating
187+ // them.
188+ (void )examples::RemoveBucketAndContents (client, " g-" + bucket_name);
189+ if (!examples::UsingEmulator ()) std::this_thread::sleep_for (kBucketPeriod );
190+ (void )examples::RemoveBucketAndContents (client, " c-" + bucket_name);
191+ if (!examples::UsingEmulator ()) std::this_thread::sleep_for (kBucketPeriod );
192+ (void )examples::RemoveBucketAndContents (client, " rc-" + bucket_name);
193+ if (!examples::UsingEmulator ()) std::this_thread::sleep_for (kBucketPeriod );
194+
184195 std::cout << " \n Running the SetBucketEncryptionEnforcementConfig() example"
185196 << std::endl;
186197 SetBucketEncryptionEnforcementConfig (client, {project_id, bucket_name});
@@ -202,7 +213,6 @@ void RunAll(std::vector<std::string> const& argv) {
202213 // In GCS a single project cannot create or delete buckets more often than
203214 // once every two seconds. We will pause until that time before deleting the
204215 // buckets.
205- auto constexpr kBucketPeriod = std::chrono::seconds (2 );
206216 auto pause = std::chrono::steady_clock::now () + kBucketPeriod ;
207217 if (!examples::UsingEmulator ()) std::this_thread::sleep_until (pause);
208218
0 commit comments