1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-17 07:48:52 +00:00

Refactor context to be sharable

This commit is contained in:
Darren Shepherd
2020-01-31 15:10:47 -07:00
parent 707b87671b
commit 91dde5ead6
4 changed files with 26 additions and 43 deletions

View File

@@ -16,15 +16,15 @@ type Config struct {
WebhookConfig authcli.WebhookConfig
}
func (c *Config) MustServerConfig() *server.Server {
cc, err := c.ToServerConfig()
func (c *Config) MustServer() *server.Server {
cc, err := c.ToServer()
if err != nil {
panic(err)
}
return cc
}
func (c *Config) ToServerConfig() (*server.Server, error) {
func (c *Config) ToServer() (*server.Server, error) {
restConfig, err := kubeconfig.GetNonInteractiveClientConfig(c.KubeConfig).ClientConfig()
if err != nil {
return nil, err
@@ -39,8 +39,6 @@ func (c *Config) ToServerConfig() (*server.Server, error) {
Namespace: c.Namespace,
RestConfig: restConfig,
AuthMiddleware: auth,
HTTPPort: c.HTTPListenPort,
HTTPSPort: c.HTTPSListenPort,
}, nil
}