Skip to content

Commit c919fe9

Browse files
authored
DN-3333 feature: Set up mongo (#13)
* DN-3333 Add mongo connection * DN-3333 chore: configure allowed origins * DN-3333 fix: connection string fix * fix: add examples * fix: oops * fix: enable TLS * fix: password env variable
1 parent 73027f2 commit c919fe9

File tree

12 files changed

+75
-18
lines changed

12 files changed

+75
-18
lines changed

Deployment/workflow-api-pr/templates/configmap-api.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,12 @@ metadata:
55
namespace: "{{ .Release.Namespace }}"
66
data:
77
DOTNET_ENVIRONMENT: "{{ .Values.environment }}"
8-
Serilog__MinimumLevel__Override__Uva.DataNose: "{{ .Values.logLevel }}"
8+
9+
Serilog__MinimumLevel__Override__Uva.DataNose: "{{ .Values.logLevel }}"
10+
11+
AllowedOrigins: "{{ .Values.allowedOrigins }}"
12+
13+
Mongo__Username: "{{ .Values.mongo.username }}"
14+
Mongo__Database: "{{ .Values.mongo.database }}"
15+
Mongo__Host: "{{ .Values.mongo.host }}"
16+
Mongo__Port: "{{ .Values.mongo.port }}"

Deployment/workflow-api-pr/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ spec:
2626
envFrom:
2727
- configMapRef:
2828
name: workflow-api-config
29-
{{/* - secretRef:*/}}
30-
{{/* name: workflow-api-secret*/}}
29+
- secretRef:
30+
name: workflow-api-secret
3131
{{- if .Values.azure }}
3232
volumeMounts:
3333
- name: secrets-store-inline

Deployment/workflow-api-pr/values.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,21 @@ environment: Test
88
contentSecurityPolicy: "default-src 'self'"
99
logLevel: Debug
1010

11-
connectionStrings:
11+
allowedOrigins: "http://localhost:5173"
12+
13+
mongo:
14+
username: username
15+
database: workflow
16+
host: host
17+
port: 27017
18+
19+
azure:
20+
keyvaultName: keyvaultName
21+
resourceGroup: resourceGroupName
22+
subscriptionId: subscriptionId
23+
tenantId: tenantId
24+
clientId: clientId
25+
identityName: identityName
26+
secrets:
27+
- name: workflow-db-password
28+
key: Mongo__Password

Deployment/workflow-api/templates/configmap.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ metadata:
55
namespace: "{{ .Release.Namespace }}"
66
data:
77
DOTNET_ENVIRONMENT: "{{ .Values.environment }}"
8-
APPLICATIONINSIGHTS_CONNECTION_STRING: "{{ .Values.connectionStrings.appInsights }}"
98

10-
Serilog__MinimumLevel__Override__Uva.DataNose: "{{ .Values.logLevel }}"
9+
Serilog__MinimumLevel__Override__Uva.DataNose: "{{ .Values.logLevel }}"
10+
11+
AllowedOrigins: "{{ .Values.allowedOrigins }}"
12+
13+
Mongo__Username: "{{ .Values.mongo.username }}"
14+
Mongo__Database: "{{ .Values.mongo.database }}"
15+
Mongo__Host: "{{ .Values.mongo.host }}"
16+
Mongo__Port: "{{ .Values.mongo.port }}"

Deployment/workflow-api/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ spec:
2626
envFrom:
2727
- configMapRef:
2828
name: workflow-api-config
29-
{{/* - secretRef:*/}}
30-
{{/* name: workflow-api-secret*/}}
29+
- secretRef:
30+
name: workflow-api-secret
3131
{{- if .Values.azure }}
3232
volumeMounts:
3333
- name: secrets-store-inline

Deployment/workflow-api/values.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,21 @@ environment: Test
77
contentSecurityPolicy: "default-src 'self'"
88
logLevel: Debug
99

10-
connectionStrings:
11-
appInsights: ""
10+
allowedOrigins: "http://localhost:5173"
11+
12+
mongo:
13+
username: username
14+
database: workflow
15+
host: host
16+
port: 27017
17+
18+
azure:
19+
keyvaultName: keyvaultName
20+
resourceGroup: resourceGroupName
21+
subscriptionId: subscriptionId
22+
tenantId: tenantId
23+
clientId: clientId
24+
identityName: identityName
25+
secrets:
26+
- name: workflow-db-password
27+
key: Mongo__Password

UvA.Workflow.Api/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ RUN dotnet publish "./UvA.Workflow.Api.csproj" -c $BUILD_CONFIGURATION -o /app/p
2020
FROM base AS final
2121
WORKDIR /app
2222
COPY --from=publish /app/publish .
23+
COPY Examples /Examples
2324
ENTRYPOINT ["dotnet", "UvA.Workflow.Api.dll"]

UvA.Workflow.Api/Infrastructure/ServiceCollectionExtentions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static IServiceCollection AddWorkflow(this IServiceCollection services, I
1717
{
1818
var options = provider.GetRequiredService<IOptions<MongoOptions>>().Value;
1919
var client = new MongoClient(options.ConnectionString);
20-
return client.GetDatabase(options.DatabaseName);
20+
return client.GetDatabase(options.Database);
2121
});
2222

2323
// Register repositories - organized by domain feature

UvA.Workflow.Api/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
var config = builder.Configuration;
2727
config.AddJsonFile("appsettings.local.json", true, true);
28+
2829
builder.Services.AddWorkflow(config);
2930
builder.Services.AddScoped<WorkflowInstanceDtoService>();
3031
builder.Services
@@ -39,7 +40,7 @@
3940
cb =>
4041
{
4142
cb.SetIsOriginAllowedToAllowWildcardSubdomains()
42-
.WithOrigins(config["AllowedOrigin"]!)
43+
.WithOrigins(config["AllowedOrigins"]!.Split(','))
4344
.AllowAnyMethod()
4445
.AllowCredentials()
4546
.AllowAnyHeader()

UvA.Workflow.Api/appsettings.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
},
88
"AllowedHosts": "*",
99
"Mongo": {
10-
"ConnectionString": "mongodb://admin:admin@localhost:27017/",
11-
"DatabaseName": "workflow"
10+
"Host": "localhost",
11+
"Port": 27017,
12+
"Username": "admin",
13+
"Password": "admin",
14+
"Database": "workflow"
1215
},
13-
"AllowedOrigin": "http://localhost:5174",
16+
"AllowedOrigins": "http://localhost:5173",
1417
"FileKey": "bEIaRcd3spsh08QfzyiiMnOnk1C5Qy6YNA21BmjIQ72nrY3CINbEIaRcd3spsh08QfzyiiMnOnk1C5Qy6YNA21BmjIQ72nrY3CIN"
1518
}

0 commit comments

Comments
 (0)