Skip to content

Commit

Permalink
runtime: Remove --insecure-addr flag
Browse files Browse the repository at this point in the history
--insecure-addr was deprecated in in Oct 2018. It's time to say
  goodbye.

Fixes #763

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
  • Loading branch information
tsandall authored and patrick-east committed Oct 23, 2020
1 parent c84109a commit 2373d89
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 30 deletions.
2 changes: 0 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ To skip bundle verification, use the --skip-verify flag.
runCommand.Flags().StringVarP(&cmdParams.rt.HistoryPath, "history", "H", historyPath(), "set path of history file")
cmdParams.rt.Addrs = runCommand.Flags().StringSliceP("addr", "a", []string{defaultAddr}, "set listening address of the server (e.g., [ip]:<port> for TCP, unix://<path> for UNIX domain socket)")
cmdParams.rt.DiagnosticAddrs = runCommand.Flags().StringSlice("diagnostic-addr", []string{}, "set read-only diagnostic listening address of the server for /health and /metric APIs (e.g., [ip]:<port> for TCP, unix://<path> for UNIX domain socket)")
runCommand.Flags().StringVarP(&cmdParams.rt.InsecureAddr, "insecure-addr", "", "", "set insecure listening address of the server")
runCommand.Flags().MarkDeprecated("insecure-addr", "use --addr instead")
runCommand.Flags().BoolVarP(&cmdParams.rt.H2CEnabled, "h2c", "", false, "enable H2C for HTTP listeners")
runCommand.Flags().StringVarP(&cmdParams.rt.OutputFormat, "format", "f", "pretty", "set shell output format, i.e, pretty, json")
runCommand.Flags().BoolVarP(&cmdParams.rt.Watch, "watch", "w", false, "watch command line files for changes")
Expand Down
6 changes: 0 additions & 6 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ type Params struct {
// for read-only diagnostic API's (/health, /metrics, etc)
DiagnosticAddrs *[]string

// InsecureAddr is the listening address that the OPA server will bind to
// in addition to Addr if TLS is enabled.
InsecureAddr string

// H2CEnabled flag controls whether OPA will allow H2C (HTTP/2 cleartext) on
// HTTP listeners.
H2CEnabled bool
Expand Down Expand Up @@ -303,7 +299,6 @@ func (rt *Runtime) Serve(ctx context.Context) error {
logrus.WithFields(logrus.Fields{
"addrs": *rt.Params.Addrs,
"diagnostic-addrs": *rt.Params.DiagnosticAddrs,
"insecure_addr": rt.Params.InsecureAddr,
}).Info("Initializing server.")

if err := rt.Manager.Start(ctx); err != nil {
Expand All @@ -320,7 +315,6 @@ func (rt *Runtime) Serve(ctx context.Context) error {
WithCompilerErrorLimit(rt.Params.ErrorLimit).
WithPprofEnabled(rt.Params.PprofEnabled).
WithAddresses(*rt.Params.Addrs).
WithInsecureAddress(rt.Params.InsecureAddr).
WithH2CEnabled(rt.Params.H2CEnabled).
WithCertificate(rt.Params.Certificate).
WithCertPool(rt.Params.CertPool).
Expand Down
20 changes: 0 additions & 20 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ type Server struct {
router *mux.Router
addrs []string
diagAddrs []string
insecureAddr string
h2cEnabled bool
authentication AuthenticationScheme
authorization AuthorizationScheme
Expand Down Expand Up @@ -214,12 +213,6 @@ func (s *Server) WithDiagnosticAddresses(addrs []string) *Server {
return s
}

// WithInsecureAddress sets the listening address that the server will bind to.
func (s *Server) WithInsecureAddress(addr string) *Server {
s.insecureAddr = addr
return s
}

// WithAuthentication sets authentication scheme to use on the server.
func (s *Server) WithAuthentication(scheme AuthenticationScheme) *Server {
s.authentication = scheme
Expand Down Expand Up @@ -339,19 +332,6 @@ func (s *Server) Listeners() ([]Loop, error) {
}
}

if s.insecureAddr != "" {
parsedURL, err := parseURL(s.insecureAddr, false)
if err != nil {
return nil, err
}
loop, httpListener, err := s.getListenerForHTTPServer(parsedURL, s.Handler, defaultListenerType)
if err != nil {
return nil, err
}
s.httpListeners = append(s.httpListeners, httpListener)
loops = append(loops, loop)
}

return loops, nil
}

Expand Down
3 changes: 1 addition & 2 deletions test/e2e/h2c/h2c_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func TestMain(m *testing.M) {
testServerParams := e2e.NewAPIServerTestParams()
testServerParams.Addrs = &[]string{":0"}
testServerParams.DiagnosticAddrs = &[]string{":0"}
testServerParams.InsecureAddr = ":0"
testServerParams.H2CEnabled = true

var err error
Expand All @@ -45,7 +44,7 @@ func TestH2CHTTPListeners(t *testing.T) {

addrs := append(testRuntime.Runtime.Addrs(), testRuntime.Runtime.DiagnosticAddrs()...)

if expected, actual := 3, len(addrs); expected != actual {
if expected, actual := 2, len(addrs); expected != actual {
t.Fatalf("expected %d addresses, found %d", expected, actual)
}

Expand Down

0 comments on commit 2373d89

Please sign in to comment.