Skip to content

Commit

Permalink
Expose TeleportProcess.GetClusterFeatures function (#40715)
Browse files Browse the repository at this point in the history
* Expose `TeleportProcess.GetClusterFeatures` function

This PR exposes `TeleportProcess.GetClusterFeatures` so it can be used
by external packages.

Signed-off-by: Tiago Silva <[email protected]>

* consolidate into a single method

---------

Signed-off-by: Tiago Silva <[email protected]>
  • Loading branch information
tigrato committed May 2, 2024
1 parent 3663898 commit 39deb07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/service/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ func (process *TeleportProcess) initDiscoveryService() error {
ServerID: process.Config.HostUUID,
Log: process.log,
ClusterName: conn.ClientIdentity.ClusterName,
ClusterFeatures: process.GetClusterFeatures,
PollInterval: process.Config.Discovery.PollInterval,
ServerCredentials: tlsConfig,
AccessGraphConfig: accessGraphCfg,
ClusterFeatures: process.getClusterFeatures,
})
if err != nil {
return trace.Wrap(err)
Expand Down
4 changes: 2 additions & 2 deletions lib/service/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (process *TeleportProcess) initKubernetes() {
if conn == nil {
return trace.Wrap(err)
}
if !process.getClusterFeatures().Kubernetes {
if !process.GetClusterFeatures().Kubernetes {
log.Warn("Warning: Kubernetes service not intialized because Teleport Auth Server is not licensed for Kubernetes Access. ",
"Please contact the cluster administrator to enable it.")
return nil
Expand Down Expand Up @@ -224,7 +224,7 @@ func (process *TeleportProcess) initKubernetesService(log *logrus.Entry, conn *C
LockWatcher: lockWatcher,
CheckImpersonationPermissions: cfg.Kube.CheckImpersonationPermissions,
PublicAddr: publicAddr,
ClusterFeatures: process.getClusterFeatures,
ClusterFeatures: process.GetClusterFeatures,
},
TLS: tlsConfig,
AccessPoint: accessPoint,
Expand Down
11 changes: 6 additions & 5 deletions lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ func (process *TeleportProcess) setClusterFeatures(features *proto.Features) {
}
}

func (process *TeleportProcess) getClusterFeatures() proto.Features {
// GetClusterFeatures returns the cluster features.
func (process *TeleportProcess) GetClusterFeatures() proto.Features {
process.Lock()
defer process.Unlock()

Expand Down Expand Up @@ -1771,7 +1772,7 @@ func (process *TeleportProcess) initAuthService() error {
}

checkingEmitter, err := events.NewCheckingEmitter(events.CheckingEmitterConfig{
Inner: events.NewMultiEmitter(events.NewLoggingEmitter(process.getClusterFeatures().Cloud), emitter),
Inner: events.NewMultiEmitter(events.NewLoggingEmitter(process.GetClusterFeatures().Cloud), emitter),
Clock: process.Clock,
ClusterName: clusterName,
})
Expand Down Expand Up @@ -2460,7 +2461,7 @@ func (process *TeleportProcess) proxyPublicAddr() utils.NetAddr {
// It is caller's responsibility to call Close on the emitter once done.
func (process *TeleportProcess) NewAsyncEmitter(clt apievents.Emitter) (*events.AsyncEmitter, error) {
emitter, err := events.NewCheckingEmitter(events.CheckingEmitterConfig{
Inner: events.NewMultiEmitter(events.NewLoggingEmitter(process.getClusterFeatures().Cloud), clt),
Inner: events.NewMultiEmitter(events.NewLoggingEmitter(process.GetClusterFeatures().Cloud), clt),
Clock: process.Clock,
})
if err != nil {
Expand Down Expand Up @@ -4116,7 +4117,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
HostUUID: process.Config.HostUUID,
Context: process.GracefulExitContext(),
StaticFS: fs,
ClusterFeatures: process.getClusterFeatures(),
ClusterFeatures: process.GetClusterFeatures(),
GetProxyIdentity: func() (*auth.Identity, error) {
return process.GetIdentity(types.RoleProxy)
},
Expand Down Expand Up @@ -4512,7 +4513,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
// the provided connection certificate is from a proxy server and
// will impersonate the identity of the user that is making the request.
ConnTLSConfig: tlsConfig.Clone(),
ClusterFeatures: process.getClusterFeatures,
ClusterFeatures: process.GetClusterFeatures,
},
TLS: tlsConfig.Clone(),
LimiterConfig: cfg.Proxy.Limiter,
Expand Down

0 comments on commit 39deb07

Please sign in to comment.