Skip to content

Commit aeaf98d

Browse files
authored
Merge pull request #507 from kubernetes-sigs/master
🏃 ff release-0.2 to master
2 parents f60c87e + b5e34e4 commit aeaf98d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1413
-790
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
*.swp
1717
*.swo
1818
*~
19+
20+
# Vscode files
21+
.vscode

Gopkg.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

alias.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ var (
9494
// NewControllerManagedBy returns a new controller builder that will be started by the provided Manager
9595
NewControllerManagedBy = builder.ControllerManagedBy
9696

97+
// NewWebhookManagedBy returns a new webhook builder that will be started by the provided Manager
98+
NewWebhookManagedBy = builder.WebhookManagedBy
99+
97100
// NewManager returns a new Manager for creating Controllers.
98101
NewManager = manager.New
99102

examples/builtins/main.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,11 @@ func main() {
7878

7979
// Setup webhooks
8080
entryLog.Info("setting up webhook server")
81-
hookServer := &webhook.Server{
82-
Port: 9876,
83-
CertDir: "/tmp/cert",
84-
}
85-
if err := mgr.Add(hookServer); err != nil {
86-
entryLog.Error(err, "unable register webhook server with manager")
87-
os.Exit(1)
88-
}
81+
hookServer := mgr.GetWebhookServer()
8982

9083
entryLog.Info("registering webhooks to the webhook server")
91-
hookServer.Register("/mutate-pods", &webhook.Admission{Handler: &podAnnotator{}})
92-
hookServer.Register("/validate-pods", &webhook.Admission{Handler: &podValidator{}})
84+
hookServer.Register("/mutate-v1-pod", &webhook.Admission{Handler: &podAnnotator{}})
85+
hookServer.Register("/validate-v1-pod", &webhook.Admission{Handler: &podValidator{}})
9386

9487
entryLog.Info("starting manager")
9588
if err := mgr.Start(signals.SetupSignalHandler()); err != nil {

examples/builtins/mutatingwebhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2727
)
2828

29+
// +kubebuilder:webhook:path=/mutate-v1-pod,mutating=true,failurePolicy=fail,groups="",resources=pods,verbs=create;update,versions=v1,name=mpod.kb.io
30+
2931
// podAnnotator annotates Pods
3032
type podAnnotator struct {
3133
client client.Client

examples/builtins/validatingwebhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2727
)
2828

29+
// +kubebuilder:webhook:path=/validate-v1-pod,mutating=false,failurePolicy=fail,groups="",resources=pods,verbs=create;update,versions=v1,name=vpod.kb.io
30+
2931
// podValidator validates Pods
3032
type podValidator struct {
3133
client client.Client

examples/conversion/pkg/apis/addtoscheme_jobs_v1.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/conversion/pkg/apis/addtoscheme_jobs_v2.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/conversion/pkg/apis/apis.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

examples/conversion/pkg/apis/jobs/v1/doc.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/conversion/pkg/apis/jobs/v2/doc.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/crd/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,19 @@ func main() {
125125
Client: mgr.GetClient(),
126126
scheme: mgr.GetScheme(),
127127
})
128-
129128
if err != nil {
130129
setupLog.Error(err, "unable to create controller")
131130
os.Exit(1)
132131
}
133132

133+
err = ctrl.NewWebhookManagedBy(mgr).
134+
For(&api.ChaosPod{}).
135+
Complete()
136+
if err != nil {
137+
setupLog.Error(err, "unable to create webhook")
138+
os.Exit(1)
139+
}
140+
134141
setupLog.Info("starting manager")
135142
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
136143
setupLog.Error(err, "problem running manager")

examples/crd/pkg/resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type ChaosPodList struct {
6161
Items []ChaosPod `json:"items"`
6262
}
6363

64-
// +kubebuilder:webhook:failurePolicy=fail,groups=chaosapps.metamagical.io,resources=chaospods,verbs=create;update,versions=v1,name=vchaospod.kb.io,path=/validate-chaosapps-metamagical-io-v1-chaospod,mutating=false
64+
// +kubebuilder:webhook:path=/validate-chaosapps-metamagical-io-v1-chaospod,mutating=false,failurePolicy=fail,groups=chaosapps.metamagical.io,resources=chaospods,verbs=create;update,versions=v1,name=vchaospod.kb.io
6565

6666
var _ webhook.Validator = &ChaosPod{}
6767

@@ -93,7 +93,7 @@ func (c *ChaosPod) ValidateUpdate(old runtime.Object) error {
9393
return nil
9494
}
9595

96-
// +kubebuilder:webhook:failurePolicy=fail,groups=chaosapps.metamagical.io,resources=chaospods,verbs=create;update,versions=v1,name=mchaospod.kb.io,path=/mutate-chaosapps-metamagical-io-v1-chaospod,mutating=true
96+
// +kubebuilder:webhook:path=/mutate-chaosapps-metamagical-io-v1-chaospod,mutating=true,failurePolicy=fail,groups=chaosapps.metamagical.io,resources=chaospods,verbs=create;update,versions=v1,name=mchaospod.kb.io
9797

9898
var _ webhook.Defaulter = &ChaosPod{}
9999

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ go 1.11
44

55
require (
66
cloud.google.com/go v0.26.0 // indirect
7-
github.com/appscode/jsonpatch v0.0.0-20190108182946-7c0e3b262f30
87
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
9-
github.com/evanphx/json-patch v4.1.0+incompatible
8+
github.com/evanphx/json-patch v4.5.0+incompatible
109
github.com/go-logr/logr v0.1.0
1110
github.com/go-logr/zapr v0.1.0
1211
github.com/gogo/protobuf v1.1.1 // indirect
@@ -23,7 +22,6 @@ require (
2322
github.com/onsi/ginkgo v1.6.0
2423
github.com/onsi/gomega v1.4.2
2524
github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c // indirect
26-
github.com/pkg/errors v0.8.1 // indirect
2725
github.com/prometheus/client_golang v0.9.0
2826
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
2927
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e // indirect
@@ -36,8 +34,10 @@ require (
3634
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be // indirect
3735
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
3836
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
37+
gomodules.xyz/jsonpatch/v2 v2.0.0
3938
google.golang.org/appengine v1.1.0 // indirect
4039
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
40+
gopkg.in/fsnotify.v1 v1.4.7
4141
gopkg.in/inf.v0 v0.9.1 // indirect
4242
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
4343
k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8

go.sum

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ=
22
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
3-
github.com/appscode/jsonpatch v0.0.0-20190108182946-7c0e3b262f30 h1:Kn3rqvbUFqSepE2OqVu0Pn1CbDw9IuMlONapol0zuwk=
4-
github.com/appscode/jsonpatch v0.0.0-20190108182946-7c0e3b262f30/go.mod h1:4AJxUpXUhv4N+ziTvIcWWXgeorXpxPZOfk9HdEVr96M=
53
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
64
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
75
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
86
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
97
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
10-
github.com/evanphx/json-patch v4.0.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
11-
github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7VpzLjCxu+UwBD1FvwOc=
12-
github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
8+
github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=
9+
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
1310
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
1411
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
1512
github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg=
@@ -63,12 +60,10 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e h1:n/3MEhJQjQxrO
6360
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
6461
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273 h1:agujYaXJSxSo18YNX3jzl+4G6Bstwt+kqv47GS12uL0=
6562
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
66-
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
6763
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
6864
github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc=
6965
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
7066
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
71-
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
7267
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
7368
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
7469
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
@@ -92,6 +87,8 @@ golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
9287
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
9388
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM=
9489
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
90+
gomodules.xyz/jsonpatch/v2 v2.0.0 h1:OyHbl+7IOECpPKfVK42oFr6N7+Y2dR+Jsb/IiDV3hOo=
91+
gomodules.xyz/jsonpatch/v2 v2.0.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
9592
google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs=
9693
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
9794
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)