Skip to content

Commit

Permalink
docs: Fix AdmitFunc godoc (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
elithrar committed Jul 22, 2019
1 parent 23e1372 commit 2e7427b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions admit_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func DenyIngresses(ignoredNamespaces []string) AdmitFunc {
// The required annotations are documented at
// https://kubernetes.io/docs/concepts/services-networking/#internal-load-balancer
//
// Services with a .spec.type other than LoadBalancer will NOT be rejected by this handler.
// Services with a .spec.type other than LoadBalancer will NOT be rejected by
// this handler.
//
// Providing an empty/nil list of ignoredNamespaces will reject LoadBalancers
// across all namespaces.
Expand All @@ -117,7 +118,6 @@ func DenyPublicLoadBalancers(ignoredNamespaces []string, provider CloudProvider)
// Don't deny Services in whitelisted namespaces
for _, ns := range ignoredNamespaces {
if service.Namespace == ns {
// this namespace is whitelisted
resp.Allowed = true
resp.Result.Message = fmt.Sprintf("allowing admission: %s namespace is whitelisted", service.Namespace)
return resp, nil
Expand Down
14 changes: 10 additions & 4 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ import (
log "github.com/go-kit/kit/log"
)

// AdmitFunc validates whether an admission request is valid, and should return
// an admission response that sets Allowed to true or false as needed.
// AdmitFunc checks whether an admission request is valid, and should return an
// admission response that sets AdmissionResponse.Allowed to true or false as
// needed.
//
// Users wishing to build their own admission handlers should satisfy the
// AdmitFunc type, and pass it to an AdmissionHandler for serving over HTTP.
//
// Note: this mirrors the type in k8s source:
// https://github.com/kubernetes/kubernetes/blob/v1.13.0/test/images/webhook/main.go#L43-L44
type AdmitFunc func(reviewRequest *admission.AdmissionReview) (*admission.AdmissionResponse, error)

// AdmissionHandler represents the configuration & associated endpoint for an
// k8s ValidatingAdmissionController webhook. Multiple instances can be created
// with distinct CheckFuncs to handle different admission requirements.
// k8s ValidatingAdmissionController (or MutatingAdmissionController) webhook.
//
// Multiple instances can be created with distinct AdmitFuncs to handle
// different admission requirements.
type AdmissionHandler struct {
// The AdmitFunc to invoke for this handler.
AdmitFunc AdmitFunc
Expand Down
2 changes: 0 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ func (as *AdmissionServer) Run(ctx context.Context) error {
}
}

// TODO(matt): Listen as plaintext if no TLSConfig is provided.

return
}()

Expand Down

0 comments on commit 2e7427b

Please sign in to comment.