Commit ff9a7fe6 authored by vaikas-google's avatar vaikas-google

Use the actual kubernetes object when deleting to ensure it matches what is expected to delete

parent 1331edbc
......@@ -165,7 +165,12 @@ func (a *Configurator) configureResource(resource *common.Resource, o operation)
case GetOperation:
return a.k.Get(resource.Name, resource.Type)
case DeleteOperation:
ret, err = a.k.Delete(resource.Name, resource.Type)
obj, err := marshalResource(resource)
if err != nil {
resource.State = failState(err)
return "", err
}
ret, err = a.k.Delete(obj)
// Treat deleting a non-existent resource as success.
if err != nil {
if strings.HasSuffix(strings.TrimSpace(ret), "not found") {
......
......@@ -37,6 +37,6 @@ type KubernetesConfig struct {
type Kubernetes interface {
Get(name string, resourceType string) (string, error)
Create(resource string) (string, error)
Delete(name string, resourceType string) (string, error)
Delete(resource string) (string, error)
Replace(resource string) (string, error)
}
......@@ -100,11 +100,9 @@ func (k *KubernetesKubectl) Create(resource string) (string, error) {
return k.execute(args, resource)
}
func (k *KubernetesKubectl) Delete(name string, resourceType string) (string, error) {
args := []string{"delete",
resourceType,
name}
return k.execute(args, "")
func (k *KubernetesKubectl) Delete(resource string) (string, error) {
args := []string{"delete"}
return k.execute(args, resource)
}
func (k *KubernetesKubectl) Replace(resource string) (string, error) {
......
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