Skip to content

Commit

Permalink
Link Applications and Databases (#224)
Browse files Browse the repository at this point in the history
Companion PR for dbos-inc/dbos-cloud#145
  • Loading branch information
kraftp authored Dec 15, 2023
1 parent c6f1bbf commit caf2a1a
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 90 deletions.
62 changes: 0 additions & 62 deletions src/cloud-cli/applications/configure.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/cloud-cli/applications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export { listApps } from './list-apps';
export { deleteApp } from './delete-app';
export { deployAppCode } from './deploy-app-code';
export { getAppLogs } from './get-app-logs';
export { configureApp } from './configure'
export { updateApp } from './update-app';

3 changes: 1 addition & 2 deletions src/cloud-cli/applications/list-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export async function listApps(host: string, port: string): Promise<number> {
}
const formattedData: Application[] = []
for (const application of data) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
formattedData.push({ "Name": application.Name, "ID": application.ID, "Status": application.Status, "MaxVMs": application.MaxVMs });
formattedData.push({ "Name": application.Name, "ID": application.ID, "Version": application.Version, "DatabaseName": application.DatabaseName, "MaxVMs": application.MaxVMs });
}
console.log(JSON.stringify(formattedData));
return 0;
Expand Down
5 changes: 3 additions & 2 deletions src/cloud-cli/applications/register-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from "axios";
import { GlobalLogger } from "../../telemetry/logs";
import { getCloudCredentials } from "../utils";

export async function registerApp(appName: string, host: string, port: string, machines: number): Promise<number> {
export async function registerApp(appName: string, dbname: string, host: string, port: string, machines: number): Promise<number> {
const logger = new GlobalLogger();
const userCredentials = getCloudCredentials();
const bearerToken = "Bearer " + userCredentials.token;
Expand All @@ -12,7 +12,8 @@ export async function registerApp(appName: string, host: string, port: string, m
`http://${host}:${port}/${userCredentials.userName}/application`,
{
name: appName,
max_vms: machines
database: dbname,
max_vms: machines,
},
{
headers: {
Expand Down
3 changes: 2 additions & 1 deletion src/cloud-cli/applications/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type Application = {
Name: string;
ID: string;
Status: string;
DatabaseName: string;
Version: string;
MaxVMs: string;
};
2 changes: 1 addition & 1 deletion src/cloud-cli/applications/update-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function updateApp(appName: string, host: string, port: string, mac
);
const application: Application = update.data as Application;
logger.info(`Successfully updated: ${application.Name}`);
console.log(JSON.stringify({ "Name": application.Name, "ID": application.ID, "Status": application.Status, "MaxVMs": application.MaxVMs }));
console.log(JSON.stringify({ "Name": application.Name, "ID": application.ID, "Version": application.Version, "MaxVMs": application.MaxVMs }));
return 0;
} catch (e) {
if (axios.isAxiosError(e) && e.response) {
Expand Down
21 changes: 5 additions & 16 deletions src/cloud-cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
deleteApp,
deployAppCode,
getAppLogs,
configureApp,
} from "./applications/";
import { Command } from 'commander';
import { login } from "./login";
Expand Down Expand Up @@ -69,10 +68,11 @@ applicationCommands
.command('register')
.description('Register a new application')
.requiredOption('-n, --name <string>', 'Specify the app name')
.requiredOption('-d, --database <string>', 'Specify the app database name')
.option('-m, --machines <string>', 'Number of VMs to deploy', '1')
.action(async (options: { name: string, machines: string }) => {
.action(async (options: { name: string, database: string, machines: string }) => {
const { host, port }: { host: string, port: string } = applicationCommands.opts()
const exitCode = await registerApp(options.name, host, port, parseInt(options.machines));
const exitCode = await registerApp(options.name, options.database, host, port, parseInt(options.machines));
process.exit(exitCode);
});

Expand Down Expand Up @@ -126,17 +126,6 @@ applicationCommands
process.exit(exitCode);
});


applicationCommands
.command('configure')
.description('Configure an application to be deployed')
.option('-d, --dbname <string>', 'Specify the name of an already setup RDS user databases')
.action(async (options: { dbname: string }) => {
const { host, port }: { host: string, port: string } = applicationCommands.opts()
const exitCode = await configureApp(host, port, options.dbname);
process.exit(exitCode);
});

//////////////////////////////
/* USER DATABASE MANAGEMENT */
//////////////////////////////
Expand All @@ -150,8 +139,8 @@ const userdbCommands = program
userdbCommands
.command('create')
.argument('<string>', 'database name')
.option('-a, --admin <string>', 'Specify the admin user', 'postgres')
.option('-W, --password <string>', 'Specify the admin password', 'postgres')
.requiredOption('-a, --admin <string>', 'Specify the admin user')
.requiredOption('-W, --password <string>', 'Specify the admin password')
.option('-s, --sync', 'make synchronous call', true)
.action((async (dbname: string, options: { admin: string, password: string, sync: boolean }) => {
const { host, port }: { host: string, port: string } = userdbCommands.opts()
Expand Down
1 change: 0 additions & 1 deletion src/cloud-cli/userdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { UserDatabaseName } from "../user_database";

export interface UserDBInstance {
readonly DBName: string,
readonly UserID: string,
readonly Status: string,
readonly HostName: string,
readonly Port: number,
Expand Down
7 changes: 3 additions & 4 deletions src/dbos-runtime/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ export interface ConfigFile {
port: number;
username: string;
password?: string;
connectionTimeoutMillis: number;
connectionTimeoutMillis?: number;
user_database: string;
system_database: string;
system_database?: string;
ssl_ca?: string;
observability_database: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
observability_database?: string;
user_dbclient?: UserDatabaseName;
migrate?: string[];
rollback?: string[];
Expand Down

0 comments on commit caf2a1a

Please sign in to comment.