Documentation
¶
Overview ¶
Package controlplane contains the gRPC server implementation for the control plane
Package controlplane contains the control plane API for the minder.
Index ¶
- Constants
- func AuthUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (any, error)
- func AuthorizedOnProject(ctx context.Context, projectID uuid.UUID) error
- func CreateDefaultRecordsForOrg(ctx context.Context, qtx db.Querier, org db.Project, projectName string) (*pb.Project, []int32, error)
- func DeleteUser(ctx context.Context, store db.Store, userId string) error
- func HandleEvents(ctx context.Context, store db.Store, cfg *config.Config)
- func NewMetrics() *metrics
- func RegisterGRPCServices(s *Server)
- func RegisterGatewayHTTPHandlers(ctx context.Context, gwmux *runtime.ServeMux, grpcAddress string, ...)
- func SubscribeToIdentityEvents(ctx context.Context, store db.Store, cfg *config.Config) error
- type AccountEvent
- type HasProtoContext
- type OrgMeta
- type ProjectIDGetter
- type ProjectMeta
- type ProviderNameGetter
- type Server
- func (s *Server) CheckHealth(_ context.Context, _ *pb.CheckHealthRequest) (*pb.CheckHealthResponse, error)
- func (s *Server) ConsumeEvents(c ...events.Consumer)
- func (s *Server) CreateProfile(ctx context.Context, cpr *minderv1.CreateProfileRequest) (*minderv1.CreateProfileResponse, error)
- func (s *Server) CreateRuleType(ctx context.Context, crt *minderv1.CreateRuleTypeRequest) (*minderv1.CreateRuleTypeResponse, error)
- func (s *Server) CreateUser(ctx context.Context, _ *pb.CreateUserRequest) (*pb.CreateUserResponse, error)
- func (s *Server) DeleteProfile(ctx context.Context, in *minderv1.DeleteProfileRequest) (*minderv1.DeleteProfileResponse, error)
- func (s *Server) DeleteRepositoryById(ctx context.Context, in *pb.DeleteRepositoryByIdRequest) (*pb.DeleteRepositoryByIdResponse, error)
- func (s *Server) DeleteRepositoryByName(ctx context.Context, in *pb.DeleteRepositoryByNameRequest) (*pb.DeleteRepositoryByNameResponse, error)
- func (s *Server) DeleteRuleType(ctx context.Context, in *minderv1.DeleteRuleTypeRequest) (*minderv1.DeleteRuleTypeResponse, error)
- func (s *Server) DeleteUser(ctx context.Context, _ *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) GetArtifactByName(ctx context.Context, in *pb.GetArtifactByNameRequest) (*pb.GetArtifactByNameResponse, error)
- func (s *Server) GetAuthorizationURL(ctx context.Context, req *pb.GetAuthorizationURLRequest) (*pb.GetAuthorizationURLResponse, error)
- func (s *Server) GetProfileById(ctx context.Context, in *minderv1.GetProfileByIdRequest) (*minderv1.GetProfileByIdResponse, error)
- func (s *Server) GetProfileStatusByName(ctx context.Context, in *minderv1.GetProfileStatusByNameRequest) (*minderv1.GetProfileStatusByNameResponse, error)
- func (s *Server) GetProfileStatusByProject(ctx context.Context, in *minderv1.GetProfileStatusByProjectRequest) (*minderv1.GetProfileStatusByProjectResponse, 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) GetRuleTypeById(ctx context.Context, in *minderv1.GetRuleTypeByIdRequest) (*minderv1.GetRuleTypeByIdResponse, error)
- func (s *Server) GetRuleTypeByName(ctx context.Context, in *minderv1.GetRuleTypeByNameRequest) (*minderv1.GetRuleTypeByNameResponse, error)
- func (s *Server) GetUser(ctx context.Context, _ *pb.GetUserRequest) (*pb.GetUserResponse, error)
- func (s *Server) HandleEvents(ctx context.Context) func() error
- func (s *Server) HandleGitHubWebHook() http.HandlerFunc
- func (s *Server) ListArtifacts(ctx context.Context, in *pb.ListArtifactsRequest) (*pb.ListArtifactsResponse, error)
- func (s *Server) ListProfiles(ctx context.Context, in *minderv1.ListProfilesRequest) (*minderv1.ListProfilesResponse, error)
- func (s *Server) ListRemoteRepositoriesFromProvider(ctx context.Context, in *pb.ListRemoteRepositoriesFromProviderRequest) (*pb.ListRemoteRepositoriesFromProviderResponse, error)
- func (s *Server) ListRepositories(ctx context.Context, in *pb.ListRepositoriesRequest) (*pb.ListRepositoriesResponse, error)
- func (s *Server) ListRuleTypes(ctx context.Context, in *minderv1.ListRuleTypesRequest) (*minderv1.ListRuleTypesResponse, error)
- func (s *Server) Register(topic string, handler events.Handler, mdw ...message.HandlerMiddleware)
- func (s *Server) RegisterRepository(ctx context.Context, in *pb.RegisterRepositoryRequest) (*pb.RegisterRepositoryResponse, 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) UpdateProfile(ctx context.Context, cpr *minderv1.UpdateProfileRequest) (*minderv1.UpdateProfileResponse, error)
- func (s *Server) UpdateRuleType(ctx context.Context, urt *minderv1.UpdateRuleTypeRequest) (*minderv1.UpdateRuleTypeResponse, error)
- func (s *Server) VerifyProviderTokenFrom(ctx context.Context, in *pb.VerifyProviderTokenFromRequest) (*pb.VerifyProviderTokenFromResponse, error)
- type ServerOption
Constants ¶
const PaginationLimit = 10
PaginationLimit is the maximum number of items that can be returned in a single page
Variables ¶
This section is empty.
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 AuthorizedOnProject ¶
AuthorizedOnProject checks if the request is authorized for the given project, and returns an error if the request is not authorized.
func CreateDefaultRecordsForOrg ¶
func CreateDefaultRecordsForOrg(ctx context.Context, qtx db.Querier, org db.Project, projectName string) (*pb.Project, []int32, error)
CreateDefaultRecordsForOrg creates the default records, such as projects, roles and provider for the organization
func DeleteUser ¶
DeleteUser deletes a user and all their associated data from the minder database
func HandleEvents ¶
HandleEvents fetches events from the identity provider and performs any related changes to the minder database
func NewMetrics ¶
func NewMetrics() *metrics
NewMetrics creates a new controlplane metrics instance.
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 AccountEvent ¶
type AccountEvent struct {
Time int64 `json:"time"`
Type string `json:"type"`
RealmId string `json:"realmId"`
ClientId string `json:"clientId"`
UserId string `json:"userId"`
}
AccountEvent is an event returned by the identity provider
type HasProtoContext ¶ added in v0.0.21
HasProtoContext is an interface that can be implemented by a request
type OrgMeta ¶
type OrgMeta struct {
Company string `json:"company"`
}
OrgMeta is the metadata associated with an organization
type ProjectIDGetter ¶
type ProjectIDGetter interface {
// GetProjectId returns the project ID
GetProjectId() string
}
ProjectIDGetter is an interface that can be implemented by a request
type ProjectMeta ¶
type ProjectMeta struct {
Description string `json:"description"`
}
ProjectMeta is the metadata associated with a project
type ProviderNameGetter ¶ added in v0.0.21
type ProviderNameGetter interface {
// GetProvider returns the provider name
GetProvider() string
}
ProviderNameGetter is an interface that can be implemented by a request
type Server ¶
type Server struct {
pb.UnimplementedHealthServiceServer
pb.UnimplementedOAuthServiceServer
pb.UnimplementedUserServiceServer
pb.UnimplementedRepositoryServiceServer
pb.UnimplementedProfileServiceServer
pb.UnimplementedArtifactServiceServer
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, cpm *metrics, cfg *config.Config, vldtr auth.JwtValidator, opts ...ServerOption, ) (*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
func (*Server) ConsumeEvents ¶
ConsumeEvents implements events.Registrar
func (*Server) CreateProfile ¶
func (s *Server) CreateProfile(ctx context.Context, cpr *minderv1.CreateProfileRequest) (*minderv1.CreateProfileResponse, error)
CreateProfile creates a profile for a project
func (*Server) CreateRuleType ¶
func (s *Server) CreateRuleType( ctx context.Context, crt *minderv1.CreateRuleTypeRequest, ) (*minderv1.CreateRuleTypeResponse, error)
CreateRuleType is a method to create a rule type
func (*Server) CreateUser ¶
func (s *Server) CreateUser(ctx context.Context, _ *pb.CreateUserRequest) (*pb.CreateUserResponse, error)
CreateUser is a service for user self registration
func (*Server) DeleteProfile ¶
func (s *Server) DeleteProfile(ctx context.Context, in *minderv1.DeleteProfileRequest) (*minderv1.DeleteProfileResponse, error)
DeleteProfile is a method to delete a profile
func (*Server) DeleteRepositoryById ¶
func (s *Server) DeleteRepositoryById(ctx context.Context, in *pb.DeleteRepositoryByIdRequest) (*pb.DeleteRepositoryByIdResponse, error)
DeleteRepositoryById deletes a repository by name
func (*Server) DeleteRepositoryByName ¶
func (s *Server) DeleteRepositoryByName(ctx context.Context, in *pb.DeleteRepositoryByNameRequest) (*pb.DeleteRepositoryByNameResponse, error)
DeleteRepositoryByName deletes a repository by name
func (*Server) DeleteRuleType ¶
func (s *Server) DeleteRuleType( ctx context.Context, in *minderv1.DeleteRuleTypeRequest, ) (*minderv1.DeleteRuleTypeResponse, error)
DeleteRuleType is a method to delete a rule type
func (*Server) DeleteUser ¶
func (s *Server) DeleteUser(ctx context.Context, _ *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error)
DeleteUser is a service for user self deletion
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) GetArtifactByName ¶ added in v0.0.22
func (s *Server) GetArtifactByName(ctx context.Context, in *pb.GetArtifactByNameRequest) (*pb.GetArtifactByNameResponse, error)
GetArtifactByName gets an artifact by name 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) GetProfileById ¶
func (s *Server) GetProfileById(ctx context.Context, in *minderv1.GetProfileByIdRequest) (*minderv1.GetProfileByIdResponse, error)
GetProfileById is a method to get a profile by id
func (*Server) GetProfileStatusByName ¶
func (s *Server) GetProfileStatusByName(ctx context.Context, in *minderv1.GetProfileStatusByNameRequest) (*minderv1.GetProfileStatusByNameResponse, error)
GetProfileStatusByName is a method to get profile status nolint:gocyclo // TODO: Refactor this to be more readable
func (*Server) GetProfileStatusByProject ¶
func (s *Server) GetProfileStatusByProject(ctx context.Context, in *minderv1.GetProfileStatusByProjectRequest) (*minderv1.GetProfileStatusByProjectResponse, error)
GetProfileStatusByProject is a method to get profile status for a project
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 minder database The API is called with a project id
func (*Server) GetRuleTypeById ¶
func (s *Server) GetRuleTypeById( ctx context.Context, in *minderv1.GetRuleTypeByIdRequest, ) (*minderv1.GetRuleTypeByIdResponse, error)
GetRuleTypeById is a method to get a rule type by id
func (*Server) GetRuleTypeByName ¶
func (s *Server) GetRuleTypeByName( ctx context.Context, in *minderv1.GetRuleTypeByNameRequest, ) (*minderv1.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) 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) ListArtifacts ¶
func (s *Server) ListArtifacts(ctx context.Context, in *pb.ListArtifactsRequest) (*pb.ListArtifactsResponse, error)
ListArtifacts lists all artifacts for a given project and provider nolint:gocyclo
func (*Server) ListProfiles ¶
func (s *Server) ListProfiles(ctx context.Context, in *minderv1.ListProfilesRequest) (*minderv1.ListProfilesResponse, error)
ListProfiles is a method to get all profiles for a project
func (*Server) ListRemoteRepositoriesFromProvider ¶
func (s *Server) ListRemoteRepositoriesFromProvider( ctx context.Context, in *pb.ListRemoteRepositoriesFromProviderRequest, ) (*pb.ListRemoteRepositoriesFromProviderResponse, error)
ListRemoteRepositoriesFromProvider returns a list of repositories from a provider
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 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 project id, limit and offset
func (*Server) ListRuleTypes ¶
func (s *Server) ListRuleTypes( ctx context.Context, in *minderv1.ListRuleTypesRequest, ) (*minderv1.ListRuleTypesResponse, error)
ListRuleTypes is a method to list all rule types for a given context
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 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 (*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 project
func (*Server) UpdateProfile ¶ added in v0.0.16
func (s *Server) UpdateProfile(ctx context.Context, cpr *minderv1.UpdateProfileRequest) (*minderv1.UpdateProfileResponse, error)
UpdateProfile updates a profile for a project
func (*Server) UpdateRuleType ¶
func (s *Server) UpdateRuleType( ctx context.Context, urt *minderv1.UpdateRuleTypeRequest, ) (*minderv1.UpdateRuleTypeResponse, error)
UpdateRuleType is a method to update a rule type
func (*Server) VerifyProviderTokenFrom ¶
func (s *Server) VerifyProviderTokenFrom(ctx context.Context, in *pb.VerifyProviderTokenFromRequest) (*pb.VerifyProviderTokenFromResponse, error)
VerifyProviderTokenFrom verifies the provider token since a timestamp
type ServerOption ¶
type ServerOption func(*Server)
ServerOption is a function that modifies a server
func WithProviderMetrics ¶
func WithProviderMetrics(mt provtelemetry.ProviderMetrics) ServerOption
WithProviderMetrics sets the provider metrics for the server