Skip to content

Commit 288bece

Browse files
committed
Polish contribution
See gh-25456
1 parent 32caf76 commit 288bece

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,11 @@ private void configureProperties(FluentConfiguration configuration, FlywayProper
248248
.to((skipExecutingMigrations) -> configuration.skipExecutingMigrations(skipExecutingMigrations));
249249
// Teams secrets management properties (all non-method reference for
250250
// compatibility with Flyway 6.x)
251-
map.from(properties.getConjurUrl()).whenNonNull().to((conjurUrl) -> configuration.conjurUrl(conjurUrl));
252-
map.from(properties.getConjurToken()).whenNonNull()
253-
.to((conjurToken) -> configuration.conjurToken(conjurToken));
254-
map.from(properties.getVaultUrl()).whenNonNull().to((vaultUrl) -> configuration.vaultUrl(vaultUrl));
255-
map.from(properties.getVaultToken()).whenNonNull().to((vaultToken) -> configuration.vaultToken(vaultToken));
256-
map.from(properties.getVaultSecrets()).whenNonNull()
251+
map.from(properties.getConjurUrl()).to((conjurUrl) -> configuration.conjurUrl(conjurUrl));
252+
map.from(properties.getConjurToken()).to((conjurToken) -> configuration.conjurToken(conjurToken));
253+
map.from(properties.getVaultUrl()).to((vaultUrl) -> configuration.vaultUrl(vaultUrl));
254+
map.from(properties.getVaultToken()).to((vaultToken) -> configuration.vaultToken(vaultToken));
255+
map.from(properties.getVaultSecrets()).whenNot(List::isEmpty)
257256
.to((vaultSecrets) -> configuration.vaultSecrets(vaultSecrets.toArray(new String[0])));
258257
}
259258

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -350,9 +350,10 @@ public class FlywayProperties {
350350
private String vaultToken;
351351

352352
/**
353-
* Comma-separated list of paths to secrets that contain Flyway configurations. Each
354-
* path must start with the name of the engine and end with the name of the secret
355-
* such 'kv/test/1/config'. Requires Flyway teams.
353+
* Comma-separated list of paths to secrets that contain Flyway configurations. This
354+
* must start with the name of the engine followed by '/data/' and end with the name
355+
* of the secret. The resulting form is '{engine}/data/{path}/{to}/{secret_name}'.
356+
* Requires Flyway teams.
356357
*/
357358
private List<String> vaultSecrets;
358359

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -416,21 +416,21 @@ void configurationCustomizersAreConfiguredAndOrdered() {
416416
@Test
417417
void batchIsCorrectlyMapped() {
418418
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
419-
.withPropertyValues("spring.flyway.batch=true").run(validateTeamsPropertyCorrectlyMapped("batch"));
419+
.withPropertyValues("spring.flyway.batch=true").run(validateFlywayTeamsPropertyOnly("batch"));
420420
}
421421

422422
@Test
423423
void dryRunOutputIsCorrectlyMapped() {
424424
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
425425
.withPropertyValues("spring.flyway.dryRunOutput=dryrun.sql")
426-
.run(validateTeamsPropertyCorrectlyMapped("dryRunOutput"));
426+
.run(validateFlywayTeamsPropertyOnly("dryRunOutput"));
427427
}
428428

429429
@Test
430430
void errorOverridesIsCorrectlyMapped() {
431431
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
432432
.withPropertyValues("spring.flyway.errorOverrides=D12345")
433-
.run(validateTeamsPropertyCorrectlyMapped("errorOverrides"));
433+
.run(validateFlywayTeamsPropertyOnly("errorOverrides"));
434434
}
435435

436436
@Test
@@ -444,27 +444,27 @@ void licenseKeyIsCorrectlyMapped(CapturedOutput output) {
444444
void oracleSqlplusIsCorrectlyMapped() {
445445
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
446446
.withPropertyValues("spring.flyway.oracle-sqlplus=true")
447-
.run(validateTeamsPropertyCorrectlyMapped("oracle.sqlplus"));
447+
.run(validateFlywayTeamsPropertyOnly("oracle.sqlplus"));
448448
}
449449

450450
@Test
451451
void oracleSqlplusWarnIsCorrectlyMapped() {
452452
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
453453
.withPropertyValues("spring.flyway.oracle-sqlplus-warn=true")
454-
.run(validateTeamsPropertyCorrectlyMapped("oracle.sqlplusWarn"));
454+
.run(validateFlywayTeamsPropertyOnly("oracle.sqlplusWarn"));
455455
}
456456

457457
@Test
458458
void streamIsCorrectlyMapped() {
459459
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
460-
.withPropertyValues("spring.flyway.stream=true").run(validateTeamsPropertyCorrectlyMapped("stream"));
460+
.withPropertyValues("spring.flyway.stream=true").run(validateFlywayTeamsPropertyOnly("stream"));
461461
}
462462

463463
@Test
464464
void undoSqlMigrationPrefix() {
465465
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
466466
.withPropertyValues("spring.flyway.undo-sql-migration-prefix=undo")
467-
.run(validateTeamsPropertyCorrectlyMapped("undoSqlMigrationPrefix"));
467+
.run(validateFlywayTeamsPropertyOnly("undoSqlMigrationPrefix"));
468468
}
469469

470470
@Test
@@ -499,78 +499,77 @@ void initSqlsWithFlywayUrl() {
499499
@Test
500500
void cherryPickIsCorrectlyMapped() {
501501
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
502-
.withPropertyValues("spring.flyway.cherry-pick=1.1")
503-
.run(validateTeamsPropertyCorrectlyMapped("cherryPick"));
502+
.withPropertyValues("spring.flyway.cherry-pick=1.1").run(validateFlywayTeamsPropertyOnly("cherryPick"));
504503
}
505504

506505
@Test
507506
void jdbcPropertiesAreCorrectlyMapped() {
508507
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
509508
.withPropertyValues("spring.flyway.jdbc-properties.prop=value")
510-
.run(validateTeamsPropertyCorrectlyMapped("jdbcProperties"));
509+
.run(validateFlywayTeamsPropertyOnly("jdbcProperties"));
511510
}
512511

513512
@Test
514513
void oracleKerberosCacheFileIsCorrectlyMapped() {
515514
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
516515
.withPropertyValues("spring.flyway.oracle-kerberos-cache-file=/tmp/cache")
517-
.run(validateTeamsPropertyCorrectlyMapped("oracle.kerberosCacheFile"));
516+
.run(validateFlywayTeamsPropertyOnly("oracle.kerberosCacheFile"));
518517
}
519518

520519
@Test
521520
void oracleKerberosConfigFileIsCorrectlyMapped() {
522521
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
523522
.withPropertyValues("spring.flyway.oracle-kerberos-config-file=/tmp/config")
524-
.run(validateTeamsPropertyCorrectlyMapped("oracle.kerberosConfigFile"));
523+
.run(validateFlywayTeamsPropertyOnly("oracle.kerberosConfigFile"));
525524
}
526525

527526
@Test
528527
void outputQueryResultsIsCorrectlyMapped() {
529528
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
530529
.withPropertyValues("spring.flyway.output-query-results=false")
531-
.run(validateTeamsPropertyCorrectlyMapped("outputQueryResults"));
530+
.run(validateFlywayTeamsPropertyOnly("outputQueryResults"));
532531
}
533532

534533
@Test
535534
void skipExecutingMigrationsIsCorrectlyMapped() {
536535
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
537536
.withPropertyValues("spring.flyway.skip-executing-migrations=true")
538-
.run(validateTeamsPropertyCorrectlyMapped("skipExecutingMigrations"));
537+
.run(validateFlywayTeamsPropertyOnly("skipExecutingMigrations"));
539538
}
540539

541540
@Test
542541
void conjurUrlIsCorrectlyMapped() {
543542
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
544543
.withPropertyValues("spring.flyway.conjur-url=http://foo.com/secrets")
545-
.run(validateTeamsPropertyCorrectlyMapped("conjurUrl"));
544+
.run(validateFlywayTeamsPropertyOnly("conjurUrl"));
546545
}
547546

548547
@Test
549548
void conjurTokenIsCorrectlyMapped() {
550549
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
551550
.withPropertyValues("spring.flyway.conjur-token=5150")
552-
.run(validateTeamsPropertyCorrectlyMapped("conjurToken"));
551+
.run(validateFlywayTeamsPropertyOnly("conjurToken"));
553552
}
554553

555554
@Test
556555
void vaultUrlIsCorrectlyMapped() {
557556
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
558557
.withPropertyValues("spring.flyway.vault-url=http://foo.com/secrets")
559-
.run(validateTeamsPropertyCorrectlyMapped("vaultUrl"));
558+
.run(validateFlywayTeamsPropertyOnly("vaultUrl"));
560559
}
561560

562561
@Test
563562
void vaultTokenIsCorrectlyMapped() {
564563
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
565564
.withPropertyValues("spring.flyway.vault-token=5150")
566-
.run(validateTeamsPropertyCorrectlyMapped("vaultToken"));
565+
.run(validateFlywayTeamsPropertyOnly("vaultToken"));
567566
}
568567

569568
@Test
570569
void vaultSecretsIsCorrectlyMapped() {
571570
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
572-
.withPropertyValues("spring.flyway.vault-secrets=kv/test/1/config,kv/test/2/config")
573-
.run(validateTeamsPropertyCorrectlyMapped("vaultSecrets"));
571+
.withPropertyValues("spring.flyway.vault-secrets=kv/data/test/1/config,kv/data/test/2/config")
572+
.run(validateFlywayTeamsPropertyOnly("vaultSecrets"));
574573
}
575574

576575
@Test
@@ -600,7 +599,7 @@ void whenCustomFlywayIsDefinedThenJooqDslContextDependsOnIt() {
600599
});
601600
}
602601

603-
private ContextConsumer<AssertableApplicationContext> validateTeamsPropertyCorrectlyMapped(String propertyName) {
602+
private ContextConsumer<AssertableApplicationContext> validateFlywayTeamsPropertyOnly(String propertyName) {
604603
return (context) -> {
605604
assertThat(context).hasFailed();
606605
Throwable failure = context.getStartupFailure();

0 commit comments

Comments
 (0)