@@ -73,12 +73,6 @@ const upsertDeploymentVariable: AsyncTypedHandler<
7373 const { workspaceId, deploymentId, variableId } = req . params ;
7474 const { body } = req ;
7575
76- // Verify deployment exists
77- const deploymentResponse = await verifyDeploymentExists (
78- workspaceId ,
79- deploymentId ,
80- ) ;
81-
8276 // Transform request body to workspace-engine schema
8377 const deploymentVariable : WorkspaceEngine [ "schemas" ] [ "DeploymentVariable" ] = {
8478 id : variableId ,
@@ -88,15 +82,9 @@ const upsertDeploymentVariable: AsyncTypedHandler<
8882 defaultValue : body . defaultValue ?? undefined ,
8983 } ;
9084
91- // Check if variable already exists to determine create vs update
92- const variables = deploymentResponse . variables ;
93- const exists = variables . some ( ( v ) => v . variable . id === variableId ) ;
94-
9585 await sendGoEvent ( {
9686 workspaceId,
97- eventType : exists
98- ? Event . DeploymentVariableUpdated
99- : Event . DeploymentVariableCreated ,
87+ eventType : Event . DeploymentVariableUpdated ,
10088 timestamp : Date . now ( ) ,
10189 data : deploymentVariable ,
10290 } ) ;
@@ -192,22 +180,9 @@ const upsertDeploymentVariableValue: AsyncTypedHandler<
192180 "/v1/workspaces/{workspaceId}/deployments/{deploymentId}/variables/{variableId}/values/{valueId}" ,
193181 "put"
194182> = async ( req , res ) => {
195- const { workspaceId, deploymentId , variableId, valueId } = req . params ;
183+ const { workspaceId, variableId, valueId } = req . params ;
196184 const { body } = req ;
197185
198- // Verify deployment and variable exist
199- const deploymentResponse = await verifyDeploymentExists (
200- workspaceId ,
201- deploymentId ,
202- ) ;
203-
204- const variables = deploymentResponse . variables ;
205- const variable = variables . find ( ( v ) => v . variable . id === variableId ) ;
206-
207- if ( ! variable ) {
208- throw new ApiError ( "Deployment variable not found" , 404 ) ;
209- }
210-
211186 // Validate resource selector if provided
212187 if ( body . resourceSelector != null ) {
213188 const isValid = await validResourceSelector ( body . resourceSelector ) ;
@@ -226,25 +201,12 @@ const upsertDeploymentVariableValue: AsyncTypedHandler<
226201 value : body . value ,
227202 } ;
228203
229- // Check if value already exists
230- const exists = variable . values . some ( ( v ) => v . id === valueId ) ;
231-
232- // Send Go event (workspace-engine consumes these events)
233- if ( exists ) {
234- await sendGoEvent ( {
235- workspaceId,
236- eventType : Event . DeploymentVariableValueUpdated ,
237- timestamp : Date . now ( ) ,
238- data : deploymentVariableValue ,
239- } ) ;
240- } else {
241- await sendGoEvent ( {
242- workspaceId,
243- eventType : Event . DeploymentVariableValueCreated ,
244- timestamp : Date . now ( ) ,
245- data : deploymentVariableValue ,
246- } ) ;
247- }
204+ await sendGoEvent ( {
205+ workspaceId,
206+ eventType : Event . DeploymentVariableValueUpdated ,
207+ timestamp : Date . now ( ) ,
208+ data : deploymentVariableValue ,
209+ } ) ;
248210
249211 res . status ( 204 ) . end ( ) ;
250212} ;
0 commit comments