MCPcopy Create free account
hub / github.com/clouditor/clouditor / cacheControls

Method cacheControls

service/evaluation/evaluation.go:845–878  ·  view source on GitHub ↗

cacheControls caches the catalog controls for the given catalog.

(catalogId string)

Source from the content-addressed store, hash-verified

843
844// cacheControls caches the catalog controls for the given catalog.
845func (svc *Service) cacheControls(catalogId string) error {
846 var (
847 err error
848 tag string
849 controls []*orchestrator.Control
850 )
851
852 if catalogId == "" {
853 return ErrCatalogIdIsMissing
854 }
855
856 // Get controls for given catalog
857 controls, err = api.ListAllPaginated[*orchestrator.ListControlsResponse](&orchestrator.ListControlsRequest{
858 CatalogId: catalogId,
859 }, svc.orchestrator.Client.ListControls, func(res *orchestrator.ListControlsResponse) []*orchestrator.Control {
860 return res.Controls
861 })
862 if err != nil {
863 return err
864 }
865
866 if len(controls) == 0 {
867 return fmt.Errorf("no controls for catalog '%s' available", catalogId)
868 }
869
870 // Store controls in map
871 svc.catalogControls[catalogId] = make(map[string]*orchestrator.Control)
872 for _, control := range controls {
873 tag = fmt.Sprintf("%s-%s", control.GetCategoryName(), control.GetId())
874 svc.catalogControls[catalogId][tag] = control
875 }
876
877 return nil
878}
879
880// getControl returns the control for the given catalogID, CategoryName and controlID.
881func (svc *Service) getControl(catalogId, categoryName, controlId string) (control *orchestrator.Control, err error) {

Callers 2

StartEvaluationMethod · 0.95

Implementers 5

Serviceservice/assessment/assessment.go
Serviceservice/discovery/discovery.go
Serviceservice/evidence/evidence_store.go
Serviceservice/evaluation/evaluation.go
Serviceservice/orchestrator/orchestrator.go

Calls 4

ListAllPaginatedFunction · 0.92
ErrorfMethod · 0.80
GetIdMethod · 0.65
GetCategoryNameMethod · 0.45

Tested by 1