SetFileStore sets the file store module
(ctx context.Context, project string, value *config.FileStoreConfig, params model.RequestParams)
| 13 | |
| 14 | // SetFileStore sets the file store module |
| 15 | func (s *Manager) SetFileStore(ctx context.Context, project string, value *config.FileStoreConfig, params model.RequestParams) (int, error) { |
| 16 | // Check if the request has been hijacked |
| 17 | hookResponse := s.integrationMan.InvokeHook(ctx, params) |
| 18 | if hookResponse.CheckResponse() { |
| 19 | // Check if an error occurred |
| 20 | if err := hookResponse.Error(); err != nil { |
| 21 | return hookResponse.Status(), err |
| 22 | } |
| 23 | |
| 24 | // Gracefully return |
| 25 | return hookResponse.Status(), nil |
| 26 | } |
| 27 | |
| 28 | // Acquire a lock |
| 29 | s.lock.Lock() |
| 30 | defer s.lock.Unlock() |
| 31 | |
| 32 | projectConfig, err := s.getConfigWithoutLock(ctx, project) |
| 33 | if err != nil { |
| 34 | return http.StatusBadRequest, err |
| 35 | } |
| 36 | |
| 37 | projectConfig.FileStoreConfig = value |
| 38 | |
| 39 | if err := s.modules.SetFileStoreConfig(ctx, project, projectConfig.FileStoreConfig); err != nil { |
| 40 | return http.StatusInternalServerError, helpers.Logger.LogError(helpers.GetRequestID(ctx), "error setting file store config", err, nil) |
| 41 | } |
| 42 | |
| 43 | resourceID := config.GenerateResourceID(s.clusterID, project, config.ResourceFileStoreConfig, "filestore") |
| 44 | if err := s.store.SetResource(ctx, resourceID, value); err != nil { |
| 45 | return http.StatusInternalServerError, err |
| 46 | } |
| 47 | |
| 48 | return http.StatusOK, nil |
| 49 | } |
| 50 | |
| 51 | // SetFileRule sets the rule for file store |
| 52 | func (s *Manager) SetFileRule(ctx context.Context, project, id string, value *config.FileRule, params model.RequestParams) (int, error) { |