Skip to content

Commit

Permalink
refactor: minor touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
limwa committed Jul 15, 2024
1 parent 8df46a5 commit d54cdce
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
4 changes: 3 additions & 1 deletion services/pulumi/resources/mongodb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { replicateTo } from "../../utils/replicator";
import { CommitSignal, PendingValue } from "../../utils/pending";
import { DBUser, MongoDBCommunityControllerArgs } from "./types";

export const namespace = new k8s.core.v1.Namespace("mongodb-namespace", {
const namespace = new k8s.core.v1.Namespace("mongodb-namespace", {
metadata: {
name: "mongodb",
},
Expand Down Expand Up @@ -43,6 +43,7 @@ export class MongoDBCommunityController<
> extends pulumi.ComponentResource<void> {
private name;
private namespace;
public readonly dbs;

private users;

Expand All @@ -64,6 +65,7 @@ export class MongoDBCommunityController<

this.name = name;
this.namespace = args?.namespace ?? namespace.metadata.name;
this.dbs = args.dbs;

this.users = users;

Expand Down
6 changes: 2 additions & 4 deletions services/pulumi/services/databases/mongodb/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as pulumi from "@pulumi/pulumi";
import { MongoDBCommunityController } from "../../../resources/mongodb";

const appsDatabases = ["admin", "nimentas"] as const;

export const apps = new MongoDBCommunityController("mongodb-apps", {
dbs: appsDatabases,
dbs: ["admin", "nimentas"],
mdbc: {
metadata: {
name: "mongodb-apps",
Expand Down Expand Up @@ -51,7 +49,7 @@ apps.addUser({
name: "ni",
db: "admin",
password: config.requireSecret("mongodb/admin-password"),
roles: appsDatabases.map((db) => ({
roles: apps.dbs.map((db) => ({
name: "root",
db,
})),
Expand Down
7 changes: 4 additions & 3 deletions services/pulumi/services/ementas/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { labels, containerPort } from "./values";
import { apps } from "../databases/mongodb";

const config = new pulumi.Config();
const connectionStringSecretName = "ementas-mongodb-secret";

apps
.addUser({
Expand All @@ -18,7 +19,7 @@ apps
},
],
connectionStringSecretNamespace: namespace.metadata.name,
connectionStringSecretName: "ementas-mongodb-secret",
connectionStringSecretName,
});

export const website = new k8s.apps.v1.Deployment("ementas-website", {
Expand All @@ -38,7 +39,7 @@ export const website = new k8s.apps.v1.Deployment("ementas-website", {
spec: {
containers: [
{
name: "ementas-website",
name: "ementas-website-container",
image: "registry.niaefeup.pt/niaefeup/nimentas-sasup:main",
imagePullPolicy: "Always",
resources: {
Expand All @@ -57,7 +58,7 @@ export const website = new k8s.apps.v1.Deployment("ementas-website", {
name: "DATABASE_URL",
valueFrom: {
secretKeyRef: {
name: "ementas-mongodb-secret",
name: connectionStringSecretName,
key: "connectionString.standard",
},
},
Expand Down
2 changes: 1 addition & 1 deletion services/pulumi/services/ementas/values.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const host = "ementas.niaefeup.pt";

export const labels = { app: "ementas-website" };
export const containerPort = 3000;
export const containerPort = 3000;
2 changes: 0 additions & 2 deletions services/pulumi/sync-crds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,4 @@ crd_paths="$(download_crds "$SPEC_FILE" "crds/.tmp/")"

crd2pulumi -n ${crd_paths[@]}

# rm -rf crds/.tmp/

echo "CRDs synced successfully"

0 comments on commit d54cdce

Please sign in to comment.