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

pull/194/head
vaikas-google 9 years ago
parent 1331edbc8f
commit ff9a7fe6e6

@ -165,7 +165,12 @@ func (a *Configurator) configureResource(resource *common.Resource, o operation)
case GetOperation: case GetOperation:
return a.k.Get(resource.Name, resource.Type) return a.k.Get(resource.Name, resource.Type)
case DeleteOperation: 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. // Treat deleting a non-existent resource as success.
if err != nil { if err != nil {
if strings.HasSuffix(strings.TrimSpace(ret), "not found") { if strings.HasSuffix(strings.TrimSpace(ret), "not found") {

@ -37,6 +37,6 @@ type KubernetesConfig struct {
type Kubernetes interface { type Kubernetes interface {
Get(name string, resourceType string) (string, error) Get(name string, resourceType string) (string, error)
Create(resource 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) Replace(resource string) (string, error)
} }

@ -100,11 +100,9 @@ func (k *KubernetesKubectl) Create(resource string) (string, error) {
return k.execute(args, resource) return k.execute(args, resource)
} }
func (k *KubernetesKubectl) Delete(name string, resourceType string) (string, error) { func (k *KubernetesKubectl) Delete(resource string) (string, error) {
args := []string{"delete", args := []string{"delete"}
resourceType, return k.execute(args, resource)
name}
return k.execute(args, "")
} }
func (k *KubernetesKubectl) Replace(resource string) (string, error) { func (k *KubernetesKubectl) Replace(resource string) (string, error) {

Loading…
Cancel
Save