Skip to content

Commit

Permalink
Webhook server uses its configured host if set
Browse files Browse the repository at this point in the history
  • Loading branch information
craigfurman committed Feb 12, 2019
1 parent 6443f37 commit 6f73314
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/webhook/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"io"
"net"
"net/http"
"path"
"sync"
Expand Down Expand Up @@ -218,9 +219,13 @@ func (s *Server) Start(stop <-chan struct{}) error {

func (s *Server) run(stop <-chan struct{}) error { // nolint: gocyclo
errCh := make(chan error)
host := ""
if s.Host != nil {
host = *s.Host
}
serveFn := func() {
s.httpServer = &http.Server{
Addr: fmt.Sprintf(":%v", s.Port),
Addr: net.JoinHostPort(host, fmt.Sprintf("%d", s.Port)),
Handler: s.sMux,
}
log.Info("starting the webhook server.")
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var _ = Describe("webhook server", func() {
Describe("run", func() {
var stop chan struct{}
var s *Server
var cn = "example.com"
var cn = "localhost"

BeforeEach(func() {
port, _, err := addr.Suggest()
Expand Down

0 comments on commit 6f73314

Please sign in to comment.