(ctx context.Context, workspaceID string, activating bool)
| 397 | const instanceExceededError = "activation instance count has reached the limit (%v)" |
| 398 | |
| 399 | func (s *InstanceService) checkActivationLimit(ctx context.Context, workspaceID string, activating bool) error { |
| 400 | if !activating || s.licenseService.IsUnifiedInstanceLicense(ctx, workspaceID) { |
| 401 | return nil |
| 402 | } |
| 403 | activatedInstanceLimit := s.licenseService.GetActivatedInstanceLimit(ctx, workspaceID) |
| 404 | count, err := s.store.GetActivatedInstanceCount(ctx, workspaceID) |
| 405 | if err != nil { |
| 406 | return connect.NewError(connect.CodeInternal, err) |
| 407 | } |
| 408 | if count >= activatedInstanceLimit { |
| 409 | return connect.NewError(connect.CodeResourceExhausted, errors.Errorf(instanceExceededError, activatedInstanceLimit)) |
| 410 | } |
| 411 | return nil |
| 412 | } |
| 413 | |
| 414 | func (s *InstanceService) checkDataSource(ctx context.Context, instance *store.InstanceMessage, dataSource *storepb.DataSource) error { |
| 415 | if dataSource.GetId() == "" { |
no test coverage detected