Skip to content

Commit

Permalink
fix implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Dec 15, 2023
1 parent aee4423 commit 92dc7c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion policy/cnspec_policy.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions policy/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ func (s *LocalServices) GetPolicy(ctx context.Context, in *Mrn) (*Policy, error)

// GetBundle retrieves the given policy and all its dependencies (policies/queries)
func (s *LocalServices) GetBundle(ctx context.Context, in *Mrn) (*Bundle, error) {
// TODO: once the backend implements GetBundleForMrn, we can remove this implementation
// and directly call GetBundleForMrn
// TODO: once the backend implements GetBundleV2, we can remove this implementation
// and directly call GetBundleV2
if in == nil || len(in.Mrn) == 0 {
return nil, status.Error(codes.InvalidArgument, "policy mrn is required")
}
Expand All @@ -293,7 +293,7 @@ func (s *LocalServices) GetBundle(ctx context.Context, in *Mrn) (*Bundle, error)
return s.cacheUpstreamPolicyOld(ctx, in.Mrn)
}

func (s *LocalServices) GetBundleForMrn(ctx context.Context, in *BundleReq) (*Bundle, error) {
func (s *LocalServices) GetBundleV2(ctx context.Context, in *BundleReq) (*Bundle, error) {
if in == nil || len(in.Mrn) == 0 {
return nil, status.Error(codes.InvalidArgument, "policy mrn is required")
}
Expand Down Expand Up @@ -569,7 +569,7 @@ func (s *LocalServices) cacheUpstreamPolicy(ctx context.Context, in *BundleReq)
}

logCtx.Debug().Str("policy", mrn).Msg("marketplace> fetch policy bundle from upstream")
bundle, err := s.Upstream.GetBundleForMrn(ctx, in)
bundle, err := s.Upstream.GetBundleV2(ctx, in)
if err != nil {
logCtx.Error().Err(err).Str("policy", mrn).Msg("marketplace> failed to retrieve policy bundle from upstream")
return nil, errors.New("failed to retrieve upstream policy " + mrn + ": " + err.Error())
Expand All @@ -587,7 +587,7 @@ func (s *LocalServices) cacheUpstreamPolicy(ctx context.Context, in *BundleReq)
return bundle, nil
}

// TODO: this can be removed once the backend implements GetBundleForMrn
// TODO: this can be removed once the backend implements GetBundleV2
func (s *LocalServices) cacheUpstreamPolicyOld(ctx context.Context, mrn string) (*Bundle, error) {
logCtx := logger.FromContext(ctx)
if s.Upstream == nil {
Expand Down

0 comments on commit 92dc7c5

Please sign in to comment.