-
Notifications
You must be signed in to change notification settings - Fork 0
/
features_delete.go
45 lines (40 loc) · 1.27 KB
/
features_delete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package kubernetes_ctx
import "github.com/xunleii/godog-kubernetes/helpers"
// RemoveResource implements the GoDoc step
// - `Kubernetes removes <ApiGroupVersionKind> '<NamespacedName>'`
// It removes the specified resource.
func RemoveResource(ctx *FeatureContext, s ScenarioContext) {
s.Step(
`^Kubernetes removes (`+RxGroupVersionKind+`) '(`+RxNamespacedName+`)'$`,
func(groupVersionKindStr, name string) error {
groupVersionKind, err := helpers.GroupVersionKindFrom(groupVersionKindStr)
if err != nil {
return err
}
namespacedName, _ := helpers.NamespacedNameFrom(name)
_, err = ctx.Delete(groupVersionKind, namespacedName)
return err
},
)
}
// RemoveMultiResource implements the GoDoc step
// - `Kubernetes removes the following resources <RESOURCES_TABLE>`
// It creates several resources in a row.
func RemoveMultiResource(ctx *FeatureContext, s ScenarioContext) {
s.Step(
`^Kubernetes removes the following resources$`,
func(table helpers.ResourceTable) error {
resources, err := helpers.UnmarshalResourceTable(table)
if err != nil {
return err
}
for _, resource := range resources {
_, err := ctx.Delete(resource.GroupVersionKind(), resource.NamespacedName())
if err != nil {
return err
}
}
return nil
},
)
}