Commit fb8dd392 authored by Adam Reese's avatar Adam Reese

Merge pull request #645 from adamreese/feat/kube-delete

feat(kube): add delete method
parents d644c220 00ff8acf
......@@ -32,6 +32,14 @@ func (c *Client) Create(namespace string, reader io.Reader) error {
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
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)
return err
}
func deleteResource(info *resource.Info) error {
return resource.NewHelper(info.Client, info.Mapping).Delete(info.Namespace, info.Name)
}
......@@ -65,6 +65,17 @@ func TestPerform(t *testing.T) {
}
}
func TestReal(t *testing.T) {
t.Skip("This is a live test, comment this line to run")
if err := New(nil).Create("test", strings.NewReader(guestbookManifest)); err != nil {
t.Fatal(err)
}
if err := New(nil).Delete("test", strings.NewReader(guestbookManifest)); err != nil {
t.Fatal(err)
}
}
const guestbookManifest = `
apiVersion: v1
kind: Service
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment