Skip to content

Commit

Permalink
Add validation webhook xray (#618)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Nov 23, 2018
1 parent 2029bf4 commit 248a53a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
29 changes: 19 additions & 10 deletions server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

stringz "github.com/appscode/go/strings"
v "github.com/appscode/go/version"
api "github.com/appscode/stash/apis/stash/v1alpha1"
cs "github.com/appscode/stash/client/clientset/versioned"
"github.com/appscode/stash/pkg/controller"
"github.com/appscode/stash/pkg/docker"
Expand All @@ -15,15 +16,17 @@ import (
)

type ExtraOptions struct {
EnableRBAC bool
StashImageTag string
DockerRegistry string
MaxNumRequeues int
NumThreads int
ScratchDir string
QPS float64
Burst int
ResyncPeriod time.Duration
EnableRBAC bool
StashImageTag string
DockerRegistry string
MaxNumRequeues int
NumThreads int
ScratchDir string
QPS float64
Burst int
ResyncPeriod time.Duration
EnableValidatingWebhook bool
EnableMutatingWebhook bool
}

func NewExtraOptions() *ExtraOptions {
Expand All @@ -48,6 +51,11 @@ func (s *ExtraOptions) AddGoFlags(fs *flag.FlagSet) {
fs.Float64Var(&s.QPS, "qps", s.QPS, "The maximum QPS to the master from this client")
fs.IntVar(&s.Burst, "burst", s.Burst, "The maximum burst for throttle")
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.")

fs.BoolVar(&s.EnableMutatingWebhook, "enable-mutating-webhook", s.EnableMutatingWebhook, "If true, enables mutating webhooks for KubeDB CRDs.")
fs.BoolVar(&s.EnableValidatingWebhook, "enable-validating-webhook", s.EnableValidatingWebhook, "If true, enables validating webhooks for KubeDB CRDs.")
fs.BoolVar(&api.EnableStatusSubresource, "enable-status-subresource", api.EnableStatusSubresource, "If true, uses sub resource for KubeDB crds.")

}

func (s *ExtraOptions) AddFlags(fs *pflag.FlagSet) {
Expand All @@ -65,9 +73,10 @@ func (s *ExtraOptions) ApplyTo(cfg *controller.Config) error {
cfg.MaxNumRequeues = s.MaxNumRequeues
cfg.NumThreads = s.NumThreads
cfg.ResyncPeriod = s.ResyncPeriod

cfg.ClientConfig.QPS = float32(s.QPS)
cfg.ClientConfig.Burst = s.Burst
cfg.EnableMutatingWebhook = s.EnableMutatingWebhook
cfg.EnableValidatingWebhook = s.EnableValidatingWebhook

if cfg.KubeClient, err = kubernetes.NewForConfig(cfg.ClientConfig); err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"net"

"github.com/appscode/kutil/tools/clientcmd"
"github.com/appscode/stash/apis/repositories/v1alpha1"
"github.com/appscode/stash/pkg/controller"
"github.com/appscode/stash/pkg/server"
Expand Down Expand Up @@ -62,6 +63,9 @@ func (o StashOptions) Config() (*server.StashConfig, error) {
if err := o.RecommendedOptions.ApplyTo(serverConfig, server.Scheme); err != nil {
return nil, err
}
// Fixes https://github.com/Azure/AKS/issues/522
clientcmd.Fix(serverConfig.ClientConfig)

serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(v1alpha1.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(server.Scheme))
serverConfig.OpenAPIConfig.Info.Title = "stash-server"
serverConfig.OpenAPIConfig.Info.Version = v1alpha1.SchemeGroupVersion.Version
Expand Down

0 comments on commit 248a53a

Please sign in to comment.