Documentation
¶
Index ¶
- Constants
- func AddCommonFlagsToCommand(c *cobra.Command, o *Options)
- func CollectExtraTelemetryData(environ []string) map[string]string
- type AgentAPI
- func (a *AgentAPI) GetAgentKey(ctx context.Context) (api.AgentKey, error)
- func (a *AgentAPI) GetGitLabExternalURL(ctx context.Context) (url.URL, error)
- func (a *AgentAPI) HandleProcessingError(ctx context.Context, log *slog.Logger, msg string, err error, ...)
- func (a *AgentAPI) MakeGitLabRequest(ctx context.Context, path string, opts ...modagent.GitLabRequestOption) (*modagent.GitLabResponse, error)
- func (a *AgentAPI) TryGetAgentKey() (api.AgentKey, bool)
- type AgentSharedAPI
- type CancelRunWhenLeaderFunc
- type ConfigurationWatcher
- type FactoriesLayer
- type InMemAPIServer
- type LeaderElector
- type LeaderModule
- type LeaderRunner
- type LeaderRunnerInterface
- type ListenAPIServer
- type ModuleRunner
- type ModuleRunnerInterface
- type ModuleStartFunc
- type ModuleStopFunc
- type ModuleStopWaitFunc
- type ObsTools
- type Options
- func (o *Options) Complete(envVarAgentToken, defaultLogLevel, defaultGRPCLogLevel string) error
- func (o *Options) ConstructKASConnection(ot *ObsTools, userAgent string, agentType api.AgentType) (*grpc.ClientConn, error)
- func (o *Options) ConstructObservabilityTools() (*ObsTools, func() error, error)
- func (o *Options) NewRPCAPIFactory() modshared.RPCAPIFactory
- type PrivateAPIServer
- type Runner
Constants ¶
const ( AgentName = "gitlab-agent" DefaultAPIListenNetwork = "tcp" DefaultPrivateAPIListenNetwork = "tcp" DefaultPrivateAPIListenAddress = ":8081" DefaultObservabilityListenNetwork = "tcp" DefaultObservabilityListenAddress = ":8080" )
Variables ¶
This section is empty.
Functions ¶
func AddCommonFlagsToCommand ¶
Types ¶
type AgentAPI ¶
type AgentAPI struct {
ModuleName string
AgentKey *syncz.ValueHolder[api.AgentKey]
GitLabExternalURL *syncz.ValueHolder[url.URL]
Client gitlab_access_rpc.GitlabAccessClient
}
AgentAPI is an implementation of modagent.API.
func (*AgentAPI) GetAgentKey ¶
func (*AgentAPI) GetGitLabExternalURL ¶
func (*AgentAPI) HandleProcessingError ¶
func (*AgentAPI) MakeGitLabRequest ¶
func (a *AgentAPI) MakeGitLabRequest(ctx context.Context, path string, opts ...modagent.GitLabRequestOption) (*modagent.GitLabResponse, error)
type AgentSharedAPI ¶
type AgentSharedAPI struct {
}
type CancelRunWhenLeaderFunc ¶
type CancelRunWhenLeaderFunc func()
type ConfigurationWatcher ¶
ConfigurationWatcher provides a mechanism to receive new configuration objects.
type FactoriesLayer ¶
type FactoriesLayer[CF, CM any] struct { Log *slog.Logger Config func(name string) CF LR LeaderRunnerInterface[CM] MR ModuleRunnerInterface[CM] Factories []modagent.Factory[CF, CM] }
func (*FactoriesLayer[CF, CM]) ToStageFuncs ¶
func (l *FactoriesLayer[CF, CM]) ToStageFuncs() ([]stager.StageFunc, error)
type InMemAPIServer ¶
type InMemAPIServer struct {
Server *grpc.Server
InMemConn *grpc.ClientConn
InMemListener net.Listener
}
InMemAPIServer represents agentk API that kas can talk to when running in agentk->kas tunnel mode.
func NewInMemAPIServer ¶
func NewInMemAPIServer(ot *ObsTools, factory modshared.RPCAPIFactory, v protovalidate.Validator) (*InMemAPIServer, error)
func (*InMemAPIServer) Close ¶
func (s *InMemAPIServer) Close() error
func (*InMemAPIServer) Start ¶
func (s *InMemAPIServer) Start(stage stager.Stage)
type LeaderElector ¶
type LeaderModule ¶
type LeaderModule struct {
// contains filtered or unexported fields
}
type LeaderRunner ¶
type LeaderRunner[CM any] struct { // contains filtered or unexported fields }
func NewLeaderRunner ¶
func NewLeaderRunner[CM any](leaderElector LeaderElector) *LeaderRunner[CM]
func (*LeaderRunner[CM]) Run ¶
func (r *LeaderRunner[CM]) Run(ctx context.Context)
Run starts the leader election process and starts and stops the modules depending on if it is the leader or not.
func (*LeaderRunner[CM]) RunWhenLeader ¶
func (r *LeaderRunner[CM]) RunWhenLeader(ctx context.Context, startFn ModuleStartFunc, stopFn ModuleStopFunc) (CancelRunWhenLeaderFunc, error)
RunWhenLeader registers a module start and stop function with the leader runner. The function that is returned must be used to unregister the leader module.
func (*LeaderRunner[CM]) WrapModule ¶
func (r *LeaderRunner[CM]) WrapModule(m modagent.Module[CM]) modagent.Module[CM]
type LeaderRunnerInterface ¶
type ListenAPIServer ¶
type ListenAPIServer struct {
Log *slog.Logger
ListenNetwork, ListenAddress string
CertFile, KeyFile string
AuxCancel context.CancelFunc
Server *grpc.Server
}
ListenAPIServer represents agentk API that kas can talk to. It can be either: - in-memory. This is the case when agentk connects to kas. - exposed on an address. This is the case when kas connects to agentk.
func NewListenAPIServer ¶
func NewListenAPIServer(log *slog.Logger, ot *ObsTools, factory modshared.RPCAPIFactory, listenNetwork, listenAddress, certFile, keyFile, jwtSecretFile, jwtIssuer, jwtAudience, mtlsClientCAFile string, mtlsEnabled bool, v protovalidate.Validator) (*ListenAPIServer, error)
func (*ListenAPIServer) Start ¶
func (s *ListenAPIServer) Start(stage stager.Stage)
type ModuleRunner ¶
type ModuleRunner[CD, CM any] struct { Log *slog.Logger Watcher ConfigurationWatcher[CD] Data2Config func(CD) (CM, []any) // second return value is extra attributes for the logger // contains filtered or unexported fields }
func (*ModuleRunner[CD, CM]) RegisterModules ¶
func (r *ModuleRunner[CD, CM]) RegisterModules(modules ...modagent.Module[CM]) []stager.StageFunc
RegisterModules registers modules with the runner. It returns staged functions to run modules.
func (*ModuleRunner[CD, CM]) RunConfigurationRefresh ¶
func (r *ModuleRunner[CD, CM]) RunConfigurationRefresh(ctx context.Context) error
type ModuleRunnerInterface ¶
type ModuleStartFunc ¶
type ModuleStartFunc func()
type ModuleStopFunc ¶
type ModuleStopFunc func() ModuleStopWaitFunc
type ModuleStopWaitFunc ¶
type ObsTools ¶
type ObsTools struct {
Reg *prometheus.Registry
TP trace.TracerProvider
MP otelmetric.MeterProvider
P propagation.TextMapPropagator
StreamProm grpc.StreamServerInterceptor
UnaryProm grpc.UnaryServerInterceptor
StreamClientProm grpc.StreamClientInterceptor
UnaryClientProm grpc.UnaryClientInterceptor
}
type Options ¶
type Options struct {
Log *slog.Logger
LogLevel *slog.LevelVar
GRPCHandler slog.Handler
GRPCLogLevel *slog.LevelVar
Validator protovalidate.Validator
AgentKey *syncz.ValueHolder[api.AgentKey]
GitLabExternalURL *syncz.ValueHolder[url.URL]
KASAddress string
KASCACertFile string
KASHeaders []string
KASSkipTLSVerify bool
KASTLSServerName string
ObservabilityListenNetwork string
ObservabilityListenAddress string
ObservabilityCertFile string
ObservabilityKeyFile string
TokenFile string
AgentToken api.AgentToken
}
func (*Options) ConstructKASConnection ¶
func (*Options) ConstructObservabilityTools ¶
func (*Options) NewRPCAPIFactory ¶
func (o *Options) NewRPCAPIFactory() modshared.RPCAPIFactory
type PrivateAPIServer ¶
type PrivateAPIServer struct {
Log *slog.Logger
ListenNetwork string
ListenAddress string
OwnURL grpctool.URLTarget
OwnURLScheme string
OwnURLPort string
Server grpctool.GRPCServer
ListenServer *grpc.Server
InMemServer *grpc.Server
InMemListener net.Listener
AgentPool grpctool.PoolInterface[grpctool.URLTarget]
AgentPoolClose func()
AuxCancel context.CancelFunc
}
func NewPrivateAPIServer ¶
func NewPrivateAPIServer(log *slog.Logger, ot *ObsTools, errRep errz.ErrReporter, factory modshared.RPCAPIFactory, v protovalidate.Validator, userAgent, listenNetwork, listenAddress, certFile, keyFile, caCertFile, jwtAuthFile string) (*PrivateAPIServer, error)
func (*PrivateAPIServer) Close ¶
func (s *PrivateAPIServer) Close() error
func (*PrivateAPIServer) Start ¶
func (s *PrivateAPIServer) Start(stage stager.Stage)
type Runner ¶
type Runner interface {
// RunWhenLeader registers the given start and stop functions for this module with the leader runner.
// When the leader runner is elected as the leader it will execute the start function and
// when the leader runner lost the leadership it will execute the stop function.
// The start function must be able to be triggered multiple times (with intermediate stop executions)
// without having to rely on a new agent configuration.
// The function that is returned must be used to unregister the module
// from the leader runner in case a shutdown is initiated or a previously registered start function
// became invalid, for example because a new agent configuration turned out to be invalid.
RunWhenLeader(ctx context.Context, startFn ModuleStartFunc, stopFunc ModuleStopFunc) (CancelRunWhenLeaderFunc, error)
}