diff --git a/pkg/client/install.go b/pkg/client/install.go index 59e53c367..8a582f2d1 100644 --- a/pkg/client/install.go +++ b/pkg/client/install.go @@ -43,7 +43,7 @@ func (i *Installer) Install() error { return err } - return kube.Create("helm", &b, nil) + return kube.New(nil).Create("helm", &b) } // InstallYAML is the installation YAML for DM. diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 7f6acf029..0fa72473d 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -9,7 +9,17 @@ import ( "k8s.io/kubernetes/pkg/kubectl/resource" ) -const includeThirdPartyAPIs = false +// Client represents a client capable of communicating with the Kubernetes API. +type Client struct { + config clientcmd.ClientConfig +} + +// New create a new Client +func New(config clientcmd.ClientConfig) *Client { + return &Client{ + config: config, + } +} // ResourceActorFunc performs an action on a signle resource. type ResourceActorFunc func(*resource.Info) error @@ -17,12 +27,13 @@ type ResourceActorFunc func(*resource.Info) error // Create creates kubernetes resources from an io.reader // // Namespace will set the namespace -// Config allows for overiding values from kubectl -func Create(namespace string, reader io.Reader, config clientcmd.ClientConfig) error { - f := cmdutil.NewFactory(config) +func (c *Client) Create(namespace string, reader io.Reader) error { + f := cmdutil.NewFactory(c.config) return perform(f, namespace, reader, createResource) } +const includeThirdPartyAPIs = false + func perform(f *cmdutil.Factory, namespace string, reader io.Reader, fn ResourceActorFunc) error { r := f.NewBuilder(includeThirdPartyAPIs). ContinueOnError().