Commit 76b252ec authored by Yas Naoi's avatar Yas Naoi
Browse files

Issue #3261006 by yas, Xiaohua Guan: Fix an error to handle an empty apiGroups...

Issue #3261006 by yas, Xiaohua Guan: Fix an error to handle an empty apiGroups field in a rule of K8s role
parent da383484
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -32,9 +32,9 @@ class K8sClient extends Client {
  ) {
    try {
      if ($method === 'PUT' || $method === 'POST') {
        // If the resource type is cluster role, the apiGroups maybe empty,
        // and it cannot be removed.
        if ($uri !== '/clusterroles') {
        // If the resource type is role or cluster role, the apiGroups maybe
        // empty, and it cannot be removed.
        if (!in_array($uri, ['/roles', '/clusterroles'], TRUE)) {
          $array = $this->removeEmptyProperties(json_decode($body, TRUE));
          $body = json_encode($array, JSON_PRETTY_PRINT);
        }