Advertisement
Guest User

Untitled

a guest
Nov 5th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.00 KB | None | 0 0
  1. diff --git a/tests/utils.go b/tests/utils.go
  2. index a45b8eb2a..82f77cefb 100644
  3. --- a/tests/utils.go
  4. +++ b/tests/utils.go
  5. @@ -28,6 +28,7 @@ import (
  6.     "fmt"
  7.     "io"
  8.     "io/ioutil"
  9. +   "net/http"
  10.     "os"
  11.     "os/exec"
  12.     "path/filepath"
  13. @@ -359,6 +360,7 @@ func BeforeTestSuitSetup() {
  14.     createNamespaces()
  15.     createServiceAccounts()
  16.     if DeployTestingInfrastructureFlag {
  17. +       WipeTestingInfrastructure()
  18.         DeployTestingInfrastructure()
  19.     }
  20.  
  21. @@ -505,8 +507,9 @@ func ReadManifestYamlFile(pathToManifest string) []unstructured.Unstructured {
  22.     return objects
  23.  }
  24.  
  25. -func isGroupVersionKindScoped(kind schema.GroupVersionKind) bool {
  26. -   if kind.Group == "rbac.authorization.k8s.io" {
  27. +func isNamespaceScoped(kind schema.GroupVersionKind) bool {
  28. +   switch kind.Kind {
  29. +   case "ClusterRole", "ClusterRoleBinding":
  30.         return false
  31.     }
  32.     return true
  33. @@ -518,7 +521,7 @@ func composeResourceURI(object unstructured.Unstructured) string {
  34.         uri += "s"
  35.     }
  36.     uri += "/" + object.GetAPIVersion()
  37. -   if object.GetNamespace() != "" && isGroupVersionKindScoped(object.GroupVersionKind()) {
  38. +   if object.GetNamespace() != "" && isNamespaceScoped(object.GroupVersionKind()) {
  39.         uri += "/namespaces/" + object.GetNamespace()
  40.     }
  41.     uri += "/" + strings.ToLower(object.GetKind())
  42. @@ -549,15 +552,16 @@ func DeleteRawManifest(object unstructured.Unstructured) error {
  43.     PanicOnError(err)
  44.  
  45.     uri := composeResourceURI(object)
  46. -   jsonbody, err := object.MarshalJSON()
  47. +   uri = uri + "/" + object.GetName()
  48.     PanicOnError(err)
  49. -   b, err := virtCli.CoreV1().RESTClient().Delete().RequestURI(uri).Body(jsonbody).DoRaw()
  50. -   if err != nil {
  51. +   result := virtCli.CoreV1().RESTClient().Delete().RequestURI(uri).Do()
  52. +   var code int
  53. +   result.StatusCode(&code)
  54. +   if result.Error() != nil && code != http.StatusNotFound {
  55.         fmt.Printf(fmt.Sprintf("ERROR: Can not delete %s\n", object))
  56.         panic(err)
  57.     }
  58. -   status := unstructured.Unstructured{}
  59. -   return json.Unmarshal(b, &status)
  60. +   return nil
  61.  }
  62.  
  63.  func DeployTestingInfrastructure() {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement