Skip to content
Merged
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
12,266 changes: 6,459 additions & 5,807 deletions apps/api/openapi/openapi.json

Large diffs are not rendered by default.

87 changes: 75 additions & 12 deletions apps/api/openapi/schemas/deployments.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ local openapi = import '../lib/openapi.libsonnet';
slug: { type: 'string' },
description: { type: 'string' },
jobAgentId: { type: 'string' },
jobAgentConfig: {
type: 'object',
additionalProperties: true,
},
jobAgentConfig: openapi.schemaRef('DeploymentJobAgentConfig'),
resourceSelector: openapi.schemaRef('Selector'),
},
},
Expand All @@ -26,10 +23,7 @@ local openapi = import '../lib/openapi.libsonnet';
slug: { type: 'string' },
description: { type: 'string' },
jobAgentId: { type: 'string' },
jobAgentConfig: {
type: 'object',
additionalProperties: true,
},
jobAgentConfig: openapi.schemaRef('DeploymentJobAgentConfig'),
resourceSelector: openapi.schemaRef('Selector'),
},
},
Expand All @@ -43,13 +37,82 @@ local openapi = import '../lib/openapi.libsonnet';
description: { type: 'string' },
systemId: { type: 'string' },
jobAgentId: { type: 'string' },
jobAgentConfig: {
type: 'object',
additionalProperties: true,
},
jobAgentConfig: openapi.schemaRef('DeploymentJobAgentConfig'),
resourceSelector: openapi.schemaRef('Selector'),
},
},

DeploymentJobAgentConfig: {
oneOf: [
openapi.schemaRef('DeploymentGithubJobAgentConfig'),
openapi.schemaRef('DeploymentArgoCDJobAgentConfig'),
openapi.schemaRef('DeploymentTerraformCloudJobAgentConfig'),
openapi.schemaRef('DeploymentCustomJobAgentConfig'),
],
discriminator: {
propertyName: 'type',
mapping: {
'github-app': '#/components/schemas/DeploymentGithubJobAgentConfig',
'argo-cd': '#/components/schemas/DeploymentArgoCDJobAgentConfig',
tfe: '#/components/schemas/DeploymentTerraformCloudJobAgentConfig',
custom: '#/components/schemas/DeploymentCustomJobAgentConfig',
},
},
},

DeploymentGithubJobAgentConfig: {
type: 'object',
required: ['type', 'repo', 'workflowId'],
properties: {
type: {
type: 'string',
enum: ['github-app'],
description: 'Deployment job agent type discriminator.',
},
repo: { type: 'string', description: 'GitHub repository name.' },
workflowId: { type: 'integer', format: 'int64', description: 'GitHub Actions workflow ID.' },
ref: { type: 'string', description: 'Git ref to run the workflow on (defaults to "main" if omitted).' },
},
},

DeploymentArgoCDJobAgentConfig: {
type: 'object',
required: ['type', 'template'],
properties: {
type: {
type: 'string',
enum: ['argo-cd'],
description: 'Deployment job agent type discriminator.',
},
template: { type: 'string', description: 'ArgoCD Application YAML/JSON template (supports Go templates).' },
},
},

DeploymentTerraformCloudJobAgentConfig: {
type: 'object',
required: ['type', 'template'],
properties: {
type: {
type: 'string',
enum: ['tfe'],
description: 'Deployment job agent type discriminator.',
},
template: { type: 'string', description: 'Terraform Cloud workspace template (YAML/JSON; supports Go templates).' },
},
},

DeploymentCustomJobAgentConfig: {
type: 'object',
required: ['type'],
properties: {
type: {
type: 'string',
enum: ['custom'],
description: 'Deployment job agent type discriminator.',
},
},
additionalProperties: true,
},
DeploymentAndSystem: {
type: 'object',
required: ['deployment', 'system'],
Expand Down
99 changes: 96 additions & 3 deletions apps/api/openapi/schemas/job-agents.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ local openapi = import '../lib/openapi.libsonnet';
{
UpsertJobAgentRequest: {
type: 'object',
required: ['name', 'type'],
required: ['name', 'type', 'config'],
properties: {
name: { type: 'string' },
type: { type: 'string' },
metadata: {
type: 'object',
additionalProperties: { type: 'string' }
},
config: { type: 'object', additionalProperties: true },
config: openapi.schemaRef('JobAgentConfig'),
},
},
JobAgent: {
Expand All @@ -21,11 +21,104 @@ local openapi = import '../lib/openapi.libsonnet';
id: { type: 'string' },
name: { type: 'string' },
type: { type: 'string' },
config: { type: 'object', additionalProperties: true },
config: openapi.schemaRef('JobAgentConfig'),
metadata: {
type: 'object',
additionalProperties: { type: 'string' }
},
},
},

JobAgentConfig: {
oneOf: [
openapi.schemaRef('GithubJobAgentConfig'),
openapi.schemaRef('ArgoCDJobAgentConfig'),
openapi.schemaRef('TerraformCloudJobAgentConfig'),
openapi.schemaRef('TestRunnerJobAgentConfig'),
openapi.schemaRef('CustomJobAgentConfig'),
],
discriminator: {
propertyName: 'type',
mapping: {
'github-app': '#/components/schemas/GithubJobAgentConfig',
'argo-cd': '#/components/schemas/ArgoCDJobAgentConfig',
tfe: '#/components/schemas/TerraformCloudJobAgentConfig',
'test-runner': '#/components/schemas/TestRunnerJobAgentConfig',
custom: '#/components/schemas/CustomJobAgentConfig',
},
},
},

GithubJobAgentConfig: {
type: 'object',
required: ['type', 'installationId', 'owner'],
properties: {
type: {
type: 'string',
enum: ['github-app'],
description: 'Job agent type discriminator.',
},
installationId: { type: 'integer', format: 'int' },
owner: { type: 'string' },
},
},

ArgoCDJobAgentConfig: {
type: 'object',
required: ['type', 'serverUrl', 'apiKey'],
properties: {
type: {
type: 'string',
enum: ['argo-cd'],
description: 'Job agent type discriminator.',
},
serverUrl: { type: 'string', description: 'ArgoCD server address (host[:port] or URL).' },
apiKey: { type: 'string', description: 'ArgoCD API token.' },
},
},

TerraformCloudJobAgentConfig: {
type: 'object',
required: ['type', 'address', 'token', 'organization'],
properties: {
type: {
type: 'string',
enum: ['tfe'],
description: 'Job agent type discriminator.',
},
organization: { type: 'string', description: 'Terraform Cloud organization name.' },
address: { type: 'string', description: 'Terraform Cloud address (e.g. https://app.terraform.io).' },
token: { type: 'string', description: 'Terraform Cloud API token.' },
template: { type: 'string', description: 'Terraform Cloud workspace template (YAML/JSON; supports Go templates).' },
},
additionalProperties: true,
},

TestRunnerJobAgentConfig: {
type: 'object',
required: ['type'],
properties: {
type: {
type: 'string',
enum: ['test-runner'],
description: 'Job agent type discriminator.',
},
delaySeconds: { type: 'integer', format: 'int', description: 'Delay before resolving the job.' },
status: { type: 'string', enum: ['completed', 'failure'], description: 'Final status to set.' },
message: { type: 'string', description: 'Optional message to include in the job output.' },
},
},

CustomJobAgentConfig: {
type: 'object',
required: ['type'],
properties: {
type: {
type: 'string',
enum: ['custom'],
description: 'Job agent type discriminator.',
},
},
additionalProperties: true,
},
}
58 changes: 54 additions & 4 deletions apps/api/openapi/schemas/jobs.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ local Job = {
id: { type: 'string' },
releaseId: { type: 'string' },
jobAgentId: { type: 'string' },
jobAgentConfig: {
type: 'object',
additionalProperties: true,
},
jobAgentConfig: openapi.schemaRef('FullJobAgentConfig'),
externalId: { type: 'string' },
status: openapi.schemaRef('JobStatus'),
createdAt: { type: 'string', format: 'date-time' },
Expand Down Expand Up @@ -81,4 +78,57 @@ local JobPropertyKeys = std.objectFields(Job.properties);
{ required: ['agentId', 'externalId'] },
],
},

FullJobAgentConfig: {
oneOf: [
openapi.schemaRef('FullGithubJobAgentConfig'),
openapi.schemaRef('FullArgoCDJobAgentConfig'),
openapi.schemaRef('FullTerraformCloudJobAgentConfig'),
openapi.schemaRef('FullTestRunnerJobAgentConfig'),
openapi.schemaRef('FullCustomJobAgentConfig'),
],
discriminator: {
propertyName: 'type',
mapping: {
'github-app': '#/components/schemas/FullGithubJobAgentConfig',
'argo-cd': '#/components/schemas/FullArgoCDJobAgentConfig',
tfe: '#/components/schemas/FullTerraformCloudJobAgentConfig',
'test-runner': '#/components/schemas/FullTestRunnerJobAgentConfig',
custom: '#/components/schemas/FullCustomJobAgentConfig',
},
},
},

FullGithubJobAgentConfig: {
allOf: [
openapi.schemaRef('GithubJobAgentConfig'),
openapi.schemaRef('DeploymentGithubJobAgentConfig'),
],
},

FullArgoCDJobAgentConfig: {
allOf: [
openapi.schemaRef('ArgoCDJobAgentConfig'),
openapi.schemaRef('DeploymentArgoCDJobAgentConfig'),
],
},

FullTerraformCloudJobAgentConfig: {
allOf: [
openapi.schemaRef('TerraformCloudJobAgentConfig'),
openapi.schemaRef('DeploymentTerraformCloudJobAgentConfig'),
],
},

FullTestRunnerJobAgentConfig: {
allOf: [
openapi.schemaRef('TestRunnerJobAgentConfig'),
],
},

FullCustomJobAgentConfig: {
allOf: [
openapi.schemaRef('CustomJobAgentConfig'),
],
},
}
4 changes: 2 additions & 2 deletions apps/api/src/routes/v1/workspaces/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const deleteDeployment: AsyncTypedHandler<
name: "",
systemId: "",
slug: "",
jobAgentConfig: {},
jobAgentConfig: { type: "custom" },
},
});

Expand All @@ -98,7 +98,7 @@ const postDeployment: AsyncTypedHandler<
const deployment: WorkspaceEngine["schemas"]["Deployment"] = {
id: uuidv4(),
...body,
jobAgentConfig: body.jobAgentConfig ?? {},
jobAgentConfig: body.jobAgentConfig ?? { type: "custom" },
};

const isValid = await validResourceSelector(body.resourceSelector);
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/workspaces/job-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const upsertJobAgent: AsyncTypedHandler<
name: body.name,
type: body.type,
workspaceId,
config: body.config ?? {},
config: body.config,
metadata: body.metadata ?? {},
};

Expand Down
Loading
Loading