Skip to content

Commit

Permalink
refactor: rename list validate function
Browse files Browse the repository at this point in the history
  • Loading branch information
JadhavPoonam committed Nov 3, 2023
1 parent 82f7ad9 commit 1cf2c79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions agent/grpc-external/services/resource/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func (s *Server) WatchList(req *pbresource.WatchListRequest, stream pbresource.ResourceService_WatchListServer) error {
reg, err := s.validateWatchListRequest(req)
reg, err := s.ensureWatchListRequestValid(req)
if err != nil {
return err
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func (s *Server) WatchList(req *pbresource.WatchListRequest, stream pbresource.R
}
}

func (s *Server) validateWatchListRequest(req *pbresource.WatchListRequest) (*resource.Registration, error) {
func (s *Server) ensureWatchListRequestValid(req *pbresource.WatchListRequest) (*resource.Registration, error) {
if req.Type == nil {
return nil, status.Errorf(codes.InvalidArgument, "type is required")
}
Expand All @@ -104,7 +104,7 @@ func (s *Server) validateWatchListRequest(req *pbresource.WatchListRequest) (*re

// if no tenancy is passed defaults to wildcard
if req.Tenancy == nil {
req.Tenancy = getDefaultTenancy(reg.Scope)
req.Tenancy = wildcardTenancyFor(reg.Scope)
}

if err = checkV2Tenancy(s.UseV2Tenancy, req.Type); err != nil {
Expand All @@ -123,7 +123,7 @@ func (s *Server) validateWatchListRequest(req *pbresource.WatchListRequest) (*re
return reg, nil
}

func getDefaultTenancy(scope resource.Scope) *pbresource.Tenancy {
func wildcardTenancyFor(scope resource.Scope) *pbresource.Tenancy {
var defaultTenancy *pbresource.Tenancy

switch scope {
Expand Down
1 change: 0 additions & 1 deletion agent/grpc-external/services/resource/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ func TestWatchList_NoTenancy(t *testing.T) {
require.NoError(t, err)
rspCh := handleResourceStream(t, stream)

// Testcase will pick one of recordLabel or artist based on scope of type.
recordLabel, err := demo.GenerateV1RecordLabel("looney-tunes")
require.NoError(t, err)

Expand Down

0 comments on commit 1cf2c79

Please sign in to comment.