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
42 changes: 6 additions & 36 deletions apps/api/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@
"BooleanValue": {
"type": "boolean"
},
"CelSelector": {
"properties": {
"cel": {
"type": "string"
}
},
"required": [
"cel"
],
"type": "object"
},
"CreateDeploymentRequest": {
"properties": {
"description": {
Expand Down Expand Up @@ -812,7 +801,8 @@
"EnvironmentProgressionRule": {
"properties": {
"dependsOnEnvironmentSelector": {
"$ref": "#/components/schemas/Selector"
"description": "CEL expression to match the environment(s) that must have a successful release before this environment can proceed.",
"type": "string"
},
"maximumAgeHours": {
"description": "Maximum age of dependency deployment before blocking progression (prevents stale promotions)",
Expand Down Expand Up @@ -1237,18 +1227,6 @@
],
"type": "object"
},
"JsonSelector": {
"properties": {
"json": {
"additionalProperties": true,
"type": "object"
}
},
"required": [
"json"
],
"type": "object"
},
"LiteralValue": {
"oneOf": [
{
Expand Down Expand Up @@ -2005,16 +1983,6 @@
],
"type": "object"
},
"Selector": {
"oneOf": [
{
"$ref": "#/components/schemas/JsonSelector"
},
{
"$ref": "#/components/schemas/CelSelector"
}
]
},
"SensitiveValue": {
"properties": {
"valueHash": {
Expand Down Expand Up @@ -2836,7 +2804,8 @@
"type": "string"
},
"selector": {
"$ref": "#/components/schemas/Selector"
"description": "CEL expression to select which versions are eligible for deployment.",
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -3115,7 +3084,8 @@
"selector": {
"properties": {
"default": {
"$ref": "#/components/schemas/Selector"
"description": "CEL expression for the default selector.",
"type": "string"
},
"entityType": {
"enum": [
Expand Down
24 changes: 0 additions & 24 deletions apps/api/openapi/schemas/core.jsonnet
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
local openapi = import '../lib/openapi.libsonnet';

{
// Selector types
JsonSelector: {
type: 'object',
required: ['json'],
properties: {
json: { type: 'object', additionalProperties: true },
},
},

CelSelector: {
type: 'object',
required: ['cel'],
properties: {
cel: { type: 'string' },
},
},

Selector: {
oneOf: [
openapi.schemaRef('JsonSelector'),
openapi.schemaRef('CelSelector'),
],
},

// Property matcher
PropertyMatcher: {
type: 'object',
Expand Down
10 changes: 8 additions & 2 deletions apps/api/openapi/schemas/policies.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ local openapi = import '../lib/openapi.libsonnet';
type: 'object',
required: ['selector'],
properties: {
selector: openapi.schemaRef('Selector'),
selector: {
type: 'string',
description: 'CEL expression to select which versions are eligible for deployment.',
},
description: {
type: 'string',
description: 'Human-readable description of what this version selector does. Example: "Only deploy v2.x versions to staging environments"',
Expand All @@ -157,7 +160,10 @@ local openapi = import '../lib/openapi.libsonnet';
type: 'object',
required: ['dependsOnEnvironmentSelector'],
properties: {
dependsOnEnvironmentSelector: openapi.schemaRef('Selector'),
dependsOnEnvironmentSelector: {
type: 'string',
description: 'CEL expression to match the environment(s) that must have a successful release before this environment can proceed.',
},

minimumSuccessPercentage: { type: 'number', format: 'float', minimum: 0, maximum: 100, default: 100 },
successStatuses: { type: 'array', items: openapi.schemaRef('JobStatus') },
Expand Down
5 changes: 4 additions & 1 deletion apps/api/openapi/schemas/workflows.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ local openapi = import '../lib/openapi.libsonnet';
required: ['entityType'],
properties: {
entityType: { type: 'string', enum: ['resource', 'environment', 'deployment'] },
default: openapi.schemaRef('Selector'),
default: {
type: 'string',
description: 'CEL expression for the default selector.',
},
},
},
},
Expand Down
6 changes: 2 additions & 4 deletions apps/api/src/routes/v1/workspaces/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ const formatPolicy = (p: PolicyRow) => {
...p.environmentProgressionRules.map((r) =>
formatPolicyRule(r.id, r.policyId, r.createdAt, {
environmentProgression: {
dependsOnEnvironmentSelector: JSON.parse(
r.dependsOnEnvironmentSelector,
),
dependsOnEnvironmentSelector: r.dependsOnEnvironmentSelector,
...(r.maximumAgeHours != null && {
maximumAgeHours: r.maximumAgeHours,
}),
Expand Down Expand Up @@ -258,7 +256,7 @@ const formatPolicy = (p: PolicyRow) => {
...p.versionSelectorRules.map((r) =>
formatPolicyRule(r.id, r.policyId, r.createdAt, {
versionSelector: {
selector: JSON.parse(r.selector),
selector: r.selector,
...(r.description != null && { description: r.description }),
},
}),
Expand Down
10 changes: 4 additions & 6 deletions apps/api/src/routes/v1/workspaces/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,11 @@ const updateVariablesForResource: AsyncTypedHandler<
});
};

const parseSelector = (raw: string | null | undefined) => {
const parseSelector = (
raw: string | null | undefined,
): string | undefined => {
if (raw == null || raw === "false") return undefined;
try {
return JSON.parse(raw) as Record<string, unknown>;
} catch {
return { cel: raw };
}
return raw;
};

const getDeploymentsForResource: AsyncTypedHandler<
Expand Down
18 changes: 6 additions & 12 deletions apps/api/src/types/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -915,9 +915,6 @@ export interface components {
/** @enum {string} */
ApprovalStatus: "approved" | "rejected";
BooleanValue: boolean;
CelSelector: {
cel: string;
};
CreateDeploymentRequest: {
description?: string;
jobAgentConfig?: {
Expand Down Expand Up @@ -1198,7 +1195,8 @@ export interface components {
resourceSelector?: string;
};
EnvironmentProgressionRule: {
dependsOnEnvironmentSelector: components["schemas"]["Selector"];
/** @description CEL expression to match the environment(s) that must have a successful release before this environment can proceed. */
dependsOnEnvironmentSelector: string;
/**
* Format: int32
* @description Maximum age of dependency deployment before blocking progression (prevents stale promotions)
Expand Down Expand Up @@ -1351,11 +1349,6 @@ export interface components {
release: components["schemas"]["Release"];
resource?: components["schemas"]["Resource"];
};
JsonSelector: {
json: {
[key: string]: unknown;
};
};
LiteralValue: components["schemas"]["BooleanValue"] | components["schemas"]["NumberValue"] | components["schemas"]["IntegerValue"] | components["schemas"]["StringValue"] | components["schemas"]["ObjectValue"] | components["schemas"]["NullValue"];
MetricProvider: components["schemas"]["HTTPMetricProvider"] | components["schemas"]["SleepMetricProvider"] | components["schemas"]["DatadogMetricProvider"] | components["schemas"]["PrometheusMetricProvider"] | components["schemas"]["TerraformCloudRunMetricProvider"];
/** @enum {boolean} */
Expand Down Expand Up @@ -1622,7 +1615,6 @@ export interface components {
/** @description Job statuses that count toward the retry limit. If null or empty, defaults to ["failure", "invalidIntegration", "invalidJobAgent"] for maxRetries > 0, or ["failure", "invalidIntegration", "invalidJobAgent", "successful"] for maxRetries = 0. Cancelled and skipped jobs never count by default (allows redeployment after cancellation). Example: ["failure", "cancelled"] will only count failed/cancelled jobs. */
retryOnStatuses?: components["schemas"]["JobStatus"][];
};
Selector: components["schemas"]["JsonSelector"] | components["schemas"]["CelSelector"];
SensitiveValue: {
valueHash: string;
};
Expand Down Expand Up @@ -1926,7 +1918,8 @@ export interface components {
VersionSelectorRule: {
/** @description Human-readable description of what this version selector does. Example: "Only deploy v2.x versions to staging environments" */
description?: string;
selector: components["schemas"]["Selector"];
/** @description CEL expression to select which versions are eligible for deployment. */
selector: string;
};
Workflow: {
id: string;
Expand Down Expand Up @@ -2009,7 +2002,8 @@ export interface components {
WorkflowSelectorArrayInput: {
key: string;
selector: {
default?: components["schemas"]["Selector"];
/** @description CEL expression for the default selector. */
default?: string;
/** @enum {string} */
entityType: "resource" | "environment" | "deployment";
};
Expand Down
Loading
Loading