MCPcopy
hub / github.com/spacecloud-io/space-cloud / SetFileStore

Method SetFileStore

gateway/managers/syncman/syncman_file.go:15–49  ·  view source on GitHub ↗

SetFileStore sets the file store module

(ctx context.Context, project string, value *config.FileStoreConfig, params model.RequestParams)

Source from the content-addressed store, hash-verified

13
14// SetFileStore sets the file store module
15func (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
52func (s *Manager) SetFileRule(ctx context.Context, project, id string, value *config.FileRule, params model.RequestParams) (int, error) {

Callers 2

TestManager_SetFileStoreFunction · 0.80
HandleSetFileStoreFunction · 0.80

Calls 9

getConfigWithoutLockMethod · 0.95
InvokeHookMethod · 0.65
CheckResponseMethod · 0.65
ErrorMethod · 0.65
StatusMethod · 0.65
SetFileStoreConfigMethod · 0.65
SetResourceMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 1

TestManager_SetFileStoreFunction · 0.64