gapi

package
v0.65.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 31 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotEnabled = errors.New("grpc api client is not enabled")

ErrNotEnabled is returned by NewClient when the client is explicitly disabled.

Functions

func BlueprintSummaryToProto

func BlueprintSummaryToProto(m *models.BlueprintSummary) *commonv1.BlueprintSummary

BlueprintSummaryToProto converts a Go BlueprintSummary model to its protobuf message.

func CompleteUserWebFlowToProto

func CompleteUserWebFlowToProto(m *models.CompleteUserWebFlow) *commonv1.CompleteUserWebFlow

CompleteUserWebFlowToProto converts a Go model to a protobuf message.

func OnboardUserDeviceFlowToProto

func OnboardUserDeviceFlowToProto(m *models.OnboardUserDeviceFlow) *commonv1.OnboardUserDeviceFlow

OnboardUserDeviceFlowToProto converts a Go model to a protobuf message.

func OnboardUserRuleToProto added in v0.40.0

func OnboardUserRuleToProto(m *models.OnboardUserRule) *commonv1.OnboardUserRule

OnboardUserRuleToProto converts a Go model to a protobuf message.

func OnboardUserWebFlowToProto

func OnboardUserWebFlowToProto(m *models.OnboardUserWebFlow) *commonv1.OnboardUserWebFlow

OnboardUserWebFlowToProto converts a Go model to a protobuf message.

func OrgBlueprintToProto added in v0.48.0

func OrgBlueprintToProto(m *models.OrgBlueprint) *provisionerv1.OrgBlueprint

OrgBlueprintToProto converts a Go OrgBlueprint model to its protobuf message.

func ProtoToBlueprintSummary

func ProtoToBlueprintSummary(pb *commonv1.BlueprintSummary) *models.BlueprintSummary

ProtoToBlueprintSummary converts a protobuf BlueprintSummary message to its Go model.

func ProtoToBlueprintValidation added in v0.48.0

func ProtoToBlueprintValidation(pb *provisionerv1.ValidateBlueprintResponse) (*models.BlueprintValidation, error)

ProtoToBlueprintValidation converts a protobuf ValidateBlueprintResponse message to its Go model, decoding ResolvedBlueprint generically into Blueprint (see BlueprintValidation). ResolvedBlueprint is only set by the server when Valid is true, so Blueprint is left nil for any invalid submission; returns an error only if a present ResolvedBlueprint fails to parse as YAML.

func ProtoToCompleteUserWebFlow

func ProtoToCompleteUserWebFlow(pb *commonv1.CompleteUserWebFlow) *models.CompleteUserWebFlow

ProtoToCompleteUserWebFlow converts a protobuf message to a Go model.

func ProtoToInjectNamespaces added in v0.38.0

ProtoToInjectNamespaces converts a protobuf ListInjectNamespacesResponse message to its Go model.

func ProtoToInjectWorkload added in v0.38.0

func ProtoToInjectWorkload(pb *provisionerv1.InjectWorkload) *models.InjectWorkload

ProtoToInjectWorkload converts a protobuf InjectWorkload message to its Go model.

func ProtoToNodeSelectorOptions added in v0.65.4

ProtoToNodeSelectorOptions converts a GetNodeSelectorOptionsResponse to its Go model. Keys and values are never nil, so they marshal as [] not null.

func ProtoToOnboardUserDeviceFlow

func ProtoToOnboardUserDeviceFlow(pb *commonv1.OnboardUserDeviceFlow) *models.OnboardUserDeviceFlow

ProtoToOnboardUserDeviceFlow converts a protobuf message to a Go model.

func ProtoToOnboardUserRule added in v0.40.0

func ProtoToOnboardUserRule(pb *commonv1.OnboardUserRule) *models.OnboardUserRule

ProtoToOnboardUserRule converts a protobuf message to a Go model.

func ProtoToOnboardUserWebFlow

func ProtoToOnboardUserWebFlow(pb *commonv1.OnboardUserWebFlow) *models.OnboardUserWebFlow

ProtoToOnboardUserWebFlow converts a protobuf message to a Go model.

func ProtoToOrgBlueprint added in v0.48.0

func ProtoToOrgBlueprint(pb *provisionerv1.OrgBlueprint) *models.OrgBlueprint

ProtoToOrgBlueprint converts a protobuf OrgBlueprint message to its Go model.

func ProtoToQueryDescriptor added in v0.35.0

func ProtoToQueryDescriptor(desc *queryv1.Descriptor) *models.QueryDescriptor

ProtoToQueryDescriptor converts a query.v1.Descriptor proto into the JSON shape served by a resource's _schema HTTP endpoint.

func ProtoToRepo added in v0.38.0

func ProtoToRepo(pb *identityv1.Repo) *models.Repo

ProtoToRepo converts a protobuf Repo message to its Go model.

func ProtoToRepoOwner added in v0.38.0

func ProtoToRepoOwner(pb *identityv1.RepoOwner) *models.RepoOwner

ProtoToRepoOwner converts a protobuf RepoOwner message to its Go model.

func ProtoToUser

func ProtoToUser(pb *commonv1.User) *models.User

func ProtoToUserCredential

func ProtoToUserCredential(pb *commonv1.UserCredential) *models.UserCredential

ProtoToUserCredential converts a protobuf message to a Go model.

func ProtoToUserOnboardCapability

func ProtoToUserOnboardCapability(pb *commonv1.UserOnboardCapability) *models.OnboardCapability

ProtoToUserOnboardCapability converts a protobuf message to a Go model.

func ProtoToUserResult added in v0.40.0

func ProtoToUserResult(pb *commonv1.UserResult) *models.UserResult

ProtoToUserResult converts a protobuf message to a Go model.

func ProtoToWorkspaceDetails

func ProtoToWorkspaceDetails(pb *commonv1.WorkspaceDetails) *models.WorkspaceDetails

ProtoToWorkspaceDetails converts a protobuf WorkspaceDetails message to its Go model.

func ProtoToWorkspaceStatus

func ProtoToWorkspaceStatus(pb *commonv1.WorkspaceStatus) *models.WorkspaceStatus

ProtoToWorkspaceStatus converts a protobuf WorkspaceStatus message to its Go model.

func QueryPayloadToProto added in v0.35.0

func QueryPayloadToProto(p *models.QueryPayload) (*queryv1.Payload, error)

QueryPayloadToProto converts a client-issued JSON query payload into a query.v1.Payload proto, rejecting any op/dir/filter-op values outside the known enum strings. It does not validate field names, per-field operator permissions, or value types against a resource's schema — that's query.Validate's job (pkg/query) once the caller has a Descriptor to validate against.

func UserCredentialToProto

func UserCredentialToProto(c *models.UserCredential) *commonv1.UserCredential

UserCredentialToProto converts a Go model to a protobuf message.

func UserOnboardCapabilityToProto

func UserOnboardCapabilityToProto(m *models.OnboardCapability) *commonv1.UserOnboardCapability

UserOnboardCapabilityToProto converts a Go model to a protobuf message.

func UserResultToProto added in v0.40.0

func UserResultToProto(m *models.UserResult) *commonv1.UserResult

UserResultToProto converts a Go model to a protobuf message.

func UserToProto

func UserToProto(u *models.User) *commonv1.User

func WithMD

func WithMD(ctx context.Context, kv ...string) context.Context

WithMD returns a new context with the provided key-value pairs added to outgoing gRPC metadata.

func WorkspaceDetailsToProto

func WorkspaceDetailsToProto(m *models.WorkspaceDetails) *commonv1.WorkspaceDetails

WorkspaceDetailsToProto converts a Go WorkspaceDetails model to its protobuf message.

func WorkspaceStatusToProto

func WorkspaceStatusToProto(m *models.WorkspaceStatus) *commonv1.WorkspaceStatus

WorkspaceStatusToProto converts a Go WorkspaceStatus model to its protobuf message.

Types

type AllowedCaller

type AllowedCaller struct {
	Namespace      string `yaml:"namespace"`
	ServiceAccount string `yaml:"serviceAccount"`
}

type Caller

type Caller struct{ Namespace, ServiceAccount string }

type Client

type Client struct {
	Conn *grpc.ClientConn
	// contains filtered or unexported fields
}

Client gRPC client

func NewClient

func NewClient(cfg ClientConfig) (*Client, error)

NewClient creates and returns a new gRPC client connection.

func (*Client) Close

func (c *Client) Close() error

Close the gRPC client connection.

type ClientConfig

type ClientConfig struct {
	// Address of the gRPC server, e.g. "localhost:50051".
	// Use the dns:/// scheme to enable client-side round-robin load balancing
	// across multiple endpoints (e.g. a headless Service in Kubernetes):
	// "dns:///grpc-server-headless.default.svc.cluster.local:50051"
	Address string `yaml:"address"`

	// ServerName is optional TLS ServerName for hostname verification.
	// Required if CACertPath is set and cert SAN doesn't match address host.
	ServerName string `yaml:"serverName"`

	// TokenFilePath is path to file containing token for authentication.
	// The file is read on each request to support token rotation.
	TokenFilePath string `yaml:"tokenFilePath"`

	// CACertPath is optional path to CA cert for TLS.
	//  If empty, TLS is disabled and credentials are insecure.
	CACertPath string `yaml:"caCertPath"`
}

ClientConfig holds configuration for gRPC client

func (*ClientConfig) IsEnabled

func (c *ClientConfig) IsEnabled() bool

type Server

type Server struct {
	GrpcServer *grpc.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg *ServerConfig, stopGracefully bool) (*Server, error)

func (*Server) AddInterceptor

func (s *Server) AddInterceptor(interceptor grpc.UnaryServerInterceptor)

func (*Server) RegisterService

func (s *Server) RegisterService(regFunc ServiceRegistrationFunc) error

RegisterService adds a service registration callback

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

type ServerConfig

type ServerConfig struct {
	Port            int             `yaml:"port"`
	EnableTLS       bool            `yaml:"enableTLS"`
	CertFile        string          `yaml:"certFile"`
	KeyFile         string          `yaml:"keyFile"`
	CertReloadDelay time.Duration   `yaml:"certReloadDelay"`
	AuthEnabled     bool            `yaml:"authEnabled"`
	IssuerURL       string          `yaml:"issuerURL"`
	Audience        string          `yaml:"audience"`
	Allowed         []AllowedCaller `yaml:"allowed"`
}

type ServiceRegistrationFunc

type ServiceRegistrationFunc func(*grpc.Server) error

ServiceRegistrationFunc is a callback function to register services on the gRPC server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL