-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
start a command for running the template service broker #15655
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This file is autogenerated, but we've stopped checking such files into the | ||
repository to reduce the need for rebases. Please run hack/generate-docs.sh to | ||
populate this file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package server | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"net" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
genericapiserver "k8s.io/apiserver/pkg/server" | ||
genericoptions "k8s.io/apiserver/pkg/server/options" | ||
|
||
"github.com/openshift/origin/pkg/openservicebroker/server" | ||
) | ||
|
||
const defaultEtcdPathPrefix = "/registry/templateservicebroker.openshift.io" | ||
|
||
type TemplateServiceBrokerServerOptions struct { | ||
RecommendedOptions *genericoptions.RecommendedOptions | ||
|
||
StdOut io.Writer | ||
StdErr io.Writer | ||
|
||
TemplateNamespaces []string | ||
} | ||
|
||
func NewTemplateServiceBrokerServerOptions(out, errOut io.Writer) *TemplateServiceBrokerServerOptions { | ||
o := &TemplateServiceBrokerServerOptions{ | ||
RecommendedOptions: genericoptions.NewRecommendedOptions(defaultEtcdPathPrefix, server.Scheme, server.Codecs.LegacyCodec()), | ||
|
||
StdOut: out, | ||
StdErr: errOut, | ||
} | ||
|
||
return o | ||
} | ||
|
||
func NewCommandStartTemplateServiceBrokerServer(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command { | ||
o := NewTemplateServiceBrokerServerOptions(out, errOut) | ||
|
||
cmd := &cobra.Command{ | ||
Use: "template-service-broker", | ||
Short: "Launch a template service broker server", | ||
Long: "Launch a template service broker server", | ||
RunE: func(c *cobra.Command, args []string) error { | ||
if err := o.Complete(); err != nil { | ||
return err | ||
} | ||
if err := o.Validate(args); err != nil { | ||
return err | ||
} | ||
if err := o.RunTemplateServiceBrokerServer(stopCh); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
flags := cmd.Flags() | ||
o.RecommendedOptions.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 | ||
} | ||
|
||
func (o TemplateServiceBrokerServerOptions) Validate(args []string) error { | ||
return nil | ||
} | ||
|
||
func (o *TemplateServiceBrokerServerOptions) Complete() error { | ||
return nil | ||
} | ||
|
||
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 { | ||
return nil, fmt.Errorf("error creating self-signed certificates: %v", err) | ||
} | ||
|
||
serverConfig := genericapiserver.NewConfig(server.Codecs) | ||
if err := o.RecommendedOptions.ApplyTo(serverConfig); err != nil { | ||
return nil, err | ||
} | ||
|
||
config := &server.TemplateServiceBrokerConfig{ | ||
GenericConfig: serverConfig, | ||
|
||
TemplateNamespaces: o.TemplateNamespaces, | ||
// TODO add the code to set up the client and informers that you need here | ||
} | ||
return config, nil | ||
} | ||
|
||
func (o TemplateServiceBrokerServerOptions) RunTemplateServiceBrokerServer(stopCh <-chan struct{}) error { | ||
config, err := o.Config() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
server, err := config.Complete().New(genericapiserver.EmptyDelegate) | ||
if err != nil { | ||
return err | ||
} | ||
return server.GenericAPIServer.PrepareRun().Run(stopCh) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, but maybe name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
As I make it more apiserver like, I think we'll change in the other direction. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at what point is this going to serve with a cert signed by the cluster CA? Isn't that going to be necessary for the SC to cleanly talk to it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never. Serving will happen with a cert created and signed by the service serving cert signing. This sets up a default if you don't pass one in, making the "no args run" work.