diff --git a/internal/auth/jwtauth.go b/internal/auth/jwtauth.go index 892fbce64a..3c14057946 100644 --- a/internal/auth/jwtauth.go +++ b/internal/auth/jwtauth.go @@ -143,23 +143,23 @@ func WithPermissionsContext(ctx context.Context, claims UserPermissions) context return context.WithValue(ctx, tokenContextKey, claims) } -// GetDefaultProject returns the default group id for the user +// GetDefaultProject returns the default project id for the user func GetDefaultProject(ctx context.Context) (uuid.UUID, error) { permissions := GetPermissionsFromContext(ctx) if len(permissions.ProjectIds) != 1 { - return uuid.UUID{}, errors.New("cannot get default group") + return uuid.UUID{}, errors.New("cannot get default project") } return permissions.ProjectIds[0], nil } -// IsAuthorizedForProject returns true if the user is authorized for the given group +// IsAuthorizedForProject returns true if the user is authorized for the given project func IsAuthorizedForProject(ctx context.Context, projectID uuid.UUID) bool { permissions := GetPermissionsFromContext(ctx) return slices.Contains(permissions.ProjectIds, projectID) } -// GetUserProjects returns all the groups where an user belongs to +// GetUserProjects returns all the projects where a user belongs to func GetUserProjects(ctx context.Context) ([]uuid.UUID, error) { permissions := GetPermissionsFromContext(ctx) return permissions.ProjectIds, nil diff --git a/internal/controlplane/common.go b/internal/controlplane/common.go index 9bc9722364..b03768ae2e 100644 --- a/internal/controlplane/common.go +++ b/internal/controlplane/common.go @@ -43,7 +43,7 @@ func providerError(err error) error { } func getProjectFromRequestOrDefault(ctx context.Context, in ProjectIDGetter) (uuid.UUID, error) { - // if we do not have a group, check if we can infer it + // if we do not have a project ID, check if we can infer it if in.GetProjectId() == "" { proj, err := auth.GetDefaultProject(ctx) if err != nil { diff --git a/internal/controlplane/handlers_artifacts.go b/internal/controlplane/handlers_artifacts.go index 30ca6f0283..89012074f7 100644 --- a/internal/controlplane/handlers_artifacts.go +++ b/internal/controlplane/handlers_artifacts.go @@ -31,7 +31,7 @@ import ( pb "github.com/stacklok/minder/pkg/api/protobuf/go/minder/v1" ) -// ListArtifacts lists all artifacts for a given group and provider +// ListArtifacts lists all artifacts for a given project and provider // nolint:gocyclo func (s *Server) ListArtifacts(ctx context.Context, in *pb.ListArtifactsRequest) (*pb.ListArtifactsResponse, error) { projectID, err := getProjectFromRequestOrDefault(ctx, in) @@ -52,7 +52,7 @@ func (s *Server) ListArtifacts(ctx context.Context, in *pb.ListArtifactsRequest) return nil, providerError(err) } - // first read all the repositories for provider and group + // first read all the repositories for provider and project repositories, err := s.store.ListRegisteredRepositoriesByProjectIDAndProvider(ctx, db.ListRegisteredRepositoriesByProjectIDAndProviderParams{Provider: provider.Name, ProjectID: projectID}) if err != nil { diff --git a/internal/controlplane/handlers_authz.go b/internal/controlplane/handlers_authz.go index b0392a619e..298c4e6adc 100644 --- a/internal/controlplane/handlers_authz.go +++ b/internal/controlplane/handlers_authz.go @@ -79,14 +79,14 @@ func lookupUserPermissions(ctx context.Context, store db.Store, tok openid.Token return emptyPermissions, fmt.Errorf("failed to read user") } - // read groups and add id to claims + // read projects and add id to claims gs, err := store.GetUserProjects(ctx, userInfo.ID) if err != nil { - return emptyPermissions, fmt.Errorf("failed to get groups") + return emptyPermissions, fmt.Errorf("failed to get projects") } - var groups []uuid.UUID + var projects []uuid.UUID for _, g := range gs { - groups = append(groups, g.ID) + projects = append(projects, g.ID) } // read roles and add details to claims @@ -112,7 +112,7 @@ func lookupUserPermissions(ctx context.Context, store db.Store, tok openid.Token claims := auth.UserPermissions{ UserId: userInfo.ID, Roles: roles, - ProjectIds: groups, + ProjectIds: projects, OrganizationId: userInfo.OrganizationID, IsStaff: containsSuperadminRole(tok), } @@ -121,7 +121,7 @@ func lookupUserPermissions(ctx context.Context, store db.Store, tok openid.Token } // AuthorizedOnProject checks if the request is authorized for the given -// group, and returns an error if the request is not authorized. +// project, and returns an error if the request is not authorized. func AuthorizedOnProject(ctx context.Context, projectID uuid.UUID) error { claims := auth.GetPermissionsFromContext(ctx) if isSuperadmin(claims) { @@ -129,7 +129,7 @@ func AuthorizedOnProject(ctx context.Context, projectID uuid.UUID) error { } opts := getRpcOptions(ctx) if opts.GetAuthScope() != minder.ObjectOwner_OBJECT_OWNER_PROJECT { - return status.Errorf(codes.Internal, "Called IsProjectAuthorized on non-group method, should be %v", opts.GetAuthScope()) + return status.Errorf(codes.Internal, "Called IsProjectAuthorized on non-project method, should be %v", opts.GetAuthScope()) } if !slices.Contains(claims.ProjectIds, projectID) { @@ -141,7 +141,7 @@ func AuthorizedOnProject(ctx context.Context, projectID uuid.UUID) error { } return *role.ProjectID == projectID && role.IsAdmin } - // check if is admin of group + // check if is admin of project if opts.GetOwnerOnly() && !slices.ContainsFunc(claims.Roles, isOwner) { return util.UserVisibleError(codes.PermissionDenied, "user is not an administrator on this project") } diff --git a/internal/controlplane/handlers_githubwebhooks.go b/internal/controlplane/handlers_githubwebhooks.go index abf1bd43b2..6d932597c7 100644 --- a/internal/controlplane/handlers_githubwebhooks.go +++ b/internal/controlplane/handlers_githubwebhooks.go @@ -998,7 +998,7 @@ func getRepoInformationFromPayload( return db.Repository{}, fmt.Errorf("error parsing repository ID: %w", err) } - // At this point, we're unsure what the group ID is, so we need to look it up. + // At this point, we're unsure what the project ID is, so we need to look it up. // It's the same case for the provider. We can gather this information from the // repository ID. dbrepo, err := store.GetRepositoryByRepoID(ctx, id) @@ -1012,7 +1012,7 @@ func getRepoInformationFromPayload( } if dbrepo.ProjectID.String() == "" { - return db.Repository{}, fmt.Errorf("no group found for repository %s/%s: %w", + return db.Repository{}, fmt.Errorf("no project found for repository %s/%s: %w", dbrepo.RepoOwner, dbrepo.RepoName, errRepoNotFound) } diff --git a/internal/controlplane/handlers_oauth.go b/internal/controlplane/handlers_oauth.go index 44abe3e136..c1cf9a18c3 100644 --- a/internal/controlplane/handlers_oauth.go +++ b/internal/controlplane/handlers_oauth.go @@ -85,7 +85,7 @@ func (s *Server) GetAuthorizationURL(ctx context.Context, Valid: true, } - // Delete any existing session state for the group + // Delete any existing session state for the project err = s.store.DeleteSessionStateByProjectID(ctx, db.DeleteSessionStateByProjectIDParams{ Provider: provider.Name, ProjectID: projectID}) @@ -100,7 +100,7 @@ func (s *Server) GetAuthorizationURL(ctx context.Context, owner = sql.NullString{Valid: true, String: *req.Owner} } - // Insert the new session state into the database along with the user's group ID + // Insert the new session state into the database along with the user's project ID // retrieved from the JWT token _, err = s.store.CreateSessionState(ctx, db.CreateSessionStateParams{ Provider: provider.Name, @@ -149,7 +149,7 @@ func (s *Server) ExchangeCodeForTokenCLI(ctx context.Context, // get projectID from session along with state nonce from the database stateData, err := s.store.GetProjectIDPortBySessionState(ctx, in.State) if err != nil { - return nil, status.Errorf(codes.Unknown, "error getting group ID by session state: %s", err) + return nil, status.Errorf(codes.Unknown, "error getting project ID by session state: %s", err) } // get provider @@ -281,7 +281,7 @@ func (s *Server) getProviderAccessToken(ctx context.Context, provider string, return decryptedToken, encToken.OwnerFilter.String, nil } -// StoreProviderToken stores the provider token for a group +// StoreProviderToken stores the provider token for a project func (s *Server) StoreProviderToken(ctx context.Context, in *pb.StoreProviderTokenRequest) (*pb.StoreProviderTokenResponse, error) { projectID, err := getProjectFromRequestOrDefault(ctx, in) diff --git a/internal/controlplane/handlers_profile.go b/internal/controlplane/handlers_profile.go index f09427d401..e3b4f16887 100644 --- a/internal/controlplane/handlers_profile.go +++ b/internal/controlplane/handlers_profile.go @@ -68,8 +68,8 @@ func (s *Server) authAndContextValidation(ctx context.Context, inout *minderv1.C return engine.WithEntityContext(ctx, entityCtx), nil } -// ensureDefaultProjectForContext ensures a valid group is set in the context or sets the default group -// if the group is not set in the incoming entity context, it'll set it. +// ensureDefaultProjectForContext ensures a valid project is set in the context or sets the default project +// if the project is not set in the incoming entity context, it'll set it. func (s *Server) ensureDefaultProjectForContext(ctx context.Context, inout *minderv1.Context) error { // Project is already set if inout.GetProject() != "" { @@ -78,19 +78,19 @@ func (s *Server) ensureDefaultProjectForContext(ctx context.Context, inout *mind gid, err := auth.GetDefaultProject(ctx) if err != nil { - return status.Errorf(codes.InvalidArgument, "cannot infer group id") + return status.Errorf(codes.InvalidArgument, "cannot infer project id") } g, err := s.store.GetProjectByID(ctx, gid) if err != nil { - return status.Errorf(codes.InvalidArgument, "cannot infer group id") + return status.Errorf(codes.InvalidArgument, "cannot infer project id") } inout.Project = &g.Name return nil } -// verifyValidProject verifies that the group is valid and the user is authorized to access it +// verifyValidProject verifies that the project is valid and the user is authorized to access it // TODO: This will have to change once we have the hierarchy tree in place. func verifyValidProject(ctx context.Context, in *engine.EntityContext) error { if !auth.IsAuthorizedForProject(ctx, in.GetProject().GetID()) { @@ -116,14 +116,14 @@ func validateActionType(r string) db.NullActionType { return db.NullActionType{Valid: false} } -// CreateProfile creates a profile for a group +// CreateProfile creates a profile for a project func (s *Server) CreateProfile(ctx context.Context, cpr *minderv1.CreateProfileRequest) (*minderv1.CreateProfileResponse, error) { in := cpr.GetProfile() ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -273,7 +273,7 @@ func (s *Server) DeleteProfile(ctx context.Context, in *minderv1.DeleteProfileRequest) (*minderv1.DeleteProfileResponse, error) { _, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } parsedProfileID, err := uuid.Parse(in.Id) @@ -297,12 +297,12 @@ func (s *Server) DeleteProfile(ctx context.Context, return &minderv1.DeleteProfileResponse{}, nil } -// ListProfiles is a method to get all profiles for a group +// ListProfiles is a method to get all profiles for a project func (s *Server) ListProfiles(ctx context.Context, in *minderv1.ListProfilesRequest) (*minderv1.ListProfilesResponse, error) { ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -326,7 +326,7 @@ func (s *Server) GetProfileById(ctx context.Context, in *minderv1.GetProfileByIdRequest) (*minderv1.GetProfileByIdResponse, error) { ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -422,7 +422,7 @@ func (s *Server) GetProfileStatusByName(ctx context.Context, in *minderv1.GetProfileStatusByNameRequest) (*minderv1.GetProfileStatusByNameResponse, error) { ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -533,12 +533,12 @@ func (s *Server) GetProfileStatusByName(ctx context.Context, }, nil } -// GetProfileStatusByProject is a method to get profile status for a group +// GetProfileStatusByProject is a method to get profile status for a project func (s *Server) GetProfileStatusByProject(ctx context.Context, in *minderv1.GetProfileStatusByProjectRequest) (*minderv1.GetProfileStatusByProjectResponse, error) { ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -547,7 +547,7 @@ func (s *Server) GetProfileStatusByProject(ctx context.Context, dbstats, err := s.store.GetProfileStatusByProject(ctx, entityCtx.Project.ID) if err != nil { if errors.Is(err, sql.ErrNoRows) { - return nil, status.Errorf(codes.NotFound, "profile statuses not found for group") + return nil, status.Errorf(codes.NotFound, "profile statuses not found for project") } return nil, status.Errorf(codes.Unknown, "failed to get profile status: %s", err) } @@ -576,7 +576,7 @@ func (s *Server) UpdateProfile(ctx context.Context, ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) diff --git a/internal/controlplane/handlers_repositories.go b/internal/controlplane/handlers_repositories.go index fea47b5035..6746e4d60e 100644 --- a/internal/controlplane/handlers_repositories.go +++ b/internal/controlplane/handlers_repositories.go @@ -37,7 +37,7 @@ import ( ) // RegisterRepository adds repositories to the database and registers a webhook -// Once a user had enrolled in a group (they have a valid token), they can register +// Once a user had enrolled in a project (they have a valid token), they can register // repositories to be monitored by the minder by provisioning a webhook on the // repositor(ies). func (s *Server) RegisterRepository(ctx context.Context, @@ -139,10 +139,10 @@ func (s *Server) RegisterRepository(ctx context.Context, return response, nil } -// ListRepositories returns a list of repositories for a given group +// ListRepositories returns a list of repositories for a given project // This function will typically be called by the client to get a list of // repositories that are registered present in the minder database -// The API is called with a group id, limit and offset +// The API is called with a project id, limit and offset func (s *Server) ListRepositories(ctx context.Context, in *pb.ListRepositoriesRequest) (*pb.ListRepositoriesResponse, error) { projectID, err := getProjectFromRequestOrDefault(ctx, in) @@ -251,7 +251,7 @@ func (s *Server) GetRepositoryById(ctx context.Context, // GetRepositoryByName returns information about a repository. // This function will typically be called by the client to get a // repository which is already registered and present in the minder database -// The API is called with a group id +// The API is called with a project id func (s *Server) GetRepositoryByName(ctx context.Context, in *pb.GetRepositoryByNameRequest) (*pb.GetRepositoryByNameResponse, error) { // split repo name in owner and name diff --git a/internal/controlplane/handlers_ruletype.go b/internal/controlplane/handlers_ruletype.go index b90056086b..98be5d25dd 100644 --- a/internal/controlplane/handlers_ruletype.go +++ b/internal/controlplane/handlers_ruletype.go @@ -39,7 +39,7 @@ func (s *Server) ListRuleTypes( ) (*minderv1.ListRuleTypesResponse, error) { ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -74,7 +74,7 @@ func (s *Server) GetRuleTypeByName( ) (*minderv1.GetRuleTypeByNameResponse, error) { ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -107,7 +107,7 @@ func (s *Server) GetRuleTypeById( ) (*minderv1.GetRuleTypeByIdResponse, error) { ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -143,7 +143,7 @@ func (s *Server) CreateRuleType( ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -201,7 +201,7 @@ func (s *Server) UpdateRuleType( ctx, err := s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } entityCtx := engine.EntityFromContext(ctx) @@ -304,7 +304,7 @@ func (s *Server) DeleteRuleType( ctx, err = s.authAndContextValidation(ctx, in.GetContext()) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "error ensuring default group: %v", err) + return nil, status.Errorf(codes.InvalidArgument, "error ensuring default project: %v", err) } profileInfo, err := s.store.ListProfilesInstantiatingRuleType(ctx, ruletype.ID) diff --git a/internal/db/entity_execution_lock.sql_test.go b/internal/db/entity_execution_lock.sql_test.go index 397370ea75..a79889b846 100644 --- a/internal/db/entity_execution_lock.sql_test.go +++ b/internal/db/entity_execution_lock.sql_test.go @@ -33,9 +33,9 @@ func TestQueries_LockIfThresholdNotExceeded(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - repo := createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + repo := createRandomRepository(t, project.ID, prov.Name) threshold := 1 concurrentCalls := 10 diff --git a/internal/db/pull_request_test.go b/internal/db/pull_request_test.go index 86b2238f0e..dc8ff5c4d2 100644 --- a/internal/db/pull_request_test.go +++ b/internal/db/pull_request_test.go @@ -59,9 +59,9 @@ func TestCreatePullRequest(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - repo := createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + repo := createRandomRepository(t, project.ID, prov.Name) pr := createRandomPullRequest(t, repo.ID) require.NotEmpty(t, pr) @@ -81,9 +81,9 @@ func TestUpsertPullRequest(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - repo := createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + repo := createRandomRepository(t, project.ID, prov.Name) pr1 := createRandomPullRequest(t, repo.ID) @@ -106,9 +106,9 @@ func TestDeletePullRequest(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - repo := createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + repo := createRandomRepository(t, project.ID, prov.Name) pr1 := createRandomPullRequest(t, repo.ID) require.NotEmpty(t, pr1) diff --git a/internal/db/repositories_test.go b/internal/db/repositories_test.go index 416c52229b..41f47d3a1c 100644 --- a/internal/db/repositories_test.go +++ b/internal/db/repositories_test.go @@ -94,18 +94,18 @@ func TestRepository(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + createRandomRepository(t, project.ID, prov.Name) } func TestGetRepositoryByID(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - repo1 := createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + repo1 := createRandomRepository(t, project.ID, prov.Name) repo2, err := testQueries.GetRepositoryByID(context.Background(), repo1.ID) require.NoError(t, err) @@ -130,9 +130,9 @@ func TestGetRepositoryByRepoName(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - repo1 := createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + repo1 := createRandomRepository(t, project.ID, prov.Name) repo2, err := testQueries.GetRepositoryByRepoName(context.Background(), GetRepositoryByRepoNameParams{ Provider: repo1.Provider, RepoOwner: repo1.RepoOwner, RepoName: repo1.RepoName}) @@ -158,19 +158,19 @@ func TestListRepositoriesByProjectID(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + createRandomRepository(t, project.ID, prov.Name) for i := int32(1001); i < 1020; i++ { - createRandomRepository(t, group.ID, prov.Name, func(r *CreateRepositoryParams) { + createRandomRepository(t, project.ID, prov.Name, func(r *CreateRepositoryParams) { r.RepoID = int32(i) }) } arg := ListRepositoriesByProjectIDParams{ Provider: prov.Name, - ProjectID: group.ID, + ProjectID: project.ID, } repos, err := testQueries.ListRepositoriesByProjectID(context.Background(), arg) @@ -187,9 +187,9 @@ func TestUpdateRepository(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - repo1 := createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + repo1 := createRandomRepository(t, project.ID, prov.Name) arg := UpdateRepositoryParams{ ID: repo1.ID, @@ -228,9 +228,9 @@ func TestUpdateRepositoryByRepoId(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - repo1 := createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + repo1 := createRandomRepository(t, project.ID, prov.Name) arg := UpdateRepositoryByIDParams{ RepoID: repo1.RepoID, @@ -268,9 +268,9 @@ func TestDeleteRepository(t *testing.T) { t.Parallel() org := createRandomOrganization(t) - group := createRandomProject(t, org.ID) - prov := createRandomProvider(t, group.ID) - repo1 := createRandomRepository(t, group.ID, prov.Name) + project := createRandomProject(t, org.ID) + prov := createRandomProvider(t, project.ID) + repo1 := createRandomRepository(t, project.ID, prov.Name) err := testQueries.DeleteRepository(context.Background(), repo1.ID) require.NoError(t, err) diff --git a/internal/engine/context.go b/internal/engine/context.go index ef925cafa2..b7251199b1 100644 --- a/internal/engine/context.go +++ b/internal/engine/context.go @@ -53,12 +53,12 @@ type Project struct { Name string } -// GetID returns the ID of the group +// GetID returns the ID of the project func (g Project) GetID() uuid.UUID { return g.ID } -// GetName returns the name of the group +// GetName returns the name of the project func (g Project) GetName() string { return g.Name } @@ -77,7 +77,7 @@ type EntityContext struct { Provider Provider } -// GetProject returns the group of the entity +// GetProject returns the project of the entity func (c *EntityContext) GetProject() Project { return c.Project } @@ -92,17 +92,17 @@ func (c *EntityContext) GetProvider() Provider { // user-friendly information about an object. func GetContextFromInput(ctx context.Context, in *pb.Context, q db.Querier) (*EntityContext, error) { if in.Project == nil || *in.Project == "" { - return nil, fmt.Errorf("invalid context: missing group") + return nil, fmt.Errorf("invalid context: missing project") } - group, err := q.GetProjectByName(ctx, *in.Project) + project, err := q.GetProjectByName(ctx, *in.Project) if err != nil { return nil, fmt.Errorf("unable to get context: %w", err) } prov, err := q.GetProviderByName(ctx, db.GetProviderByNameParams{ Name: in.Provider, - ProjectID: group.ID, + ProjectID: project.ID, }) if err != nil { return nil, fmt.Errorf("unable to get context: failed getting provider: %w", err) @@ -110,8 +110,8 @@ func GetContextFromInput(ctx context.Context, in *pb.Context, q db.Querier) (*En return &EntityContext{ Project: Project{ - ID: group.ID, - Name: group.Name, + ID: project.ID, + Name: project.Name, }, Provider: Provider{ ID: prov.ID, diff --git a/internal/engine/executor.go b/internal/engine/executor.go index 81ccb73d46..698de93ded 100644 --- a/internal/engine/executor.go +++ b/internal/engine/executor.go @@ -168,7 +168,7 @@ func (e *Executor) prepAndEvalEntityEvent(ctx context.Context, inf *EntityInfoWr // get project info project, err := e.querier.GetProjectByID(ctx, *projectID) if err != nil { - return fmt.Errorf("error getting group: %w", err) + return fmt.Errorf("error getting project: %w", err) } provider, err := e.querier.GetProviderByName(ctx, db.GetProviderByNameParams{ @@ -215,7 +215,7 @@ func (e *Executor) evalEntityEvent( defer e.releaseLockAndFlush(ctx, inf) - // Get profiles relevant to group + // Get profiles relevant to project dbpols, err := e.querier.ListProfilesByProjectID(ctx, *inf.ProjectID) if err != nil { return fmt.Errorf("error getting profiles: %w", err) diff --git a/internal/engine/executor_test.go b/internal/engine/executor_test.go index 8d3f7c272f..76facd2817 100644 --- a/internal/engine/executor_test.go +++ b/internal/engine/executor_test.go @@ -94,7 +94,7 @@ func TestExecutor_handleEntityEvent(t *testing.T) { gomock.Any(), ).Return(db.ListRuleEvaluationsByProfileIdRow{}, nil) - // get group information + // get project information mockStore.EXPECT(). GetProjectByID(gomock.Any(), projectID). Return(db.Project{ diff --git a/internal/engine/profile.go b/internal/engine/profile.go index cf798d21b5..582212174b 100644 --- a/internal/engine/profile.go +++ b/internal/engine/profile.go @@ -149,7 +149,7 @@ func TraverseRules(rules []*pb.Profile_Rule, fn func(*pb.Profile_Rule) error) er } // MergeDatabaseListIntoProfiles merges the database list profiles into the given -// profiles map. This assumes that the profiles belong to the same group. +// profiles map. This assumes that the profiles belong to the same project. // // TODO(jaosorior): This will have to consider the project tree once we migrate to that func MergeDatabaseListIntoProfiles(ppl []db.ListProfilesByProjectIDRow, ectx *EntityContext) map[string]*pb.Profile { @@ -192,7 +192,7 @@ func MergeDatabaseListIntoProfiles(ppl []db.ListProfilesByProjectIDRow, ectx *En } // MergeDatabaseGetIntoProfiles merges the database get profiles into the given -// profiles map. This assumes that the profiles belong to the same group. +// profiles map. This assumes that the profiles belong to the same project. // // TODO(jaosorior): This will have to consider the project tree once we migrate to that func MergeDatabaseGetIntoProfiles(ppl []db.GetProfileByProjectAndIDRow, ectx *EntityContext) map[string]*pb.Profile { @@ -230,7 +230,7 @@ func MergeDatabaseGetIntoProfiles(ppl []db.GetProfileByProjectAndIDRow, ectx *En } // rowInfoToProfileMap adds the database row information to the given map of -// profiles. This assumes that the profiles belong to the same group. +// profiles. This assumes that the profiles belong to the same project. // Note that this function is thought to be called from scpecific Merge functions // and thus the logic is targetted to that. func rowInfoToProfileMap( diff --git a/internal/engine/rule_types.go b/internal/engine/rule_types.go index c98ab0e38a..7848cb98a4 100644 --- a/internal/engine/rule_types.go +++ b/internal/engine/rule_types.go @@ -45,7 +45,7 @@ type RuleMeta struct { Provider string // Organization is the ID of the organization that this rule is for Organization *string - // Project is the ID of the group that this rule is for + // Project is the ID of the project that this rule is for Project *string } diff --git a/internal/reconcilers/artifacts.go b/internal/reconcilers/artifacts.go index cd161f8542..dad769da79 100644 --- a/internal/reconcilers/artifacts.go +++ b/internal/reconcilers/artifacts.go @@ -44,7 +44,7 @@ var CONTAINER_TYPE = "container" // RepoReconcilerEvent is an event that is sent to the reconciler topic type RepoReconcilerEvent struct { - // Project is the group that the event is relevant to + // Project is the project that the event is relevant to Project uuid.UUID `json:"group" validate:"gte=0"` // Repository is the repository to be reconciled Repository int32 `json:"repository" validate:"gte=0"` diff --git a/internal/reconcilers/run_profile.go b/internal/reconcilers/run_profile.go index 61333c7e41..1b5f232406 100644 --- a/internal/reconcilers/run_profile.go +++ b/internal/reconcilers/run_profile.go @@ -37,7 +37,7 @@ import ( // ProfileInitEvent is an event that is sent to the reconciler topic // when a new profile is created. It is used to initialize the profile -// by iterating over all registered entities for the relevant group +// by iterating over all registered entities for the relevant project // and sending a profile evaluation event for each one. type ProfileInitEvent struct { // Project is the project that the event is relevant to @@ -62,7 +62,7 @@ func NewProfileInitMessage(provider string, projectID uuid.UUID) (*message.Messa // handleProfileInitEvent handles a profile init event. // It is responsible for iterating over all registered repositories -// for the group and sending a profile evaluation event for each one. +// for the project and sending a profile evaluation event for each one. func (e *Reconciler) handleProfileInitEvent(msg *message.Message) error { ctx := msg.Context() prov := msg.Metadata.Get(events.ProviderTypeKey)