Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
Signed-off-by: Vacant2333 <vacant2333@gmail.com>
  • Loading branch information
Vacant2333 committed Jul 19, 2024
1 parent 8141f1f commit 5ea21fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cmd/webhook-manager/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package app

import (
"errors"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -46,10 +47,6 @@ func Run(config *options.Config) error {
}
}

if config.WebhookURL == "" && config.WebhookNamespace == "" && config.WebhookName == "" {
return fmt.Errorf("failed to start webhooks as both 'url' and 'namespace/name' of webhook are empty")
}

restConfig, err := kube.BuildConfig(config.KubeClientOptions)
if err != nil {
return fmt.Errorf("unable to build k8s config: %v", err)
Expand Down Expand Up @@ -101,7 +98,7 @@ func Run(config *options.Config) error {
}
go func() {
err = server.ListenAndServeTLS("", "")
if err != nil && err != http.ErrServerClosed {
if err != nil && !errors.Is(err, http.ErrServerClosed) {
klog.Fatalf("ListenAndServeTLS for admission webhook failed: %v", err)
close(webhookServeError)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/webhooks/router/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func ForEachAdmission(config *options.Config, handler func(*AdmissionService) er
if err := handler(service); err != nil {
return err
}
} else {
return fmt.Errorf("enabled admission %s not found on the admission registered map", admission)
}
}
return nil
Expand Down

0 comments on commit 5ea21fd

Please sign in to comment.