@@ -42,7 +42,7 @@ func NewCatalog(client *Client) *Catalog {
42
42
}
43
43
}
44
44
45
- // Deletes the Catalog, returning an error if the vCD call fails.
45
+ // Delete deletes the Catalog, returning an error if the vCD call fails.
46
46
// Link to API call: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/DELETE-Catalog.html
47
47
func (catalog * Catalog ) Delete (force , recursive bool ) error {
48
48
@@ -52,7 +52,7 @@ func (catalog *Catalog) Delete(force, recursive bool) error {
52
52
return err
53
53
}
54
54
if catalogID == "" {
55
- return fmt .Errorf ("empty ID returned for catalog ID %s" , catalog .Catalog .ID )
55
+ return fmt .Errorf ("empty ID returned for catalog %s" , catalog .Catalog .Name )
56
56
}
57
57
adminCatalogHREF .Path += "/admin/catalog/" + catalogID
58
58
@@ -61,13 +61,18 @@ func (catalog *Catalog) Delete(force, recursive bool) error {
61
61
"recursive" : strconv .FormatBool (recursive ),
62
62
}, http .MethodDelete , adminCatalogHREF , nil )
63
63
64
- _ , err = checkResp (catalog .client .Http .Do (req ))
65
-
64
+ resp , err := checkResp (catalog .client .Http .Do (req ))
66
65
if err != nil {
67
- return fmt .Errorf ("error deleting Catalog %s: %s" , catalog .Catalog .ID , err )
66
+ return fmt .Errorf ("error deleting Catalog %s: %s" , catalog .Catalog .Name , err )
68
67
}
69
-
70
- return nil
68
+ task := NewTask (catalog .client )
69
+ if err = decodeBody (types .BodyTypeXML , resp , task .Task ); err != nil {
70
+ return fmt .Errorf ("error decoding task response: %s" , err )
71
+ }
72
+ if task .Task .Status == "error" {
73
+ return fmt .Errorf ("catalog not properly destroyed" )
74
+ }
75
+ return task .WaitTaskCompletion ()
71
76
}
72
77
73
78
// Envelope is a ovf description root element. File contains information for vmdk files.
0 commit comments