MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / UpdateInfo

Method UpdateInfo

service/cluster/cluster.go:239–270  ·  view source on GitHub ↗
(ctx context.Context, id string, name *string, resume *string)

Source from the content-addressed store, hash-verified

237
238}
239func (s *imlClusterService) UpdateInfo(ctx context.Context, id string, name *string, resume *string) (c *Cluster, errOut error) {
240 operator := utils.UserId(ctx)
241 if name == nil && resume == nil {
242 return nil, errors.New("no update")
243 }
244 errOut = s.store.Transaction(ctx, func(ctx context.Context) error {
245 v, err := s.store.FirstQuery(ctx, "`uuid` = ?", []interface{}{id}, "id desc")
246 if err != nil {
247 return err
248 }
249 if name != nil {
250 v.Name = *name
251 }
252 if resume != nil {
253 v.Resume = *resume
254 }
255 v.Updater = operator
256 v.UpdateAt = time.Now()
257 upCount, err := s.store.Update(ctx, v)
258 if err != nil {
259 return err
260 }
261 if upCount == 0 {
262 return errors.New("no update")
263 }
264 c = FromEntity(v)
265 return nil
266 })
267
268 return
269
270}
271
272func (s *imlClusterService) UpdateAddress(ctx context.Context, id string, address string) ([]*Node, error) {
273

Callers

nothing calls this directly

Calls 2

FromEntityFunction · 0.70
UpdateMethod · 0.65

Tested by

no test coverage detected