Skip to content

Commit

Permalink
Remove unused servicecfg.Config.Console field
Browse files Browse the repository at this point in the history
  • Loading branch information
rosstimothy committed Jan 13, 2025
1 parent 8e513b4 commit 71dde9e
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 49 deletions.
2 changes: 1 addition & 1 deletion e
Submodule e updated from 498f64 to 65fa47
1 change: 0 additions & 1 deletion e2e/aws/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ func newTeleportConfig(t *testing.T) *servicecfg.Config {
tconf := servicecfg.MakeDefaultConfig()
// Replace the default auth and proxy listeners with the ones so we can
// run multiple tests in parallel.
tconf.Console = nil
tconf.Proxy.DisableWebInterface = true
tconf.PollingPeriod = 500 * time.Millisecond
tconf.Testing.ClientTimeout = time.Second
Expand Down
2 changes: 0 additions & 2 deletions integration/appaccess/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ func SetupWithOptions(t *testing.T, opts AppTestOptions) *Pack {
p.leafCluster = helpers.NewInstance(t, leafCfg)

rcConf := servicecfg.MakeDefaultConfig()
rcConf.Console = nil
rcConf.Logger = log
rcConf.DataDir = t.TempDir()
rcConf.Auth.Enabled = true
Expand All @@ -364,7 +363,6 @@ func SetupWithOptions(t *testing.T, opts AppTestOptions) *Pack {
rcConf.Clock = opts.Clock

lcConf := servicecfg.MakeDefaultConfig()
lcConf.Console = nil
lcConf.Logger = log
lcConf.DataDir = t.TempDir()
lcConf.Auth.Enabled = true
Expand Down
2 changes: 0 additions & 2 deletions integration/appaccess/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ func (p *Pack) startRootAppServers(t *testing.T, count int, opts AppTestOptions)
for i := 0; i < count; i++ {
raConf := servicecfg.MakeDefaultConfig()
raConf.Clock = opts.Clock
raConf.Console = nil
raConf.Logger = utils.NewSlogLoggerForTests()
raConf.DataDir = t.TempDir()
raConf.SetToken("static-token-value")
Expand Down Expand Up @@ -873,7 +872,6 @@ func (p *Pack) startLeafAppServers(t *testing.T, count int, opts AppTestOptions)
for i := 0; i < count; i++ {
laConf := servicecfg.MakeDefaultConfig()
laConf.Clock = opts.Clock
laConf.Console = nil
laConf.Logger = utils.NewSlogLoggerForTests()
laConf.DataDir = t.TempDir()
laConf.SetToken("static-token-value")
Expand Down
4 changes: 1 addition & 3 deletions integration/helpers/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,9 @@ func (i *TeleInstance) GetSiteAPI(siteName string) authclient.ClientI {

// Create creates a new instance of Teleport which trusts a list of other clusters (other
// instances)
func (i *TeleInstance) Create(t *testing.T, trustedSecrets []*InstanceSecrets, enableSSH bool, console io.Writer) error {
func (i *TeleInstance) Create(t *testing.T, trustedSecrets []*InstanceSecrets, enableSSH bool) error {
tconf := servicecfg.MakeDefaultConfig()
tconf.SSH.Enabled = enableSSH
tconf.Console = console
tconf.Logger = i.Log
tconf.Proxy.DisableWebService = true
tconf.Proxy.DisableWebInterface = true
Expand Down Expand Up @@ -1129,7 +1128,6 @@ func (i *TeleInstance) StartProxy(cfg ProxyConfig, opts ...Option) (reversetunne
i.tempDirs = append(i.tempDirs, dataDir)

tconf := servicecfg.MakeDefaultConfig()
tconf.Console = nil
tconf.Logger = i.Log
authServer := utils.MustParseAddr(i.Auth)
tconf.SetAuthServerAddress(*authServer)
Expand Down
4 changes: 2 additions & 2 deletions integration/hostuser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func TestRootLoginAsHostUser(t *testing.T) {
Roles: []types.Role{role},
}

require.NoError(t, instance.Create(t, nil, true, nil))
require.NoError(t, instance.Create(t, nil, true))
require.NoError(t, instance.Start())
t.Cleanup(func() {
require.NoError(t, instance.StopAll())
Expand Down Expand Up @@ -740,7 +740,7 @@ func TestRootStaticHostUsers(t *testing.T) {
Logger: utils.NewSlogLoggerForTests(),
})

require.NoError(t, instance.Create(t, nil, false, nil))
require.NoError(t, instance.Create(t, nil, false))
require.NoError(t, instance.Start())
t.Cleanup(func() {
require.NoError(t, instance.StopAll())
Expand Down
23 changes: 9 additions & 14 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ func (s *integrationTestSuite) newUnstartedTeleport(t *testing.T, logins []strin
for _, login := range logins {
teleport.AddUser(login, []string{login})
}
require.NoError(t, teleport.Create(t, nil, enableSSH, nil))
require.NoError(t, teleport.Create(t, nil, enableSSH))
return teleport
}

Expand Down Expand Up @@ -2564,9 +2564,9 @@ func testTwoClustersProxy(t *testing.T, suite *integrationTestSuite) {
a.AddUser(username, []string{username})
b.AddUser(username, []string{username})

require.NoError(t, b.Create(t, a.Secrets.AsSlice(), false, nil))
require.NoError(t, b.Create(t, a.Secrets.AsSlice(), false))
defer b.StopAll()
require.NoError(t, a.Create(t, b.Secrets.AsSlice(), true, nil))
require.NoError(t, a.Create(t, b.Secrets.AsSlice(), true))
defer a.StopAll()

require.NoError(t, b.Start())
Expand Down Expand Up @@ -2602,8 +2602,8 @@ func testHA(t *testing.T, suite *integrationTestSuite) {
a.AddUser(username, []string{username})
b.AddUser(username, []string{username})

require.NoError(t, b.Create(t, a.Secrets.AsSlice(), true, nil))
require.NoError(t, a.Create(t, b.Secrets.AsSlice(), true, nil))
require.NoError(t, b.Create(t, a.Secrets.AsSlice(), true))
require.NoError(t, a.Create(t, b.Secrets.AsSlice(), true))

require.NoError(t, b.Start())
require.NoError(t, a.Start())
Expand Down Expand Up @@ -3950,13 +3950,13 @@ func testDiscoveryRecovers(t *testing.T, suite *integrationTestSuite) {
remote.AddUser(username, []string{username})
main.AddUser(username, []string{username})

require.NoError(t, main.Create(t, remote.Secrets.AsSlice(), false, nil))
require.NoError(t, main.Create(t, remote.Secrets.AsSlice(), false))
mainSecrets := main.Secrets
// switch listen address of the main cluster to load balancer
mainProxyAddr := *utils.MustParseAddr(mainSecrets.TunnelAddr)
lb.AddBackend(mainProxyAddr)
mainSecrets.TunnelAddr = lb.Addr().String()
require.NoError(t, remote.Create(t, mainSecrets.AsSlice(), true, nil))
require.NoError(t, remote.Create(t, mainSecrets.AsSlice(), true))

require.NoError(t, main.Start())
require.NoError(t, remote.Start())
Expand Down Expand Up @@ -4085,13 +4085,13 @@ func testDiscovery(t *testing.T, suite *integrationTestSuite) {
remote.AddUser(username, []string{username})
main.AddUser(username, []string{username})

require.NoError(t, main.Create(t, remote.Secrets.AsSlice(), false, nil))
require.NoError(t, main.Create(t, remote.Secrets.AsSlice(), false))
mainSecrets := main.Secrets
// switch listen address of the main cluster to load balancer
mainProxyAddr := *utils.MustParseAddr(mainSecrets.TunnelAddr)
lb.AddBackend(mainProxyAddr)
mainSecrets.TunnelAddr = lb.Addr().String()
require.NoError(t, remote.Create(t, mainSecrets.AsSlice(), true, nil))
require.NoError(t, remote.Create(t, mainSecrets.AsSlice(), true))

require.NoError(t, main.Start())
require.NoError(t, remote.Start())
Expand Down Expand Up @@ -7223,7 +7223,6 @@ func WithListeners(setupFn helpers.InstanceListenerSetupFunc) InstanceConfigOpti

func (s *integrationTestSuite) defaultServiceConfig() *servicecfg.Config {
cfg := servicecfg.MakeDefaultConfig()
cfg.Console = nil
cfg.Logger = s.Log
cfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
cfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
Expand Down Expand Up @@ -8572,7 +8571,6 @@ func TestConnectivityWithoutAuth(t *testing.T) {

// Create auth config.
authCfg := servicecfg.MakeDefaultConfig()
authCfg.Console = nil
authCfg.Logger = utils.NewSlogLoggerForTests()
authCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
authCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
Expand Down Expand Up @@ -8635,7 +8633,6 @@ func TestConnectivityWithoutAuth(t *testing.T) {
nodeCfg.SetToken("token")
nodeCfg.CachePolicy.Enabled = true
nodeCfg.DataDir = t.TempDir()
nodeCfg.Console = nil
nodeCfg.Logger = utils.NewSlogLoggerForTests()
nodeCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
nodeCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
Expand Down Expand Up @@ -8716,7 +8713,6 @@ func TestConnectivityDuringAuthRestart(t *testing.T) {

// Create auth config.
authCfg := servicecfg.MakeDefaultConfig()
authCfg.Console = nil
authCfg.Logger = utils.NewSlogLoggerForTests()
authCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
authCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
Expand Down Expand Up @@ -8776,7 +8772,6 @@ func TestConnectivityDuringAuthRestart(t *testing.T) {
nodeCfg.SetToken("token")
nodeCfg.CachePolicy.Enabled = true
nodeCfg.DataDir = t.TempDir()
nodeCfg.Console = nil
nodeCfg.Logger = utils.NewSlogLoggerForTests()
nodeCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig()
nodeCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient()
Expand Down
2 changes: 0 additions & 2 deletions integration/kube_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1833,7 +1833,6 @@ type sessionMetadataResponse struct {
// teleKubeConfig sets up teleport with kubernetes turned on
func (s *KubeSuite) teleKubeConfig(hostname string) *servicecfg.Config {
tconf := servicecfg.MakeDefaultConfig()
tconf.Console = nil
tconf.Logger = s.log
tconf.SSH.Enabled = true
tconf.Proxy.DisableWebInterface = true
Expand All @@ -1854,7 +1853,6 @@ func (s *KubeSuite) teleKubeConfig(hostname string) *servicecfg.Config {
// teleKubeConfig sets up teleport with kubernetes turned on
func (s *KubeSuite) teleAuthConfig(hostname string) *servicecfg.Config {
tconf := servicecfg.MakeDefaultConfig()
tconf.Console = nil
tconf.Logger = s.log
tconf.PollingPeriod = 500 * time.Millisecond
tconf.Testing.ClientTimeout = time.Second
Expand Down
1 change: 0 additions & 1 deletion integration/port_forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ func testPortForwarding(t *testing.T, suite *integrationTestSuite) {
nodeCfg.SetToken("token")
nodeCfg.CachePolicy.Enabled = true
nodeCfg.DataDir = t.TempDir()
nodeCfg.Console = nil
nodeCfg.Auth.Enabled = false
nodeCfg.Proxy.Enabled = false
nodeCfg.SSH.Enabled = true
Expand Down
1 change: 0 additions & 1 deletion integration/proxy/proxy_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func newSuite(t *testing.T, opts ...proxySuiteOptionsFunc) *Suite {
func (p *Suite) addNodeToLeafCluster(t *testing.T, tunnelNodeHostname string) {
nodeConfig := func() *servicecfg.Config {
tconf := servicecfg.MakeDefaultConfig()
tconf.Console = nil
tconf.Logger = utils.NewSlogLoggerForTests()
tconf.Hostname = tunnelNodeHostname
tconf.SetToken("token")
Expand Down
4 changes: 0 additions & 4 deletions lib/client/api_login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,6 @@ type standaloneBundle struct {
func newStandaloneTeleport(t *testing.T, clock clockwork.Clock) *standaloneBundle {
randomAddr := utils.NetAddr{AddrNetwork: "tcp", Addr: "127.0.0.1:0"}

console := io.Discard

staticToken := uuid.New().String()

// Prepare role and user.
Expand Down Expand Up @@ -549,7 +547,6 @@ func newStandaloneTeleport(t *testing.T, clock clockwork.Clock) *standaloneBundl
cfg.DataDir = makeDataDir()
cfg.Hostname = "localhost"
cfg.Clock = clock
cfg.Console = console
cfg.Logger = utils.NewSlogLoggerForTests()
cfg.SetAuthServerAddress(randomAddr) // must be present
cfg.Auth.Preference, err = types.NewAuthPreferenceFromConfigFile(types.AuthPreferenceSpecV2{
Expand Down Expand Up @@ -633,7 +630,6 @@ func newStandaloneTeleport(t *testing.T, clock clockwork.Clock) *standaloneBundl
cfg.Hostname = "localhost"
cfg.SetToken(staticToken)
cfg.Clock = clock
cfg.Console = console
cfg.Logger = utils.NewSlogLoggerForTests()
cfg.SetAuthServerAddress(*authAddr)
cfg.Auth.Enabled = false
Expand Down
6 changes: 0 additions & 6 deletions lib/config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,11 +781,6 @@ func applyAuthOrProxyAddress(fc *FileConfig, cfg *servicecfg.Config) error {
}

func applyLogConfig(loggerConfig Log, cfg *servicecfg.Config) error {
switch loggerConfig.Output {
case "stderr", "error", "2", "stdout", "out", "1":
cfg.Console = io.Discard // disable console printing
}

logger, level, err := logutils.Initialize(logutils.Config{
Output: loggerConfig.Output,
Severity: loggerConfig.Severity,
Expand Down Expand Up @@ -2514,7 +2509,6 @@ func Configure(clf *CommandLineFlags, cfg *servicecfg.Config, legacyAppFlags boo

// apply --debug flag to config:
if clf.Debug {
cfg.Console = io.Discard
cfg.Debug = clf.Debug
}

Expand Down
9 changes: 0 additions & 9 deletions lib/service/servicecfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package servicecfg

import (
"context"
"io"
"log/slog"
"net"
"net/http"
Expand Down Expand Up @@ -133,9 +132,6 @@ type Config struct {
// a teleport cluster). It's automatically generated on 1st start
HostUUID string

// Console writer to speak to a user
Console io.Writer

// ReverseTunnels is a list of reverse tunnels to create on the
// first cluster start
ReverseTunnels []types.ReverseTunnel
Expand Down Expand Up @@ -551,7 +547,6 @@ func ApplyDefaults(cfg *Config) {
// Global defaults.
cfg.Hostname = hostname
cfg.DataDir = defaults.DataDir
cfg.Console = os.Stdout
cfg.CipherSuites = utils.DefaultCipherSuites()
cfg.Ciphers = sc.Ciphers
cfg.KEXAlgorithms = kex
Expand Down Expand Up @@ -695,10 +690,6 @@ func applyDefaults(cfg *Config) {
cfg.Version = defaults.TeleportConfigVersionV1
}

if cfg.Console == nil {
cfg.Console = io.Discard
}

if cfg.Logger == nil {
cfg.Logger = slog.Default()
}
Expand Down
1 change: 0 additions & 1 deletion tool/teleport/common/teleport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func TestTeleportMain(t *testing.T) {
require.True(t, conf.Auth.Enabled)
require.True(t, conf.SSH.Enabled)
require.True(t, conf.Proxy.Enabled)
require.Equal(t, os.Stdout, conf.Console)
require.True(t, slog.Default().Handler().Enabled(context.Background(), slog.LevelError))
})

Expand Down

0 comments on commit 71dde9e

Please sign in to comment.