feat(kube): add delete method

pull/645/head
Adam Reese 9 years ago
parent eba4c59a84
commit 4a82e7ab4c

@ -32,6 +32,14 @@ func (c *Client) Create(namespace string, reader io.Reader) error {
return perform(f, namespace, reader, createResource) return perform(f, namespace, reader, createResource)
} }
// Delete deletes kubernetes resources from an io.reader
//
// Namespace will set the namespace
func (c *Client) Delete(namespace string, reader io.Reader) error {
f := cmdutil.NewFactory(c.config)
return perform(f, namespace, reader, deleteResource)
}
const includeThirdPartyAPIs = false const includeThirdPartyAPIs = false
func perform(f *cmdutil.Factory, namespace string, reader io.Reader, fn ResourceActorFunc) error { func perform(f *cmdutil.Factory, namespace string, reader io.Reader, fn ResourceActorFunc) error {
@ -73,3 +81,7 @@ func createResource(info *resource.Info) error {
_, err := resource.NewHelper(info.Client, info.Mapping).Create(info.Namespace, true, info.Object) _, err := resource.NewHelper(info.Client, info.Mapping).Create(info.Namespace, true, info.Object)
return err return err
} }
func deleteResource(info *resource.Info) error {
return resource.NewHelper(info.Client, info.Mapping).Delete(info.Namespace, info.Name)
}

Loading…
Cancel
Save