MCPcopy Create free account
hub / github.com/bytebase/bytebase / getQueryDataPolicy

Method getQueryDataPolicy

backend/store/policy.go:252–275  ·  view source on GitHub ↗
(ctx context.Context, workspaceID string, resource string)

Source from the content-addressed store, hash-verified

250}
251
252func (s *Store) getQueryDataPolicy(ctx context.Context, workspaceID string, resource string) (*storepb.QueryDataPolicy, error) {
253 resourceType, _, err := common.GetPolicyResourceTypeAndResource(resource)
254 if err != nil {
255 return nil, err
256 }
257 policy, err := s.GetPolicy(ctx, &FindPolicyMessage{
258 Workspace: workspaceID,
259 ResourceType: &resourceType,
260 Resource: &resource,
261 Type: new(storepb.Policy_QUERY_DATA),
262 })
263 if err != nil {
264 return nil, errors.Wrapf(err, "failed to get policy")
265 }
266 if policy == nil {
267 return &storepb.QueryDataPolicy{}, nil
268 }
269
270 p := &storepb.QueryDataPolicy{}
271 if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(policy.Payload), p); err != nil {
272 return nil, errors.Wrapf(err, "failed to unmarshal query data policy")
273 }
274 return p, nil
275}
276
277type reviewConfigResource struct {
278 resourceType storepb.Policy_Resource

Callers 1

Calls 3

GetPolicyMethod · 0.95
UnmarshalMethod · 0.80

Tested by

no test coverage detected