Skip to content

Commit

Permalink
Rename EntityWithProperties to EntityWithPropertiesByID
Browse files Browse the repository at this point in the history
We're about to add a different `EntityWithPropertiesByUpstreamID` so
let's make the names more descriptive.
  • Loading branch information
jhrozek committed Sep 19, 2024
1 parent 83874e3 commit 7e9c9d7
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion internal/controlplane/handlers_evalstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (s *Server) sortEntitiesEvaluationStatus(
continue
}

efp, err := s.props.EntityWithProperties(ctx, e.EntityID, nil)
efp, err := s.props.EntityWithPropertiesByID(ctx, e.EntityID, nil)
if err != nil {
if errors.Is(err, propSvc.ErrEntityNotFound) {
// If the entity is not found, log and skip
Expand Down
2 changes: 1 addition & 1 deletion internal/controlplane/handlers_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func (s *Server) getRuleEvalStatus(

// the caller just ignores allt the errors anyway, so we don't start a transaction as the integrity issues
// would not be discovered anyway
efp, err := s.props.EntityWithProperties(ctx, dbRuleEvalStat.EntityID, nil)
efp, err := s.props.EntityWithPropertiesByID(ctx, dbRuleEvalStat.EntityID, nil)
if err != nil {
return nil, fmt.Errorf("error fetching entity for properties: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controlplane/handlers_providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ func TestDeleteProvider(t *testing.T) {

mockprops := propSvc.NewMockPropertiesService(ctrl)
mockprops.EXPECT().
EntityWithProperties(gomock.Any(), gomock.Any(), nil).
EntityWithPropertiesByID(gomock.Any(), gomock.Any(), nil).
Return(models.NewEntityWithPropertiesFromInstance(
models.EntityInstance{}, nil), nil)

Expand Down Expand Up @@ -649,7 +649,7 @@ func TestDeleteProviderByID(t *testing.T) {

mockprops := propSvc.NewMockPropertiesService(ctrl)
mockprops.EXPECT().
EntityWithProperties(gomock.Any(), gomock.Any(), nil).
EntityWithPropertiesByID(gomock.Any(), gomock.Any(), nil).
Return(models.NewEntityWithPropertiesFromInstance(
models.EntityInstance{}, nil), nil)

Expand Down
2 changes: 1 addition & 1 deletion internal/engine/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (e *executor) profileEvalStatus(
}

// get the entity with properties by the entity UUID
ewp, err := e.propService.EntityWithProperties(ctx, entityID,
ewp, err := e.propService.EntityWithPropertiesByID(ctx, entityID,
service.CallBuilder().WithStoreOrTransaction(e.querier))
if err != nil {
return fmt.Errorf("error getting entity with properties: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ default allow = true`,

mockPropSvc := mockprops.NewMockPropertiesService(ctrl)
mockPropSvc.EXPECT().
EntityWithProperties(gomock.Any(), repositoryID, gomock.Any()).
EntityWithPropertiesByID(gomock.Any(), repositoryID, gomock.Any()).
Return(&models.EntityWithProperties{
Entity: models.EntityInstance{
ID: repositoryID,
Expand Down
12 changes: 6 additions & 6 deletions internal/entities/properties/service/mock/service.go

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

6 changes: 3 additions & 3 deletions internal/entities/properties/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ type PropertiesService interface {
EntityWithPropertiesAsProto(
ctx context.Context, ewp *models.EntityWithProperties, provMgr manager.ProviderManager,
) (protoreflect.ProtoMessage, error)
// EntityWithProperties Fetches an Entity by ID and Project in order to refresh the properties
EntityWithProperties(
// EntityWithPropertiesByID Fetches an Entity by ID and Project in order to refresh the properties
EntityWithPropertiesByID(
ctx context.Context, entityID uuid.UUID, opts *CallOptions,
) (*models.EntityWithProperties, error)
// RetrieveAllProperties fetches all properties for an entity
Expand Down Expand Up @@ -290,7 +290,7 @@ func (ps *propertiesService) ReplaceProperty(
return err
}

func (ps *propertiesService) EntityWithProperties(
func (ps *propertiesService) EntityWithPropertiesByID(
ctx context.Context, entityID uuid.UUID,
opts *CallOptions,
) (*models.EntityWithProperties, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/entities/properties/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ func TestPropertiesService_EntityWithProperties(t *testing.T) {
Return(tt.dbPropsBuilder(tt.entityID), nil)

ps := NewPropertiesService(mockDB)
result, err := ps.EntityWithProperties(ctx, tt.entityID, nil)
result, err := ps.EntityWithPropertiesByID(ctx, tt.entityID, nil)
require.NoError(t, err)
require.NotNil(t, result)
require.Equal(t, result.Entity.ID, tt.entityID)
Expand Down
2 changes: 1 addition & 1 deletion internal/history/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (ehs *evaluationHistoryService) ListEvaluationHistory(

data := make([]*OneEvalHistoryAndEntity, 0, len(rows))
for _, row := range rows {
efp, err := propsvc.EntityWithProperties(ctx, row.EntityID,
efp, err := propsvc.EntityWithPropertiesByID(ctx, row.EntityID,
propertiessvc.CallBuilder().WithStoreOrTransaction(qtx))
if err != nil {
return nil, fmt.Errorf("error fetching entity for properties: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions internal/history/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,12 @@ func TestListEvaluationHistory(t *testing.T) {
pm := pmMock.NewMockProviderManager(ctrl)
propsSvc := propsSvcMock.NewMockPropertiesService(ctrl)
for _, efp := range tt.efp {
propsSvc.EXPECT().EntityWithProperties(ctx, gomock.Any(), gomock.Any()).
propsSvc.EXPECT().EntityWithPropertiesByID(ctx, gomock.Any(), gomock.Any()).
Return(efp, tt.entityForPropertiesError)
}

if tt.entityForPropertiesError != nil && len(tt.efp) == 0 {
propsSvc.EXPECT().EntityWithProperties(ctx, gomock.Any(), gomock.Any()).
propsSvc.EXPECT().EntityWithPropertiesByID(ctx, gomock.Any(), gomock.Any()).
Return(nil, tt.entityForPropertiesError).AnyTimes()
}
propsSvc.EXPECT().RetrieveAllPropertiesForEntity(ctx, gomock.Any(), gomock.Any(), gomock.Any()).
Expand Down
2 changes: 1 addition & 1 deletion internal/providers/github/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (g *githubProviderManager) Delete(ctx context.Context, config *db.Provider)
}

for _, ent := range entities {
ewp, err := g.propsSvc.EntityWithProperties(ctx, ent.ID, nil)
ewp, err := g.propsSvc.EntityWithPropertiesByID(ctx, ent.ID, nil)
if err != nil {
zerolog.Ctx(ctx).Error().Err(err).
Str("provider_id", config.ID.String()).
Expand Down
6 changes: 3 additions & 3 deletions internal/repositories/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (r *repositoryService) ListRepositories(

ents = make([]*models.EntityWithProperties, 0, len(repoEnts))
for _, ent := range repoEnts {
ewp, err := r.propSvc.EntityWithProperties(ctx, ent.ID,
ewp, err := r.propSvc.EntityWithPropertiesByID(ctx, ent.ID,
service.CallBuilder().WithStoreOrTransaction(qtx))
if err != nil {
return nil, fmt.Errorf("error fetching properties for repository: %w", err)
Expand Down Expand Up @@ -315,7 +315,7 @@ func (r *repositoryService) DeleteByID(ctx context.Context, repositoryID uuid.UU
logger.BusinessRecord(ctx).Project = projectID
logger.BusinessRecord(ctx).Repository = repositoryID

ent, err := r.propSvc.EntityWithProperties(ctx, repositoryID, nil)
ent, err := r.propSvc.EntityWithPropertiesByID(ctx, repositoryID, nil)
if err != nil {
return fmt.Errorf("error fetching repository: %w", err)
}
Expand Down Expand Up @@ -355,7 +355,7 @@ func (r *repositoryService) DeleteByName(

logger.BusinessRecord(ctx).Repository = repo.ID

ent, err := r.propSvc.EntityWithProperties(ctx, repo.ID, nil)
ent, err := r.propSvc.EntityWithPropertiesByID(ctx, repo.ID, nil)
if err != nil {
return fmt.Errorf("error fetching repository: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/repositories/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ func withSuccessfulPropFetch(prop *properties.Properties) func(svcMock propSvcMo

func withSuccessfulEntityWithProps(mock propSvcMock) {
mock.EXPECT().
EntityWithProperties(gomock.Any(), gomock.Any(), gomock.Any()).
EntityWithPropertiesByID(gomock.Any(), gomock.Any(), gomock.Any()).
Return(models.NewEntityWithPropertiesFromInstance(models.EntityInstance{
ID: dbRepo.ID,
ProjectID: projectID,
Expand All @@ -722,7 +722,7 @@ func withSuccessfulEntityWithProps(mock propSvcMock) {

func withFailedEntityWithProps(mock propSvcMock) {
mock.EXPECT().
EntityWithProperties(gomock.Any(), gomock.Any(), gomock.Any()).
EntityWithPropertiesByID(gomock.Any(), gomock.Any(), gomock.Any()).
Return(nil, errDefault)
}

Expand Down

0 comments on commit 7e9c9d7

Please sign in to comment.