Skip to content

Commit 248a53a

Browse files
authored
Add validation webhook xray (#618)
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 2029bf4 commit 248a53a

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

server/options.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
stringz "github.com/appscode/go/strings"
88
v "github.com/appscode/go/version"
9+
api "github.com/appscode/stash/apis/stash/v1alpha1"
910
cs "github.com/appscode/stash/client/clientset/versioned"
1011
"github.com/appscode/stash/pkg/controller"
1112
"github.com/appscode/stash/pkg/docker"
@@ -15,15 +16,17 @@ import (
1516
)
1617

1718
type ExtraOptions struct {
18-
EnableRBAC bool
19-
StashImageTag string
20-
DockerRegistry string
21-
MaxNumRequeues int
22-
NumThreads int
23-
ScratchDir string
24-
QPS float64
25-
Burst int
26-
ResyncPeriod time.Duration
19+
EnableRBAC bool
20+
StashImageTag string
21+
DockerRegistry string
22+
MaxNumRequeues int
23+
NumThreads int
24+
ScratchDir string
25+
QPS float64
26+
Burst int
27+
ResyncPeriod time.Duration
28+
EnableValidatingWebhook bool
29+
EnableMutatingWebhook bool
2730
}
2831

2932
func NewExtraOptions() *ExtraOptions {
@@ -48,6 +51,11 @@ func (s *ExtraOptions) AddGoFlags(fs *flag.FlagSet) {
4851
fs.Float64Var(&s.QPS, "qps", s.QPS, "The maximum QPS to the master from this client")
4952
fs.IntVar(&s.Burst, "burst", s.Burst, "The maximum burst for throttle")
5053
fs.DurationVar(&s.ResyncPeriod, "resync-period", s.ResyncPeriod, "If non-zero, will re-list this often. Otherwise, re-list will be delayed aslong as possible (until the upstream source closes the watch or times out.")
54+
55+
fs.BoolVar(&s.EnableMutatingWebhook, "enable-mutating-webhook", s.EnableMutatingWebhook, "If true, enables mutating webhooks for KubeDB CRDs.")
56+
fs.BoolVar(&s.EnableValidatingWebhook, "enable-validating-webhook", s.EnableValidatingWebhook, "If true, enables validating webhooks for KubeDB CRDs.")
57+
fs.BoolVar(&api.EnableStatusSubresource, "enable-status-subresource", api.EnableStatusSubresource, "If true, uses sub resource for KubeDB crds.")
58+
5159
}
5260

5361
func (s *ExtraOptions) AddFlags(fs *pflag.FlagSet) {
@@ -65,9 +73,10 @@ func (s *ExtraOptions) ApplyTo(cfg *controller.Config) error {
6573
cfg.MaxNumRequeues = s.MaxNumRequeues
6674
cfg.NumThreads = s.NumThreads
6775
cfg.ResyncPeriod = s.ResyncPeriod
68-
6976
cfg.ClientConfig.QPS = float32(s.QPS)
7077
cfg.ClientConfig.Burst = s.Burst
78+
cfg.EnableMutatingWebhook = s.EnableMutatingWebhook
79+
cfg.EnableValidatingWebhook = s.EnableValidatingWebhook
7180

7281
if cfg.KubeClient, err = kubernetes.NewForConfig(cfg.ClientConfig); err != nil {
7382
return err

server/start.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"net"
77

8+
"github.com/appscode/kutil/tools/clientcmd"
89
"github.com/appscode/stash/apis/repositories/v1alpha1"
910
"github.com/appscode/stash/pkg/controller"
1011
"github.com/appscode/stash/pkg/server"
@@ -62,6 +63,9 @@ func (o StashOptions) Config() (*server.StashConfig, error) {
6263
if err := o.RecommendedOptions.ApplyTo(serverConfig, server.Scheme); err != nil {
6364
return nil, err
6465
}
66+
// Fixes https://github.com/Azure/AKS/issues/522
67+
clientcmd.Fix(serverConfig.ClientConfig)
68+
6569
serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(v1alpha1.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(server.Scheme))
6670
serverConfig.OpenAPIConfig.Info.Title = "stash-server"
6771
serverConfig.OpenAPIConfig.Info.Version = v1alpha1.SchemeGroupVersion.Version

0 commit comments

Comments
 (0)