add feature enablement options to recommendedoptions

This commit is contained in:
deads2k
2017-02-07 13:22:38 -05:00
parent 51b5d5a51b
commit cc75d51897
9 changed files with 84 additions and 26 deletions

View File

@@ -45,6 +45,7 @@ type ServerRunOptions struct {
SecureServing *genericoptions.SecureServingOptions
InsecureServing *genericoptions.ServingOptions
Audit *genericoptions.AuditLogOptions
Features *genericoptions.FeatureOptions
Authentication *kubeoptions.BuiltInAuthenticationOptions
Authorization *kubeoptions.BuiltInAuthorizationOptions
CloudProvider *kubeoptions.CloudProviderOptions
@@ -70,6 +71,7 @@ func NewServerRunOptions() *ServerRunOptions {
SecureServing: genericoptions.NewSecureServingOptions(),
InsecureServing: genericoptions.NewInsecureServingOptions(),
Audit: genericoptions.NewAuditLogOptions(),
Features: genericoptions.NewFeatureOptions(),
Authentication: kubeoptions.NewBuiltInAuthenticationOptions().WithAll(),
Authorization: kubeoptions.NewBuiltInAuthorizationOptions(),
CloudProvider: kubeoptions.NewCloudProviderOptions(),
@@ -106,6 +108,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
s.InsecureServing.AddFlags(fs)
s.InsecureServing.AddDeprecatedFlags(fs)
s.Audit.AddFlags(fs)
s.Features.AddFlags(fs)
s.Authentication.AddFlags(fs)
s.Authorization.AddFlags(fs)
s.CloudProvider.AddFlags(fs)

View File

@@ -28,7 +28,7 @@ func TestAddFlagsFlag(t *testing.T) {
f := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
s := NewServerRunOptions()
s.AddFlags(f)
if s.GenericServerRunOptions.EnableSwaggerUI {
if s.Features.EnableSwaggerUI {
t.Errorf("Expected s.EnableSwaggerUI to be false by default")
}
@@ -36,7 +36,7 @@ func TestAddFlagsFlag(t *testing.T) {
"--enable-swagger-ui=true",
}
f.Parse(args)
if !s.GenericServerRunOptions.EnableSwaggerUI {
if !s.Features.EnableSwaggerUI {
t.Errorf("Expected s.EnableSwaggerUI to be true")
}
}

View File

@@ -123,6 +123,9 @@ func Run(s *options.ServerRunOptions) error {
if err := s.Audit.ApplyTo(genericConfig); err != nil {
return err
}
if err := s.Features.ApplyTo(genericConfig); err != nil {
return err
}
capabilities.Initialize(capabilities.Capabilities{
AllowPrivileged: s.AllowPrivileged,