Skip to content

Commit

Permalink
avniproject/avni-webapp#1337 | Resolve issues with Remote Metabase AP…
Browse files Browse the repository at this point in the history
…I invocations with missing dbUser's password
  • Loading branch information
himeshr committed Dec 4, 2024
1 parent 6f8597b commit cbef3ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ public class DatabaseDetails {
private String port;
private String db;
private String user;
private String password;

public DatabaseDetails() {
}

public DatabaseDetails(String host, String port, String db, String user) {
public DatabaseDetails(String host, String port, String db, String user, String password) {
this.host = host;
this.port = port;
this.db = db;
this.user = user;
this.password = password;
}

public DatabaseDetails(AvniDatabase avniDatabase, String dbUser) {
this(avniDatabase.getAvniDatabaseServer(), avniDatabase.getAvniDatabasePort(), avniDatabase.getAvniDatabaseName(), dbUser);
public DatabaseDetails(AvniDatabase avniDatabase, String dbUser, String dbUserPassword) {
this(avniDatabase.getAvniDatabaseServer(), avniDatabase.getAvniDatabasePort(), avniDatabase.getAvniDatabaseName(), dbUser, dbUserPassword);
}

public String getHost() {
Expand All @@ -38,4 +40,8 @@ public String getDb() {
public String getUser() {
return user;
}

public String getPassword() {
return password;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@Service
public class MetabaseService {

public static final String ORG_DB_USER_PASSWORD = "password";
public static final String DB_ENGINE = "postgres";
private final OrganisationService organisationService;
private final AvniDatabase avniDatabase;
private final DatabaseRepository databaseRepository;
Expand Down Expand Up @@ -44,7 +46,7 @@ public void setupMetabase() {

globalDatabase = databaseRepository.getDatabaseByName(new Database(name));
if (globalDatabase == null) {
Database newDatabase = new Database(name, "postgres", new DatabaseDetails(avniDatabase, dbUser));
Database newDatabase = new Database(name, DB_ENGINE, new DatabaseDetails(avniDatabase, dbUser, ORG_DB_USER_PASSWORD));
globalDatabase = databaseRepository.save(newDatabase);
}

Expand Down

0 comments on commit cbef3ed

Please sign in to comment.