Skip to content
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

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -38471,6 +38471,117 @@ _openshift_start_node()
noun_aliases=()
}

_openshift_start_template-service-broker()
{
last_command="openshift_start_template-service-broker"
commands=()

flags=()
two_word_flags=()
local_nonpersistent_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--audit-log-maxage=")
local_nonpersistent_flags+=("--audit-log-maxage=")
flags+=("--audit-log-maxbackup=")
local_nonpersistent_flags+=("--audit-log-maxbackup=")
flags+=("--audit-log-maxsize=")
local_nonpersistent_flags+=("--audit-log-maxsize=")
flags+=("--audit-log-path=")
local_nonpersistent_flags+=("--audit-log-path=")
flags+=("--audit-policy-file=")
local_nonpersistent_flags+=("--audit-policy-file=")
flags+=("--audit-webhook-config-file=")
local_nonpersistent_flags+=("--audit-webhook-config-file=")
flags+=("--audit-webhook-mode=")
local_nonpersistent_flags+=("--audit-webhook-mode=")
flags+=("--authentication-kubeconfig=")
local_nonpersistent_flags+=("--authentication-kubeconfig=")
flags+=("--authentication-skip-lookup")
local_nonpersistent_flags+=("--authentication-skip-lookup")
flags+=("--authentication-token-webhook-cache-ttl=")
local_nonpersistent_flags+=("--authentication-token-webhook-cache-ttl=")
flags+=("--authorization-kubeconfig=")
local_nonpersistent_flags+=("--authorization-kubeconfig=")
flags+=("--authorization-webhook-cache-authorized-ttl=")
local_nonpersistent_flags+=("--authorization-webhook-cache-authorized-ttl=")
flags+=("--authorization-webhook-cache-unauthorized-ttl=")
local_nonpersistent_flags+=("--authorization-webhook-cache-unauthorized-ttl=")
flags+=("--bind-address=")
local_nonpersistent_flags+=("--bind-address=")
flags+=("--cert-dir=")
local_nonpersistent_flags+=("--cert-dir=")
flags+=("--client-ca-file=")
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=")
local_nonpersistent_flags+=("--requestheader-allowed-names=")
flags+=("--requestheader-client-ca-file=")
local_nonpersistent_flags+=("--requestheader-client-ca-file=")
flags+=("--requestheader-extra-headers-prefix=")
local_nonpersistent_flags+=("--requestheader-extra-headers-prefix=")
flags+=("--requestheader-group-headers=")
local_nonpersistent_flags+=("--requestheader-group-headers=")
flags+=("--requestheader-username-headers=")
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=")
local_nonpersistent_flags+=("--tls-ca-file=")
flags+=("--tls-cert-file=")
local_nonpersistent_flags+=("--tls-cert-file=")
flags+=("--tls-private-key-file=")
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=")
flags+=("--loglevel=")
flags+=("--logspec=")
flags+=("--version")

must_have_one_flag=()
must_have_one_noun=()
noun_aliases=()
}

_openshift_start()
{
last_command="openshift_start"
Expand All @@ -38480,6 +38591,7 @@ _openshift_start()
commands+=("master")
commands+=("network")
commands+=("node")
commands+=("template-service-broker")

flags=()
two_word_flags=()
Expand Down
112 changes: 112 additions & 0 deletions contrib/completions/zsh/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -38620,6 +38620,117 @@ _openshift_start_node()
noun_aliases=()
}

_openshift_start_template-service-broker()
{
last_command="openshift_start_template-service-broker"
commands=()

flags=()
two_word_flags=()
local_nonpersistent_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--audit-log-maxage=")
local_nonpersistent_flags+=("--audit-log-maxage=")
flags+=("--audit-log-maxbackup=")
local_nonpersistent_flags+=("--audit-log-maxbackup=")
flags+=("--audit-log-maxsize=")
local_nonpersistent_flags+=("--audit-log-maxsize=")
flags+=("--audit-log-path=")
local_nonpersistent_flags+=("--audit-log-path=")
flags+=("--audit-policy-file=")
local_nonpersistent_flags+=("--audit-policy-file=")
flags+=("--audit-webhook-config-file=")
local_nonpersistent_flags+=("--audit-webhook-config-file=")
flags+=("--audit-webhook-mode=")
local_nonpersistent_flags+=("--audit-webhook-mode=")
flags+=("--authentication-kubeconfig=")
local_nonpersistent_flags+=("--authentication-kubeconfig=")
flags+=("--authentication-skip-lookup")
local_nonpersistent_flags+=("--authentication-skip-lookup")
flags+=("--authentication-token-webhook-cache-ttl=")
local_nonpersistent_flags+=("--authentication-token-webhook-cache-ttl=")
flags+=("--authorization-kubeconfig=")
local_nonpersistent_flags+=("--authorization-kubeconfig=")
flags+=("--authorization-webhook-cache-authorized-ttl=")
local_nonpersistent_flags+=("--authorization-webhook-cache-authorized-ttl=")
flags+=("--authorization-webhook-cache-unauthorized-ttl=")
local_nonpersistent_flags+=("--authorization-webhook-cache-unauthorized-ttl=")
flags+=("--bind-address=")
local_nonpersistent_flags+=("--bind-address=")
flags+=("--cert-dir=")
local_nonpersistent_flags+=("--cert-dir=")
flags+=("--client-ca-file=")
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=")
local_nonpersistent_flags+=("--requestheader-allowed-names=")
flags+=("--requestheader-client-ca-file=")
local_nonpersistent_flags+=("--requestheader-client-ca-file=")
flags+=("--requestheader-extra-headers-prefix=")
local_nonpersistent_flags+=("--requestheader-extra-headers-prefix=")
flags+=("--requestheader-group-headers=")
local_nonpersistent_flags+=("--requestheader-group-headers=")
flags+=("--requestheader-username-headers=")
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=")
local_nonpersistent_flags+=("--tls-ca-file=")
flags+=("--tls-cert-file=")
local_nonpersistent_flags+=("--tls-cert-file=")
flags+=("--tls-private-key-file=")
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=")
flags+=("--loglevel=")
flags+=("--logspec=")
flags+=("--version")

must_have_one_flag=()
must_have_one_noun=()
noun_aliases=()
}

_openshift_start()
{
last_command="openshift_start"
Expand All @@ -38629,6 +38740,7 @@ _openshift_start()
commands+=("master")
commands+=("network")
commands+=("node")
commands+=("template-service-broker")

flags=()
two_word_flags=()
Expand Down
1 change: 1 addition & 0 deletions docs/man/man1/.files_generated_openshift
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ openshift-start-master-controllers.1
openshift-start-master.1
openshift-start-network.1
openshift-start-node.1
openshift-start-template-service-broker.1
openshift-start.1
openshift-version.1
openshift.1
3 changes: 3 additions & 0 deletions docs/man/man1/openshift-start-template-service-broker.1
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.
4 changes: 4 additions & 0 deletions pkg/cmd/server/start/start_allinone.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/openshift/origin/pkg/cmd/server/crypto"
"github.com/openshift/origin/pkg/cmd/server/start/kubernetes"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
tsbcmd "github.com/openshift/origin/pkg/openservicebroker/cmd/server"
"k8s.io/apimachinery/pkg/util/wait"
)

type AllInOneOptions struct {
Expand Down Expand Up @@ -125,10 +127,12 @@ func NewCommandStartAllInOne(basename string, out, errout io.Writer) (*cobra.Com
startNode, _ := NewCommandStartNode(basename, out, errout)
startNodeNetwork, _ := NewCommandStartNetwork(basename, out, errout)
startEtcdServer, _ := NewCommandStartEtcdServer(RecommendedStartEtcdServerName, basename, out, errout)
startTSBServer := tsbcmd.NewCommandStartTemplateServiceBrokerServer(out, errout, wait.NeverStop)
cmds.AddCommand(startMaster)
cmds.AddCommand(startNode)
cmds.AddCommand(startNodeNetwork)
cmds.AddCommand(startEtcdServer)
cmds.AddCommand(startTSBServer)

startKube := kubernetes.NewCommand("kubernetes", basename, out, errout)
cmds.AddCommand(startKube)
Expand Down
105 changes: 105 additions & 0 deletions pkg/openservicebroker/cmd/server/start.go
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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

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.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, but maybe name server here something slightly different so it doesn't conflict with the imported pkg "github.com/openshift/origin/pkg/openservicebroker/server"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, but maybe name server here something slightly different so it doesn't conflict with the imported pkg "github.com/openshift/origin/pkg/openservicebroker/server"

As I make it more apiserver like, I think we'll change in the other direction.

}
Loading