Skip to content

Commit

Permalink
simplify tsb flags
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k committed Aug 8, 2017
1 parent 828c1b3 commit 4ae0bef
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 63 deletions.
28 changes: 0 additions & 28 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -38516,30 +38516,8 @@ _openshift_start_template-service-broker()
local_nonpersistent_flags+=("--client-ca-file=")
flags+=("--contention-profiling")
local_nonpersistent_flags+=("--contention-profiling")
flags+=("--delete-collection-workers=")
local_nonpersistent_flags+=("--delete-collection-workers=")
flags+=("--deserialization-cache-size=")
local_nonpersistent_flags+=("--deserialization-cache-size=")
flags+=("--enable-garbage-collector")
local_nonpersistent_flags+=("--enable-garbage-collector")
flags+=("--enable-swagger-ui")
local_nonpersistent_flags+=("--enable-swagger-ui")
flags+=("--etcd-cafile=")
local_nonpersistent_flags+=("--etcd-cafile=")
flags+=("--etcd-certfile=")
local_nonpersistent_flags+=("--etcd-certfile=")
flags+=("--etcd-keyfile=")
local_nonpersistent_flags+=("--etcd-keyfile=")
flags+=("--etcd-prefix=")
local_nonpersistent_flags+=("--etcd-prefix=")
flags+=("--etcd-quorum-read")
local_nonpersistent_flags+=("--etcd-quorum-read")
flags+=("--etcd-servers=")
local_nonpersistent_flags+=("--etcd-servers=")
flags+=("--etcd-servers-overrides=")
local_nonpersistent_flags+=("--etcd-servers-overrides=")
flags+=("--experimental-encryption-provider-config=")
local_nonpersistent_flags+=("--experimental-encryption-provider-config=")
flags+=("--profiling")
local_nonpersistent_flags+=("--profiling")
flags+=("--requestheader-allowed-names=")
Expand All @@ -38554,10 +38532,6 @@ _openshift_start_template-service-broker()
local_nonpersistent_flags+=("--requestheader-username-headers=")
flags+=("--secure-port=")
local_nonpersistent_flags+=("--secure-port=")
flags+=("--storage-backend=")
local_nonpersistent_flags+=("--storage-backend=")
flags+=("--storage-media-type=")
local_nonpersistent_flags+=("--storage-media-type=")
flags+=("--template-namespace=")
local_nonpersistent_flags+=("--template-namespace=")
flags+=("--tls-ca-file=")
Expand All @@ -38568,8 +38542,6 @@ _openshift_start_template-service-broker()
local_nonpersistent_flags+=("--tls-private-key-file=")
flags+=("--tls-sni-cert-key=")
local_nonpersistent_flags+=("--tls-sni-cert-key=")
flags+=("--watch-cache")
local_nonpersistent_flags+=("--watch-cache")
flags+=("--azure-container-registry-config=")
flags+=("--google-json-key=")
flags+=("--log-flush-frequency=")
Expand Down
28 changes: 0 additions & 28 deletions contrib/completions/zsh/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -38665,30 +38665,8 @@ _openshift_start_template-service-broker()
local_nonpersistent_flags+=("--client-ca-file=")
flags+=("--contention-profiling")
local_nonpersistent_flags+=("--contention-profiling")
flags+=("--delete-collection-workers=")
local_nonpersistent_flags+=("--delete-collection-workers=")
flags+=("--deserialization-cache-size=")
local_nonpersistent_flags+=("--deserialization-cache-size=")
flags+=("--enable-garbage-collector")
local_nonpersistent_flags+=("--enable-garbage-collector")
flags+=("--enable-swagger-ui")
local_nonpersistent_flags+=("--enable-swagger-ui")
flags+=("--etcd-cafile=")
local_nonpersistent_flags+=("--etcd-cafile=")
flags+=("--etcd-certfile=")
local_nonpersistent_flags+=("--etcd-certfile=")
flags+=("--etcd-keyfile=")
local_nonpersistent_flags+=("--etcd-keyfile=")
flags+=("--etcd-prefix=")
local_nonpersistent_flags+=("--etcd-prefix=")
flags+=("--etcd-quorum-read")
local_nonpersistent_flags+=("--etcd-quorum-read")
flags+=("--etcd-servers=")
local_nonpersistent_flags+=("--etcd-servers=")
flags+=("--etcd-servers-overrides=")
local_nonpersistent_flags+=("--etcd-servers-overrides=")
flags+=("--experimental-encryption-provider-config=")
local_nonpersistent_flags+=("--experimental-encryption-provider-config=")
flags+=("--profiling")
local_nonpersistent_flags+=("--profiling")
flags+=("--requestheader-allowed-names=")
Expand All @@ -38703,10 +38681,6 @@ _openshift_start_template-service-broker()
local_nonpersistent_flags+=("--requestheader-username-headers=")
flags+=("--secure-port=")
local_nonpersistent_flags+=("--secure-port=")
flags+=("--storage-backend=")
local_nonpersistent_flags+=("--storage-backend=")
flags+=("--storage-media-type=")
local_nonpersistent_flags+=("--storage-media-type=")
flags+=("--template-namespace=")
local_nonpersistent_flags+=("--template-namespace=")
flags+=("--tls-ca-file=")
Expand All @@ -38717,8 +38691,6 @@ _openshift_start_template-service-broker()
local_nonpersistent_flags+=("--tls-private-key-file=")
flags+=("--tls-sni-cert-key=")
local_nonpersistent_flags+=("--tls-sni-cert-key=")
flags+=("--watch-cache")
local_nonpersistent_flags+=("--watch-cache")
flags+=("--azure-container-registry-config=")
flags+=("--google-json-key=")
flags+=("--log-flush-frequency=")
Expand Down
37 changes: 30 additions & 7 deletions pkg/openservicebroker/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import (
"github.com/openshift/origin/pkg/openservicebroker/server"
)

const defaultEtcdPathPrefix = "/registry/templateservicebroker.openshift.io"

type TemplateServiceBrokerServerOptions struct {
RecommendedOptions *genericoptions.RecommendedOptions
// we don't have any storage, so we shouldn't use the recommended options
SecureServing *genericoptions.SecureServingOptions
Authentication *genericoptions.DelegatingAuthenticationOptions
Authorization *genericoptions.DelegatingAuthorizationOptions
Audit *genericoptions.AuditOptions
Features *genericoptions.FeatureOptions

StdOut io.Writer
StdErr io.Writer
Expand All @@ -26,7 +29,11 @@ type TemplateServiceBrokerServerOptions struct {

func NewTemplateServiceBrokerServerOptions(out, errOut io.Writer) *TemplateServiceBrokerServerOptions {
o := &TemplateServiceBrokerServerOptions{
RecommendedOptions: genericoptions.NewRecommendedOptions(defaultEtcdPathPrefix, server.Scheme, server.Codecs.LegacyCodec()),
SecureServing: genericoptions.NewSecureServingOptions(),
Authentication: genericoptions.NewDelegatingAuthenticationOptions(),
Authorization: genericoptions.NewDelegatingAuthorizationOptions(),
Audit: genericoptions.NewAuditOptions(),
Features: genericoptions.NewFeatureOptions(),

StdOut: out,
StdErr: errOut,
Expand Down Expand Up @@ -57,7 +64,11 @@ func NewCommandStartTemplateServiceBrokerServer(out, errOut io.Writer, stopCh <-
}

flags := cmd.Flags()
o.RecommendedOptions.AddFlags(flags)
o.SecureServing.AddFlags(flags)
o.Authentication.AddFlags(flags)
o.Authorization.AddFlags(flags)
o.Audit.AddFlags(flags)
o.Features.AddFlags(flags)
flags.StringSliceVar(&o.TemplateNamespaces, "template-namespace", o.TemplateNamespaces, "TemplateNamespaces indicates the namespace(s) in which the template service broker looks for templates to serve to the catalog.")

return cmd
Expand All @@ -73,12 +84,24 @@ func (o *TemplateServiceBrokerServerOptions) Complete() error {

func (o TemplateServiceBrokerServerOptions) Config() (*server.TemplateServiceBrokerConfig, error) {
// TODO have a "real" external address
if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, []net.IP{net.ParseIP("127.0.0.1")}); err != nil {
if err := o.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, []net.IP{net.ParseIP("127.0.0.1")}); err != nil {
return nil, fmt.Errorf("error creating self-signed certificates: %v", err)
}

serverConfig := genericapiserver.NewConfig(server.Codecs)
if err := o.RecommendedOptions.ApplyTo(serverConfig); err != nil {
if err := o.SecureServing.ApplyTo(serverConfig); err != nil {
return nil, err
}
if err := o.Authentication.ApplyTo(serverConfig); err != nil {
return nil, err
}
if err := o.Authorization.ApplyTo(serverConfig); err != nil {
return nil, err
}
if err := o.Audit.ApplyTo(serverConfig); err != nil {
return nil, err
}
if err := o.Features.ApplyTo(serverConfig); err != nil {
return nil, err
}

Expand Down

0 comments on commit 4ae0bef

Please sign in to comment.