Skip to content

Commit

Permalink
Make --image-tag a required flag. (#817)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Jun 12, 2019
1 parent 9ca08aa commit 955b1ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 14 additions & 4 deletions pkg/cmds/server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package server

import (
"flag"
"fmt"
"time"

stringz "github.com/appscode/go/strings"
v "github.com/appscode/go/version"
"github.com/spf13/pflag"
crd_cs "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -35,7 +34,7 @@ type ExtraOptions struct {
func NewExtraOptions() *ExtraOptions {
return &ExtraOptions{
DockerRegistry: docker.ACRegistry,
StashImageTag: stringz.Val(v.Version.Version, "canary"),
StashImageTag: "",
MaxNumRequeues: 5,
NumThreads: 2,
ScratchDir: "/tmp",
Expand All @@ -57,7 +56,6 @@ func (s *ExtraOptions) AddGoFlags(fs *flag.FlagSet) {
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(&apis.EnableStatusSubresource, "enable-status-subresource", apis.EnableStatusSubresource, "If true, uses sub resource for KubeDB crds.")

}

func (s *ExtraOptions) AddFlags(fs *pflag.FlagSet) {
Expand Down Expand Up @@ -101,3 +99,15 @@ func (s *ExtraOptions) ApplyTo(cfg *controller.Config) error {

return nil
}

func (s *ExtraOptions) Validate() []error {
if s == nil {
return nil
}

var errs []error
if s.StashImageTag == "" {
errs = append(errs, fmt.Errorf("--image-tag must be specified"))
}
return errs
}
6 changes: 5 additions & 1 deletion pkg/cmds/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/spf13/pflag"
admissionv1beta1 "k8s.io/api/admission/v1beta1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
openapinamer "k8s.io/apiserver/pkg/endpoints/openapi"
genericapiserver "k8s.io/apiserver/pkg/server"
genericoptions "k8s.io/apiserver/pkg/server/options"
Expand Down Expand Up @@ -51,7 +52,10 @@ func (o StashOptions) AddFlags(fs *pflag.FlagSet) {
}

func (o StashOptions) Validate(args []string) error {
return nil
var errs []error
errs = append(errs, o.RecommendedOptions.Validate()...)
errs = append(errs, o.ExtraOptions.Validate()...)
return utilerrors.NewAggregate(errs)
}

func (o *StashOptions) Complete() error {
Expand Down

0 comments on commit 955b1ad

Please sign in to comment.