Skip to content

Commit 777b493

Browse files
committed
fix: redis provider variables
1 parent 15771f3 commit 777b493

File tree

7 files changed

+29
-12
lines changed

7 files changed

+29
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Buttler automates CI/CD workflows using Docker and GitHub webhooks
3939
- [PostgreSQL](https://www.postgresql.org)
4040
- [MySQL](https://www.mysql.com) *(not implemented yet)*
4141
- [MongoDB](https://www.mongodb.com) *(not implemented yet)*
42-
- [Redis](https://redis.io) *(not implemented yet)*
42+
- [Redis](https://redis.io)
4343
- can be linked to other services ([see screenshots](#linking-services))
4444
- Services dashboard ([see screenshots](#list-of-services))
4545
- Edit service page ([see screenshots](#edit-service-page))

src/actions/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export async function start(serviceId: string, _: FormData) {
123123

124124
const image = await getServiceImage();
125125
const providerVariables = service.providers
126-
.map(provider => getProviderVariables(service.name, provider.name, provider.variables))
126+
.map(provider => getProviderVariables(service.name, provider.name, provider.repo, provider.variables))
127127
.reduce((bundle, current) => Object.assign(bundle, current), {});
128128
const containerId = await createContainer(
129129
kebabCase(service.name),

src/app/services/[id]/edit/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const EditServicePage = async ({
2626
if (!service) notFound();
2727

2828
const providerVariables = service.providers
29-
.map(provider => getProviderVariables(service.name, provider.name, provider.variables))
29+
.map(provider => getProviderVariables(service.name, provider.name, provider.repo, provider.variables))
3030
.reduce((bundle, current) => {
3131
Object.assign(bundle, current);
3232
return bundle;

src/core/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function startBuilding(service: ServiceDTO) {
2525
await removeContainer(service.containerId);
2626
await updateService(db, service.id, { status: "idle", containerId: null, imageId: null });
2727
const providerVariables = service.providers
28-
.map(provider => getProviderVariables(service.name, provider.name, provider.variables))
28+
.map(provider => getProviderVariables(service.name, provider.name, provider.repo, provider.variables))
2929
.reduce((bundle, current) => Object.assign(bundle, current), {});
3030
const containerId = await createContainer(
3131
kebabCase(service.name),

src/core/provider.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
import { kebabCase, snakeCase } from "change-case";
22

3-
export function getProviderVariables(serviceName: string, providerName: string, providerVariables: Record<string, string>) {
4-
return {
5-
POSTGRES_HOST: kebabCase(providerName),
6-
POSTGRES_PORT: "5432",
7-
POSTGRES_USER: "postgres",
8-
POSTGRES_PASSWORD: providerVariables.POSTGRES_PASSWORD,
9-
POSTGRES_DATABASE: snakeCase(serviceName),
10-
} as Record<string, string>;
3+
export function getProviderVariables(
4+
serviceName: string,
5+
providerName: string,
6+
providerType: string,
7+
providerVariables: Record<string, string>,
8+
): Record<string, string> {
9+
switch (providerType) {
10+
case "postgres":
11+
return {
12+
POSTGRES_HOST: kebabCase(providerName),
13+
POSTGRES_PORT: "5432",
14+
POSTGRES_USER: "postgres",
15+
POSTGRES_PASSWORD: providerVariables.POSTGRES_PASSWORD,
16+
POSTGRES_DATABASE: snakeCase(serviceName),
17+
};
18+
case "redis":
19+
return {
20+
REDIS_HOST: kebabCase(providerName),
21+
REDIS_PORT: "6379",
22+
};
23+
default:
24+
return {};
25+
}
1126
}

src/models/service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const baseSchema = createInsertSchema(services, {
1515
providers: z.object({
1616
id: z.string(),
1717
name: z.string(),
18+
repo: z.string(),
1819
networkIds: z.string().array(),
1920
variables: z.record(z.string(), z.string()),
2021
}).array(),

src/operations/getService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default async function getService(db: typeof database, serviceId: string)
3535
columns: {
3636
id: true,
3737
name: true,
38+
repo: true,
3839
},
3940
with: {
4041
networks: {

0 commit comments

Comments
 (0)