Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions apps/api/src/types/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ export interface components {
[key: string]: unknown;
};
jobAgentId?: string;
metadata?: {
[key: string]: string;
};
name: string;
resourceSelector?: components["schemas"]["Selector"];
slug: string;
Expand All @@ -839,6 +842,9 @@ export interface components {
};
CreateEnvironmentRequest: {
description?: string;
metadata?: {
[key: string]: string;
};
name: string;
resourceSelector?: components["schemas"]["Selector"];
systemId: string;
Expand Down Expand Up @@ -871,6 +877,9 @@ export interface components {
};
CreateSystemRequest: {
description?: string;
metadata?: {
[key: string]: string;
};
name: string;
};
CreateWorkspaceRequest: {
Expand Down Expand Up @@ -930,6 +939,9 @@ export interface components {
[key: string]: unknown;
};
jobAgentId?: string;
metadata: {
[key: string]: string;
};
name: string;
resourceSelector?: components["schemas"]["Selector"];
slug: string;
Expand Down Expand Up @@ -1007,6 +1019,9 @@ export interface components {
createdAt: string;
description?: string;
id: string;
metadata: {
[key: string]: string;
};
name: string;
resourceSelector?: components["schemas"]["Selector"];
systemId: string;
Expand Down Expand Up @@ -1346,6 +1361,9 @@ export interface components {
System: {
description?: string;
id: string;
metadata: {
[key: string]: string;
};
name: string;
slug: string;
workspaceId: string;
Expand Down Expand Up @@ -1400,6 +1418,9 @@ export interface components {
[key: string]: unknown;
};
jobAgentId?: string;
metadata?: {
[key: string]: string;
};
name: string;
resourceSelector?: components["schemas"]["Selector"];
slug: string;
Expand Down Expand Up @@ -1435,6 +1456,9 @@ export interface components {
};
UpsertEnvironmentRequest: {
description?: string;
metadata?: {
[key: string]: string;
};
name: string;
resourceSelector?: components["schemas"]["Selector"];
systemId: string;
Expand Down Expand Up @@ -1485,6 +1509,9 @@ export interface components {
};
UpsertSystemRequest: {
description?: string;
metadata?: {
[key: string]: string;
};
name: string;
};
UpsertUserApprovalRecordRequest: {
Expand Down
26 changes: 24 additions & 2 deletions apps/workspace-engine/oapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@
"name": {
"type": "string"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"resourceSelector": {
"$ref": "#/components/schemas/Selector"
},
Expand All @@ -192,6 +198,7 @@
"required": [
"id",
"name",
"metadata",
"slug",
"systemId",
"jobAgentConfig"
Expand Down Expand Up @@ -459,6 +466,7 @@
"required": [
"id",
"name",
"metadata",
"systemId",
"createdAt"
],
Expand Down Expand Up @@ -737,6 +745,12 @@
"name": {
"type": "string"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"type": {
"type": "string"
},
Expand All @@ -749,7 +763,8 @@
"workspaceId",
"name",
"type",
"config"
"config",
"metadata"
],
"type": "object"
},
Expand Down Expand Up @@ -1764,14 +1779,21 @@
"name": {
"type": "string"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"workspaceId": {
"type": "string"
}
},
"required": [
"id",
"workspaceId",
"name"
"name",
"metadata"
],
"type": "object"
},
Expand Down
6 changes: 5 additions & 1 deletion apps/workspace-engine/oapi/spec/schemas/deployments.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local openapi = import '../lib/openapi.libsonnet';
{
Deployment: {
type: 'object',
required: ['id', 'name', 'slug', 'systemId', 'jobAgentConfig'],
required: ['id', 'name', 'slug', 'systemId', 'jobAgentConfig', 'metadata'],
properties: {
id: { type: 'string' },
name: { type: 'string' },
Expand All @@ -13,6 +13,10 @@ local openapi = import '../lib/openapi.libsonnet';
jobAgentId: { type: 'string' },
jobAgentConfig: openapi.schemaRef('JobAgentConfig'),
resourceSelector: openapi.schemaRef('Selector'),
metadata: {
type: 'object',
additionalProperties: { type: 'string' },
},
},
},

Expand Down
18 changes: 15 additions & 3 deletions apps/workspace-engine/oapi/spec/schemas/entities.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,49 @@ local openapi = import '../lib/openapi.libsonnet';

Environment: {
type: 'object',
required: ['id', 'name', 'systemId', 'createdAt'],
required: ['id', 'name', 'systemId', 'createdAt', 'metadata'],
properties: {
id: { type: 'string' },
name: { type: 'string' },
description: { type: 'string' },
systemId: { type: 'string' },
resourceSelector: openapi.schemaRef('Selector'),
createdAt: { type: 'string', format: 'date-time' },
metadata: {
type: 'object',
additionalProperties: { type: 'string' },
},
},
},

System: {
type: 'object',
required: ['id', 'workspaceId', 'name'],
required: ['id', 'workspaceId', 'name', 'metadata'],
properties: {
id: { type: 'string' },
workspaceId: { type: 'string' },
name: { type: 'string' },
description: { type: 'string' },
metadata: {
type: 'object',
additionalProperties: { type: 'string' },
},
},
},

JobAgent: {
type: 'object',
required: ['id', 'workspaceId', 'name', 'type', 'config'],
required: ['id', 'workspaceId', 'name', 'type', 'config', 'metadata'],
properties: {
id: { type: 'string' },
workspaceId: { type: 'string' },
name: { type: 'string' },
type: { type: 'string' },
config: openapi.schemaRef('JobAgentConfig'),
metadata: {
type: 'object',
additionalProperties: { type: 'string' },
},
},
},

Expand Down
50 changes: 27 additions & 23 deletions apps/workspace-engine/pkg/oapi/oapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions apps/workspace-engine/pkg/selector/langs/cel/cel.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ func resourceToMap(r *oapi.Resource) map[string]any {
}

func deploymentToMap(d *oapi.Deployment) map[string]any {
m := make(map[string]any, 8)
m := make(map[string]any, 9)
m["id"] = d.Id
m["name"] = d.Name
m["slug"] = d.Slug
m["systemId"] = d.SystemId
m["jobAgentConfig"] = d.JobAgentConfig
m["metadata"] = d.Metadata
if d.Description != nil {
m["description"] = *d.Description
}
Expand All @@ -211,11 +212,12 @@ func deploymentToMap(d *oapi.Deployment) map[string]any {
}

func environmentToMap(e *oapi.Environment) map[string]any {
m := make(map[string]any, 6)
m := make(map[string]any, 7)
m["id"] = e.Id
m["name"] = e.Name
m["systemId"] = e.SystemId
m["createdAt"] = e.CreatedAt
m["metadata"] = e.Metadata
if e.Description != nil {
m["description"] = *e.Description
}
Expand Down
22 changes: 22 additions & 0 deletions apps/workspace-engine/pkg/workspace/relationships/property.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ func getDeploymentProperty(deployment *oapi.Deployment, propertyPath []string) (
return nil, err
}
return convertValue(value)
case "metadata":
if len(propertyPath) == 1 {
return convertValue(deployment.Metadata)
}
if len(propertyPath) == 2 {
if val, ok := deployment.Metadata[propertyPath[1]]; ok {
return convertValue(val)
}
return nil, fmt.Errorf("metadata key %s not found", propertyPath[1])
}
return nil, fmt.Errorf("metadata path too deep: %v", propertyPath)
default:
return getPropertyReflection(deployment, propertyPath)
}
Expand All @@ -149,6 +160,17 @@ func getEnvironmentProperty(environment *oapi.Environment, propertyPath []string
return nil, fmt.Errorf("description is nil")
case "system_id", "systemid":
return convertValue(environment.SystemId)
case "metadata":
if len(propertyPath) == 1 {
return convertValue(environment.Metadata)
}
if len(propertyPath) == 2 {
if val, ok := environment.Metadata[propertyPath[1]]; ok {
return convertValue(val)
}
return nil, fmt.Errorf("metadata key %s not found", propertyPath[1])
}
return nil, fmt.Errorf("metadata path too deep: %v", propertyPath)
default:
return getPropertyReflection(environment, propertyPath)
}
Expand Down
4 changes: 4 additions & 0 deletions apps/workspace-engine/pkg/workspace/store/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func (e *Deployments) Upsert(ctx context.Context, deployment *oapi.Deployment) e
_, span := deploymentsTracer.Start(ctx, "UpsertDeployment")
defer span.End()

if deployment.Metadata == nil {
deployment.Metadata = map[string]string{}
}

e.repo.Deployments.Set(deployment.Id, deployment)
e.store.changeset.RecordUpsert(deployment)

Expand Down
Loading
Loading