Skip to content

Commit 4743344

Browse files
authoredApr 2, 2024··
Move some of dialog to log rather than prompt to unbold (#6950)
1 parent fbbffd7 commit 4743344

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed
 

‎src/apphosting/secrets/dialogs.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,17 @@ export async function selectBackendServiceAccounts(
150150
const metadata: BackendMetadata[] = toMetadata(projectNumber, listBackends.backends);
151151

152152
if (metadata.every(matchesServiceAccounts(metadata[0]))) {
153+
utils.logLabeledBullet(
154+
"apphosting",
155+
"To use this secret, your backend's service account must have secret accessor permission. All of your backends use " +
156+
(sameServiceAccount(metadata[0]) ? "service account " : "service accounts ") +
157+
serviceAccountDisplay(metadata[0]) +
158+
". Granting access to one backend will grant access to all backends.",
159+
);
153160
const grant = await prompt.confirm({
154161
nonInteractive: options.nonInteractive,
155162
default: true,
156-
message:
157-
"To use this secret, your backend's service account must have secret accessor permission. All of your backends use " +
158-
(sameServiceAccount(metadata[0]) ? "service account " : "service accounts ") +
159-
serviceAccountDisplay(metadata[0]) +
160-
". Granting access to one backend will grant access to all backends. Would you like to grant it now?",
163+
message: "Would you like to grant it now?",
161164
});
162165
if (grant) {
163166
return selectFromMetadata(metadata, [

‎src/test/apphosting/secrets/dialogs.spec.ts

+30-18
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,18 @@ describe("dialogs", () => {
235235
dialogs.selectBackendServiceAccounts("number", "id", {}),
236236
).to.eventually.deep.equal(secrets.toMulti(accounts));
237237

238+
expect(utils.logLabeledBullet).to.have.been.calledWith(
239+
"apphosting",
240+
"To use this secret, your backend's service account must have secret accessor permission. " +
241+
`All of your backends use service accounts ${dialogs.serviceAccountDisplay(accounts)}. ` +
242+
"Granting access to one backend will grant access to all backends.",
243+
);
238244
expect(prompt.confirm).to.have.been.calledWith({
239245
nonInteractive: undefined,
240246
default: true,
241-
message:
242-
"To use this secret, your backend's service account must have secret accessor permission. " +
243-
`All of your backends use service accounts ${dialogs.serviceAccountDisplay(accounts)}. ` +
244-
"Granting access to one backend will grant access to all backends. Would you like to grant it now?",
247+
message: "Would you like to grant it now?",
245248
});
246-
expect(utils.logLabeledBullet).to.not.have.been.called;
249+
expect(utils.logLabeledBullet).to.have.been.calledOnce;
247250
});
248251

249252
it("handles multiple backends with the same (multiple) SAs (opt no)", async () => {
@@ -258,13 +261,16 @@ describe("dialogs", () => {
258261
dialogs.selectBackendServiceAccounts("number", "id", {}),
259262
).to.eventually.deep.equal(emptyMulti);
260263

264+
expect(utils.logLabeledBullet).to.have.been.calledWith(
265+
"apphosting",
266+
"To use this secret, your backend's service account must have secret accessor permission. " +
267+
`All of your backends use service accounts ${dialogs.serviceAccountDisplay(legacyAccounts)}. ` +
268+
"Granting access to one backend will grant access to all backends.",
269+
);
261270
expect(prompt.confirm).to.have.been.calledWith({
262271
nonInteractive: undefined,
263272
default: true,
264-
message:
265-
"To use this secret, your backend's service account must have secret accessor permission. " +
266-
`All of your backends use service accounts ${dialogs.serviceAccountDisplay(legacyAccounts)}. ` +
267-
"Granting access to one backend will grant access to all backends. Would you like to grant it now?",
273+
message: "Would you like to grant it now?",
268274
});
269275
expect(utils.logLabeledBullet).to.have.been.calledWith(
270276
"apphosting",
@@ -286,15 +292,18 @@ describe("dialogs", () => {
286292
runServiceAccounts: [],
287293
});
288294

295+
expect(utils.logLabeledBullet).to.have.been.calledWith(
296+
"apphosting",
297+
"To use this secret, your backend's service account must have secret accessor permission. " +
298+
"All of your backends use service account a. Granting access to one backend will grant access " +
299+
"to all backends.",
300+
);
289301
expect(prompt.confirm).to.have.been.calledWith({
290302
nonInteractive: undefined,
291303
default: true,
292-
message:
293-
"To use this secret, your backend's service account must have secret accessor permission. " +
294-
"All of your backends use service account a. Granting access to one backend will grant access " +
295-
"to all backends. Would you like to grant it now?",
304+
message: "Would you like to grant it now?",
296305
});
297-
expect(utils.logLabeledBullet).to.not.have.been.called;
306+
expect(utils.logLabeledBullet).to.have.been.calledOnce;
298307
});
299308

300309
it("handles multiple backends with the same (single) SA (opt no)", async () => {
@@ -308,13 +317,16 @@ describe("dialogs", () => {
308317
dialogs.selectBackendServiceAccounts("number", "id", {}),
309318
).to.eventually.deep.equal(emptyMulti);
310319

320+
expect(utils.logLabeledBullet).to.have.been.calledWith(
321+
"apphosting",
322+
"To use this secret, your backend's service account must have secret accessor permission. " +
323+
"All of your backends use service account a. Granting access to one backend will grant access " +
324+
"to all backends.",
325+
);
311326
expect(prompt.confirm).to.have.been.calledWith({
312327
nonInteractive: undefined,
313328
default: true,
314-
message:
315-
"To use this secret, your backend's service account must have secret accessor permission. " +
316-
"All of your backends use service account a. Granting access to one backend will grant access " +
317-
"to all backends. Would you like to grant it now?",
329+
message: "Would you like to grant it now?",
318330
});
319331
expect(utils.logLabeledBullet).to.have.been.calledWith(
320332
"apphosting",

0 commit comments

Comments
 (0)
Please sign in to comment.