MCPcopy Index your code
hub / github.com/rilldata/rill / UpdateProjectVariables

Method UpdateProjectVariables

admin/projects.go:260–303  ·  view source on GitHub ↗

UpdateProjectVariables updates a project's variables and runs reconcile on the deployments.

(ctx context.Context, project *database.Project, environment string, vars map[string]string, unsetVars []string, userID string)

Source from the content-addressed store, hash-verified

258
259// UpdateProjectVariables updates a project's variables and runs reconcile on the deployments.
260func (s *Service) UpdateProjectVariables(ctx context.Context, project *database.Project, environment string, vars map[string]string, unsetVars []string, userID string) error {
261 if len(vars) == 0 && len(unsetVars) == 0 {
262 return nil
263 }
264 txCtx, tx, err := s.DB.NewTx(ctx, false)
265 if err != nil {
266 return err
267 }
268 defer func() {
269 _ = tx.Rollback()
270 }()
271
272 // Upsert variables
273 if len(vars) > 0 {
274 _, err = s.DB.UpsertProjectVariable(txCtx, project.ID, environment, vars, userID)
275 if err != nil {
276 return err
277 }
278 }
279
280 // Delete unset variables
281 if len(unsetVars) > 0 {
282 err = s.DB.DeleteProjectVariables(txCtx, project.ID, environment, unsetVars)
283 if err != nil {
284 return err
285 }
286 }
287
288 // Commit transaction
289 err = tx.Commit()
290 if err != nil {
291 return err
292 }
293
294 // Update deployments
295 s.Logger.Info("update project variables: updating deployments", observability.ZapCtx(ctx))
296
297 err = s.UpdateDeploymentsForProject(ctx, project)
298 if err != nil {
299 return err
300 }
301
302 return nil
303}
304
305// UpdateOrgDeploymentAnnotations iterates over projects of the given org and
306// updates annotations of corresponding deployments with the new organization name

Callers

nothing calls this directly

Calls 8

ZapCtxFunction · 0.92
InfoMethod · 0.80
NewTxMethod · 0.65
RollbackMethod · 0.65
UpsertProjectVariableMethod · 0.65
CommitMethod · 0.65

Tested by

no test coverage detected