Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling the HTTP API again. #4655

Merged
merged 2 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ func LocalConfig(cfg *config.RuntimeConfig) local.Config {
return lc
}

func shouldRunProxyManager(cfg *config.RuntimeConfig) bool {
return !cfg.ConnectTestDisableManagedProxies && cfg.ConnectEnabled
}

func (a *Agent) Start() error {
c := a.config

Expand Down Expand Up @@ -372,7 +376,7 @@ func (a *Agent) Start() error {
// create the proxy process manager and start it. This is purposely
// done here after the local state above is loaded in so we can have
// a more accurate initial state view.
if !c.ConnectTestDisableManagedProxies {
if shouldRunProxyManager(c) {
a.proxyManager = proxy.NewManager()
a.proxyManager.AllowRoot = a.config.ConnectProxyAllowManagedRoot
a.proxyManager.State = a.State
Expand Down
18 changes: 18 additions & 0 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3054,3 +3054,21 @@ func TestAgent_ReLoadProxiesFromConfig(t *testing.T) {
proxies = a.State.Proxies()
require.Len(proxies, 0)
}

func TestAgent_ShouldRunProxyManager(t *testing.T) {
t.Parallel()
tests := []struct {
Config config.RuntimeConfig
ShouldRunProxyManager bool
}{
{config.RuntimeConfig{ConnectEnabled: true, ConnectTestDisableManagedProxies: true}, false},
{config.RuntimeConfig{ConnectEnabled: true, ConnectTestDisableManagedProxies: false}, true},
{config.RuntimeConfig{ConnectEnabled: false, ConnectTestDisableManagedProxies: true}, false},
{config.RuntimeConfig{ConnectEnabled: false, ConnectTestDisableManagedProxies: false}, false},
}
for _, tt := range tests {
if shouldRunProxyManager(&tt.Config) != tt.ShouldRunProxyManager {
t.Fatal("Mismatch")
}
}
}