Documentation
¶
Overview ¶
Package controlplane contains the gRPC server implementation for the control plane
Package controlplane contains the control plane API for the mediator.
Index ¶
- Constants
- Variables
- func AuthUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (any, error)
- func AuthorizedOnGroup(ctx context.Context, groupId int32) error
- func AuthorizedOnOrg(ctx context.Context, orgId int32) error
- func AuthorizedOnUser(ctx context.Context, userId int32) error
- func RegisterGRPCServices(s *Server)
- func RegisterGatewayHTTPHandlers(ctx context.Context, gwmux *runtime.ServeMux, grpcAddress string, ...)
- type CreateRoleValidation
- type RegistrationStatus
- type Repository
- type RepositoryResult
- type Server
- func (s *Server) CheckHealth(_ context.Context, _ *pb.CheckHealthRequest) (*pb.CheckHealthResponse, error)
- func (s *Server) ConsumeEvents(c ...events.Consumer)
- func (s *Server) CreateGroup(ctx context.Context, req *pb.CreateGroupRequest) (*pb.CreateGroupResponse, error)
- func (s *Server) CreateKeyPair(ctx context.Context, req *pb.CreateKeyPairRequest) (*pb.CreateKeyPairResponse, error)
- func (s *Server) CreateOrganization(ctx context.Context, in *pb.CreateOrganizationRequest) (*pb.CreateOrganizationResponse, error)
- func (s *Server) CreatePolicy(ctx context.Context, cpr *pb.CreatePolicyRequest) (*pb.CreatePolicyResponse, error)
- func (s *Server) CreateRoleByGroup(ctx context.Context, in *pb.CreateRoleByGroupRequest) (*pb.CreateRoleByGroupResponse, error)
- func (s *Server) CreateRoleByOrganization(ctx context.Context, in *pb.CreateRoleByOrganizationRequest) (*pb.CreateRoleByOrganizationResponse, error)
- func (s *Server) CreateRuleType(ctx context.Context, crt *pb.CreateRuleTypeRequest) (*pb.CreateRuleTypeResponse, error)
- func (s *Server) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*pb.CreateUserResponse, error)
- func (s *Server) DeleteGroup(ctx context.Context, in *pb.DeleteGroupRequest) (*pb.DeleteGroupResponse, error)
- func (s *Server) DeleteOrganization(ctx context.Context, in *pb.DeleteOrganizationRequest) (*pb.DeleteOrganizationResponse, error)
- func (s *Server) DeletePolicy(ctx context.Context, in *pb.DeletePolicyRequest) (*pb.DeletePolicyResponse, error)
- func (s *Server) DeleteRole(ctx context.Context, in *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error)
- func (s *Server) DeleteRuleType(ctx context.Context, in *pb.DeleteRuleTypeRequest) (*pb.DeleteRuleTypeResponse, error)
- func (s *Server) DeleteUser(ctx context.Context, in *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error)
- func (s *Server) ExchangeCodeForTokenCLI(ctx context.Context, in *pb.ExchangeCodeForTokenCLIRequest) (*httpbody.HttpBody, error)
- func (s *Server) ExchangeCodeForTokenWEB(ctx context.Context, in *pb.ExchangeCodeForTokenWEBRequest) (*pb.ExchangeCodeForTokenWEBResponse, error)
- func (s *Server) GetArtifactById(ctx context.Context, in *pb.GetArtifactByIdRequest) (*pb.GetArtifactByIdResponse, error)
- func (s *Server) GetAuthorizationURL(ctx context.Context, req *pb.GetAuthorizationURLRequest) (*pb.GetAuthorizationURLResponse, error)
- func (s *Server) GetGroupById(ctx context.Context, req *pb.GetGroupByIdRequest) (*pb.GetGroupByIdResponse, error)
- func (s *Server) GetGroupByName(ctx context.Context, req *pb.GetGroupByNameRequest) (*pb.GetGroupByNameResponse, error)
- func (s *Server) GetGroups(ctx context.Context, req *pb.GetGroupsRequest) (*pb.GetGroupsResponse, error)
- func (s *Server) GetOrganization(ctx context.Context, in *pb.GetOrganizationRequest) (*pb.GetOrganizationResponse, error)
- func (s *Server) GetOrganizationByName(ctx context.Context, in *pb.GetOrganizationByNameRequest) (*pb.GetOrganizationByNameResponse, error)
- func (s *Server) GetOrganizations(ctx context.Context, in *pb.GetOrganizationsRequest) (*pb.GetOrganizationsResponse, error)
- func (s *Server) GetPolicyById(ctx context.Context, in *pb.GetPolicyByIdRequest) (*pb.GetPolicyByIdResponse, error)
- func (s *Server) GetPolicyStatusByGroup(ctx context.Context, in *pb.GetPolicyStatusByGroupRequest) (*pb.GetPolicyStatusByGroupResponse, error)
- func (s *Server) GetPolicyStatusById(ctx context.Context, in *pb.GetPolicyStatusByIdRequest) (*pb.GetPolicyStatusByIdResponse, error)
- func (s *Server) GetProviderAccessToken(ctx context.Context, provider string, groupId int32, checkAuthz bool) (oauth2.Token, string, error)
- func (s *Server) GetRepositoryById(ctx context.Context, in *pb.GetRepositoryByIdRequest) (*pb.GetRepositoryByIdResponse, error)
- func (s *Server) GetRepositoryByName(ctx context.Context, in *pb.GetRepositoryByNameRequest) (*pb.GetRepositoryByNameResponse, error)
- func (s *Server) GetRoleById(ctx context.Context, in *pb.GetRoleByIdRequest) (*pb.GetRoleByIdResponse, error)
- func (s *Server) GetRoleByName(ctx context.Context, in *pb.GetRoleByNameRequest) (*pb.GetRoleByNameResponse, error)
- func (s *Server) GetRoles(ctx context.Context, in *pb.GetRolesRequest) (*pb.GetRolesResponse, error)
- func (s *Server) GetRolesByGroup(ctx context.Context, in *pb.GetRolesByGroupRequest) (*pb.GetRolesByGroupResponse, error)
- func (s *Server) GetRuleTypeById(ctx context.Context, in *pb.GetRuleTypeByIdRequest) (*pb.GetRuleTypeByIdResponse, error)
- func (s *Server) GetRuleTypeByName(ctx context.Context, in *pb.GetRuleTypeByNameRequest) (*pb.GetRuleTypeByNameResponse, error)
- func (s *Server) GetUser(ctx context.Context, _ *pb.GetUserRequest) (*pb.GetUserResponse, error)
- func (s *Server) GetUserById(ctx context.Context, in *pb.GetUserByIdRequest) (*pb.GetUserByIdResponse, error)
- func (s *Server) GetUsers(ctx context.Context, in *pb.GetUsersRequest) (*pb.GetUsersResponse, error)
- func (s *Server) GetUsersByGroup(ctx context.Context, in *pb.GetUsersByGroupRequest) (*pb.GetUsersByGroupResponse, error)
- func (s *Server) GetUsersByOrganization(ctx context.Context, in *pb.GetUsersByOrganizationRequest) (*pb.GetUsersByOrganizationResponse, error)
- func (s *Server) HandleEvents(ctx context.Context) func() error
- func (s *Server) HandleGitHubWebHook() http.HandlerFunc
- func (s *Server) IsProviderCallAuthorized(ctx context.Context, provider db.Provider, groupId int32) bool
- func (s *Server) ListArtifacts(ctx context.Context, in *pb.ListArtifactsRequest) (*pb.ListArtifactsResponse, error)
- func (s *Server) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error)
- func (s *Server) ListRepositories(ctx context.Context, in *pb.ListRepositoriesRequest) (*pb.ListRepositoriesResponse, error)
- func (s *Server) ListRuleTypes(ctx context.Context, in *pb.ListRuleTypesRequest) (*pb.ListRuleTypesResponse, error)
- func (_ *Server) RefreshToken(_ context.Context, _ *pb.RefreshTokenRequest) (*pb.RefreshTokenResponse, error)
- func (s *Server) Register(topic string, handler events.Handler)
- func (s *Server) RegisterRepository(ctx context.Context, in *pb.RegisterRepositoryRequest) (*pb.RegisterRepositoryResponse, error)
- func (s *Server) RevokeOauthGroupToken(ctx context.Context, in *pb.RevokeOauthGroupTokenRequest) (*pb.RevokeOauthGroupTokenResponse, error)
- func (s *Server) RevokeOauthTokens(ctx context.Context, _ *pb.RevokeOauthTokensRequest) (*pb.RevokeOauthTokensResponse, error)
- func (s *Server) StartGRPCServer(ctx context.Context) error
- func (s *Server) StartHTTPServer(ctx context.Context) error
- func (s *Server) StoreProviderToken(ctx context.Context, in *pb.StoreProviderTokenRequest) (*pb.StoreProviderTokenResponse, error)
- func (s *Server) SyncRepositories(ctx context.Context, in *pb.SyncRepositoriesRequest) (*pb.SyncRepositoriesResponse, error)
- func (s *Server) UpdateRuleType(ctx context.Context, urt *pb.UpdateRuleTypeRequest) (*pb.UpdateRuleTypeResponse, error)
- func (*Server) Verify(ctx context.Context, _ *pb.VerifyRequest) (*pb.VerifyResponse, error)
- func (s *Server) VerifyProviderTokenFrom(ctx context.Context, in *pb.VerifyProviderTokenFromRequest) (*pb.VerifyProviderTokenFromResponse, error)
Constants ¶
const PaginationLimit = 10
PaginationLimit is the maximum number of items that can be returned in a single page
Variables ¶
var CONTAINER_TYPE = "container"
CONTAINER_TYPE is the type for container artifacts
var ErrArtifactNotFound = errors.New("artifact not found")
ErrArtifactNotFound is returned when an artifact is not found
var ErrRepoNotFound = errors.New("repository not found")
ErrRepoNotFound is returned when a repository is not found
Functions ¶
func AuthUnaryInterceptor ¶
func AuthUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)
AuthUnaryInterceptor is a server interceptor for authentication
func AuthorizedOnGroup ¶ added in v0.0.4
AuthorizedOnGroup checks if the request is authorized for the given group, and returns an error if the request is not authorized.
func AuthorizedOnOrg ¶ added in v0.0.4
AuthorizedOnOrg checks if the request is authorized for the given organization, and returns an error if the request is not authorized.
func AuthorizedOnUser ¶ added in v0.0.4
AuthorizedOnUser checks if the request is authorized for the given user, and returns an error if the request is not authorized.
func RegisterGRPCServices ¶
func RegisterGRPCServices(s *Server)
RegisterGRPCServices registers the GRPC services
func RegisterGatewayHTTPHandlers ¶
func RegisterGatewayHTTPHandlers(ctx context.Context, gwmux *runtime.ServeMux, grpcAddress string, opts []grpc.DialOption)
RegisterGatewayHTTPHandlers registers the gateway HTTP handlers
Types ¶
type CreateRoleValidation ¶
type CreateRoleValidation struct {
Name string `db:"name" validate:"required"`
}
CreateRoleValidation is a struct for validating the CreateRole request
type RegistrationStatus ¶
RegistrationStatus gathers the status of the webhook call for each repository
type Repository ¶
Repository represents a GitHub repository
type RepositoryResult ¶
type RepositoryResult struct {
Owner string
Repository string
RepoID int32
HookID int64
HookURL string
DeployURL string
CreatedAt time.Time
UpdatedAt time.Time
HookName string
HookType string
HookUUID string
RegistrationStatus
}
RepositoryResult represents the result of the webhook registration
func RegisterWebHook ¶
func RegisterWebHook( ctx context.Context, token oauth2.Token, repositories []Repository, events []string, ) ([]RepositoryResult, error)
RegisterWebHook registers a webhook for the given repositories and events and returns the registration result for each repository. If an error occurs, the registration is aborted and the error is returned. https://docs.github.com/en/rest/reference/repos#create-a-repository-webhook
type Server ¶
type Server struct {
pb.UnimplementedHealthServiceServer
pb.UnimplementedOAuthServiceServer
pb.UnimplementedAuthServiceServer
pb.UnimplementedOrganizationServiceServer
pb.UnimplementedGroupServiceServer
pb.UnimplementedRoleServiceServer
pb.UnimplementedUserServiceServer
pb.UnimplementedRepositoryServiceServer
pb.UnimplementedPolicyServiceServer
pb.UnimplementedArtifactServiceServer
pb.UnimplementedKeyServiceServer
OAuth2 *oauth2.Config
ClientID string
ClientSecret string
// contains filtered or unexported fields
}
Server represents the controlplane server
func NewServer ¶
func NewServer(store db.Store, evt *events.Eventer, cfg *config.Config, vldtr auth.JwtValidator) (*Server, error)
NewServer creates a new server instance
func (*Server) CheckHealth ¶
func (s *Server) CheckHealth(_ context.Context, _ *pb.CheckHealthRequest) (*pb.CheckHealthResponse, error)
CheckHealth is a simple health check for monitoring The lintcheck is disabled because the unused-receiver is required by the implementation. UnimplementedHealthServiceServer is initialized within the Server struct
func (*Server) ConsumeEvents ¶
ConsumeEvents implements events.Registrar
func (*Server) CreateGroup ¶
func (s *Server) CreateGroup(ctx context.Context, req *pb.CreateGroupRequest) (*pb.CreateGroupResponse, error)
CreateGroup creates a group
func (*Server) CreateKeyPair ¶
func (s *Server) CreateKeyPair(ctx context.Context, req *pb.CreateKeyPairRequest) (*pb.CreateKeyPairResponse, error)
CreateKeyPair creates a new key pair for a given group
func (*Server) CreateOrganization ¶
func (s *Server) CreateOrganization(ctx context.Context, in *pb.CreateOrganizationRequest) (*pb.CreateOrganizationResponse, error)
CreateOrganization is a service for creating an organization nolint:gocyclo // we should reactor this later.
func (*Server) CreatePolicy ¶
func (s *Server) CreatePolicy(ctx context.Context, cpr *pb.CreatePolicyRequest) (*pb.CreatePolicyResponse, error)
CreatePolicy creates a policy for a group nolint: gocyclo
func (*Server) CreateRoleByGroup ¶
func (s *Server) CreateRoleByGroup(ctx context.Context, in *pb.CreateRoleByGroupRequest) (*pb.CreateRoleByGroupResponse, error)
CreateRoleByGroup is a service for creating a role for a group
func (*Server) CreateRoleByOrganization ¶
func (s *Server) CreateRoleByOrganization(ctx context.Context, in *pb.CreateRoleByOrganizationRequest) (*pb.CreateRoleByOrganizationResponse, error)
CreateRoleByOrganization is a service for creating a role for an organization
func (*Server) CreateRuleType ¶
func (s *Server) CreateRuleType(ctx context.Context, crt *pb.CreateRuleTypeRequest) (*pb.CreateRuleTypeResponse, error)
CreateRuleType is a method to create a rule type
func (*Server) CreateUser ¶
func (s *Server) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*pb.CreateUserResponse, error)
CreateUser is a service for user self registration
func (*Server) DeleteGroup ¶
func (s *Server) DeleteGroup(ctx context.Context, in *pb.DeleteGroupRequest) (*pb.DeleteGroupResponse, error)
DeleteGroup is a handler that deletes a group
func (*Server) DeleteOrganization ¶
func (s *Server) DeleteOrganization(ctx context.Context, in *pb.DeleteOrganizationRequest) (*pb.DeleteOrganizationResponse, error)
DeleteOrganization is a handler that deletes a organization
func (*Server) DeletePolicy ¶
func (s *Server) DeletePolicy(ctx context.Context, in *pb.DeletePolicyRequest) (*pb.DeletePolicyResponse, error)
DeletePolicy is a method to delete a policy
func (*Server) DeleteRole ¶
func (s *Server) DeleteRole(ctx context.Context, in *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error)
DeleteRole is a service for deleting a role
func (*Server) DeleteRuleType ¶
func (s *Server) DeleteRuleType(ctx context.Context, in *pb.DeleteRuleTypeRequest) (*pb.DeleteRuleTypeResponse, error)
DeleteRuleType is a method to delete a rule type
func (*Server) DeleteUser ¶
func (s *Server) DeleteUser(ctx context.Context, in *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error)
DeleteUser is a service for deleting an user
func (*Server) ExchangeCodeForTokenCLI ¶
func (s *Server) ExchangeCodeForTokenCLI(ctx context.Context, in *pb.ExchangeCodeForTokenCLIRequest) (*httpbody.HttpBody, error)
ExchangeCodeForTokenCLI exchanges an OAuth2 code for a token This function gathers the state from the database and compares it to the state passed in. If they match, the code is exchanged for a token. This function is used by the CLI client.
func (*Server) ExchangeCodeForTokenWEB ¶
func (s *Server) ExchangeCodeForTokenWEB(ctx context.Context, in *pb.ExchangeCodeForTokenWEBRequest) (*pb.ExchangeCodeForTokenWEBResponse, error)
ExchangeCodeForTokenWEB exchanges an OAuth2 code for a token and returns a JWT token as a session cookie. This handler is specific for web clients. The lint check for this function is disabled because it's a false positive. It will complain about am unsused receiver (s *Server), however this receiver will be used later when we implement the database store.
func (*Server) GetArtifactById ¶
func (s *Server) GetArtifactById(ctx context.Context, in *pb.GetArtifactByIdRequest) (*pb.GetArtifactByIdResponse, error)
GetArtifactById gets an artifact by id nolint:gocyclo
func (*Server) GetAuthorizationURL ¶
func (s *Server) GetAuthorizationURL(ctx context.Context, req *pb.GetAuthorizationURLRequest) (*pb.GetAuthorizationURLResponse, error)
GetAuthorizationURL returns the URL to redirect the user to for authorization and the state to be used for the callback. It accepts a provider string and a boolean indicating whether the client is a CLI or web client
func (*Server) GetGroupById ¶
func (s *Server) GetGroupById(ctx context.Context, req *pb.GetGroupByIdRequest) (*pb.GetGroupByIdResponse, error)
GetGroupById returns a group by id
func (*Server) GetGroupByName ¶
func (s *Server) GetGroupByName(ctx context.Context, req *pb.GetGroupByNameRequest) (*pb.GetGroupByNameResponse, error)
GetGroupByName returns a group by name
func (*Server) GetGroups ¶
func (s *Server) GetGroups(ctx context.Context, req *pb.GetGroupsRequest) (*pb.GetGroupsResponse, error)
GetGroups returns a list of groups
func (*Server) GetOrganization ¶
func (s *Server) GetOrganization(ctx context.Context, in *pb.GetOrganizationRequest) (*pb.GetOrganizationResponse, error)
GetOrganization is a service for getting an organization
func (*Server) GetOrganizationByName ¶
func (s *Server) GetOrganizationByName(ctx context.Context, in *pb.GetOrganizationByNameRequest) (*pb.GetOrganizationByNameResponse, error)
GetOrganizationByName is a service for getting an organization
func (*Server) GetOrganizations ¶
func (s *Server) GetOrganizations(ctx context.Context, in *pb.GetOrganizationsRequest) (*pb.GetOrganizationsResponse, error)
GetOrganizations is a service for getting a list of organizations
func (*Server) GetPolicyById ¶
func (s *Server) GetPolicyById(ctx context.Context, in *pb.GetPolicyByIdRequest) (*pb.GetPolicyByIdResponse, error)
GetPolicyById is a method to get a policy by id
func (*Server) GetPolicyStatusByGroup ¶
func (s *Server) GetPolicyStatusByGroup(ctx context.Context, in *pb.GetPolicyStatusByGroupRequest) (*pb.GetPolicyStatusByGroupResponse, error)
GetPolicyStatusByGroup is a method to get policy status for a group
func (*Server) GetPolicyStatusById ¶
func (s *Server) GetPolicyStatusById(ctx context.Context, in *pb.GetPolicyStatusByIdRequest) (*pb.GetPolicyStatusByIdResponse, error)
GetPolicyStatusById is a method to get policy status nolint:gocyclo // TODO: Refactor this to be more readable
func (*Server) GetProviderAccessToken ¶
func (s *Server) GetProviderAccessToken(ctx context.Context, provider string, groupId int32, checkAuthz bool) (oauth2.Token, string, error)
GetProviderAccessToken returns the access token for providers
func (*Server) GetRepositoryById ¶
func (s *Server) GetRepositoryById(ctx context.Context, in *pb.GetRepositoryByIdRequest) (*pb.GetRepositoryByIdResponse, error)
GetRepositoryById returns a repository for a given repository id
func (*Server) GetRepositoryByName ¶
func (s *Server) GetRepositoryByName(ctx context.Context, in *pb.GetRepositoryByNameRequest) (*pb.GetRepositoryByNameResponse, error)
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 mediator database The API is called with a group id
func (*Server) GetRoleById ¶
func (s *Server) GetRoleById(ctx context.Context, in *pb.GetRoleByIdRequest) (*pb.GetRoleByIdResponse, error)
GetRoleById is a service for getting a role by id
func (*Server) GetRoleByName ¶
func (s *Server) GetRoleByName(ctx context.Context, in *pb.GetRoleByNameRequest) (*pb.GetRoleByNameResponse, error)
GetRoleByName is a service for getting a role by name
func (*Server) GetRoles ¶
func (s *Server) GetRoles(ctx context.Context, in *pb.GetRolesRequest) (*pb.GetRolesResponse, error)
GetRoles is a service for getting roles
func (*Server) GetRolesByGroup ¶
func (s *Server) GetRolesByGroup(ctx context.Context, in *pb.GetRolesByGroupRequest) (*pb.GetRolesByGroupResponse, error)
GetRolesByGroup is a service for getting roles for a group
func (*Server) GetRuleTypeById ¶
func (s *Server) GetRuleTypeById(ctx context.Context, in *pb.GetRuleTypeByIdRequest) (*pb.GetRuleTypeByIdResponse, error)
GetRuleTypeById is a method to get a rule type by id
func (*Server) GetRuleTypeByName ¶
func (s *Server) GetRuleTypeByName(ctx context.Context, in *pb.GetRuleTypeByNameRequest) (*pb.GetRuleTypeByNameResponse, error)
GetRuleTypeByName is a method to get a rule type by name
func (*Server) GetUser ¶
func (s *Server) GetUser(ctx context.Context, _ *pb.GetUserRequest) (*pb.GetUserResponse, error)
GetUser is a service for getting personal user details
func (*Server) GetUserById ¶
func (s *Server) GetUserById(ctx context.Context, in *pb.GetUserByIdRequest) (*pb.GetUserByIdResponse, error)
GetUserById is a service for getting a user by id
func (*Server) GetUsers ¶
func (s *Server) GetUsers(ctx context.Context, in *pb.GetUsersRequest) (*pb.GetUsersResponse, error)
GetUsers is a service for getting a list of users
func (*Server) GetUsersByGroup ¶
func (s *Server) GetUsersByGroup(ctx context.Context, in *pb.GetUsersByGroupRequest) (*pb.GetUsersByGroupResponse, error)
GetUsersByGroup is a service for getting a list of users of a group
func (*Server) GetUsersByOrganization ¶
func (s *Server) GetUsersByOrganization(ctx context.Context, in *pb.GetUsersByOrganizationRequest) (*pb.GetUsersByOrganizationResponse, error)
GetUsersByOrganization is a service for getting a list of users of an organization
func (*Server) HandleEvents ¶
HandleEvents starts the event handler and blocks while handling events.
func (*Server) HandleGitHubWebHook ¶
func (s *Server) HandleGitHubWebHook() http.HandlerFunc
HandleGitHubWebHook handles incoming GitHub webhooks See https://docs.github.com/en/developers/webhooks-and-events/webhooks/about-webhooks for more information.
func (*Server) IsProviderCallAuthorized ¶
func (s *Server) IsProviderCallAuthorized(ctx context.Context, provider db.Provider, groupId int32) bool
IsProviderCallAuthorized checks if the request is authorized
func (*Server) ListArtifacts ¶
func (s *Server) ListArtifacts(ctx context.Context, in *pb.ListArtifactsRequest) (*pb.ListArtifactsResponse, error)
ListArtifacts lists all artifacts for a given group and provider nolint:gocyclo
func (*Server) ListPolicies ¶
func (s *Server) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error)
ListPolicies is a method to get all policies for a group
func (*Server) ListRepositories ¶
func (s *Server) ListRepositories(ctx context.Context, in *pb.ListRepositoriesRequest) (*pb.ListRepositoriesResponse, error)
ListRepositories returns a list of repositories for a given group This function will typically be called by the client to get a list of repositories that are registered present in the mediator database The API is called with a group id, limit and offset
func (*Server) ListRuleTypes ¶
func (s *Server) ListRuleTypes(ctx context.Context, in *pb.ListRuleTypesRequest) (*pb.ListRuleTypesResponse, error)
ListRuleTypes is a method to list all rule types for a given context
func (*Server) RefreshToken ¶
func (_ *Server) RefreshToken(_ context.Context, _ *pb.RefreshTokenRequest) (*pb.RefreshTokenResponse, error)
RefreshToken refreshes the access token
func (*Server) RegisterRepository ¶
func (s *Server) RegisterRepository(ctx context.Context, in *pb.RegisterRepositoryRequest) (*pb.RegisterRepositoryResponse, error)
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 repositories to be monitored by the mediator by provisioning a webhook on the repositor(ies). The API is called with a slice of repositories to register and a slice of events e.g.
grpcurl -plaintext -d '{
"repositories": [
{ "owner": "acme", "name": "widgets" },
{ "owner": "acme", "name": "gadgets" }
],
"events": [ "push", "issues" ]
}' 127.0.0.1:8090 mediator.v1.RepositoryService/RegisterRepository
nolint: gocyclo
func (*Server) RevokeOauthGroupToken ¶
func (s *Server) RevokeOauthGroupToken(ctx context.Context, in *pb.RevokeOauthGroupTokenRequest) (*pb.RevokeOauthGroupTokenResponse, error)
RevokeOauthGroupToken revokes the oauth token for a group
func (*Server) RevokeOauthTokens ¶
func (s *Server) RevokeOauthTokens(ctx context.Context, _ *pb.RevokeOauthTokensRequest) (*pb.RevokeOauthTokensResponse, error)
RevokeOauthTokens revokes the all oauth tokens for a provider This is in case of a security breach, where we need to revoke all tokens
func (*Server) StartGRPCServer ¶
StartGRPCServer starts a gRPC server and blocks while serving.
func (*Server) StartHTTPServer ¶
StartHTTPServer starts a HTTP server and registers the gRPC handler mux to it set store as a blank identifier for now as we will use it in the future
func (*Server) StoreProviderToken ¶
func (s *Server) StoreProviderToken(ctx context.Context, in *pb.StoreProviderTokenRequest) (*pb.StoreProviderTokenResponse, error)
StoreProviderToken stores the provider token for a group
func (*Server) SyncRepositories ¶
func (s *Server) SyncRepositories(ctx context.Context, in *pb.SyncRepositoriesRequest) (*pb.SyncRepositoriesResponse, error)
SyncRepositories synchronizes the repositories for a given provider and group
func (*Server) UpdateRuleType ¶
func (s *Server) UpdateRuleType(ctx context.Context, urt *pb.UpdateRuleTypeRequest) (*pb.UpdateRuleTypeResponse, error)
UpdateRuleType is a method to update a rule type
func (*Server) Verify ¶
func (*Server) Verify(ctx context.Context, _ *pb.VerifyRequest) (*pb.VerifyResponse, error)
Verify verifies the access token
func (*Server) VerifyProviderTokenFrom ¶
func (s *Server) VerifyProviderTokenFrom(ctx context.Context, in *pb.VerifyProviderTokenFromRequest) (*pb.VerifyProviderTokenFromResponse, error)
VerifyProviderTokenFrom verifies the provider token since a timestamp