-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from DataBiosphere/ps/fix-stairctl
PF-3004: Fix stairctl so it runs again, other updates
- Loading branch information
Showing
17 changed files
with
268 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,6 @@ pom.xml | |
|
||
### Jenv directory-local version setting | ||
.java-version | ||
|
||
### Spring Shell | ||
spring-shell.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 10 additions & 58 deletions
68
stairctl/src/main/java/bio/terra/stairctl/ConnectParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,23 @@ | ||
package bio.terra.stairctl; | ||
|
||
import java.util.Optional; | ||
import java.util.Objects; | ||
|
||
// Container for DB connection parameters. It provides defaulting from another instance | ||
// of ConnectParams so that we can easily apply the incoming configuration. | ||
public class ConnectParams { | ||
private String username; | ||
private String password; | ||
private String host; | ||
private String port; | ||
private String dbname; | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public ConnectParams username(String username) { | ||
this.username = username; | ||
return this; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public ConnectParams password(String password) { | ||
this.password = password; | ||
return this; | ||
} | ||
|
||
public String getHost() { | ||
return host; | ||
} | ||
|
||
public ConnectParams host(String host) { | ||
this.host = host; | ||
return this; | ||
} | ||
|
||
public String getPort() { | ||
return port; | ||
} | ||
|
||
public ConnectParams port(String port) { | ||
this.port = port; | ||
return this; | ||
} | ||
|
||
public String getDbname() { | ||
return dbname; | ||
} | ||
|
||
public ConnectParams dbname(String dbname) { | ||
this.dbname = dbname; | ||
return this; | ||
} | ||
public record ConnectParams( | ||
String username, String password, String host, String port, String dbname) { | ||
|
||
public String makeUri() { | ||
return String.format("jdbc:postgresql://%s:%s/%s", host, port, dbname); | ||
} | ||
|
||
// Fill in any null parameters with those from the provided defaults | ||
public void applyDefaults(ConnectParams defaults) { | ||
username = Optional.ofNullable(username).orElse(defaults.getUsername()); | ||
password = Optional.ofNullable(password).orElse(defaults.getPassword()); | ||
host = Optional.ofNullable(host).orElse(defaults.getHost()); | ||
port = Optional.ofNullable(port).orElse(defaults.getPort()); | ||
dbname = Optional.ofNullable(dbname).orElse(defaults.getDbname()); | ||
public ConnectParams withDefaults(ConnectParams defaults) { | ||
return new ConnectParams( | ||
Objects.requireNonNullElseGet(username, defaults::username), | ||
Objects.requireNonNullElseGet(password, defaults::password), | ||
Objects.requireNonNullElseGet(host, defaults::host), | ||
Objects.requireNonNullElseGet(port, defaults::port), | ||
Objects.requireNonNullElseGet(dbname, defaults::dbname)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.