Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
cloud
Merge requests
!2305
Issue
#3458095
by zterry95, yas: Fix compatibility with Maclof\Kubernetes\Client
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3458095
by zterry95, yas: Fix compatibility with Maclof\Kubernetes\Client
issue/cloud-3458095:3458095-fix-the-compatibility
into
7.x
Overview
0
Commits
3
Pipelines
4
Changes
1
Merged
Yas Naoi
requested to merge
issue/cloud-3458095:3458095-fix-the-compatibility
into
7.x
11 months ago
Overview
0
Commits
3
Pipelines
4
Changes
1
Expand
Closes
#3458095
0
0
Merge request reports
Compare
7.x
version 3
c62be258
11 months ago
version 2
a2e7e555
11 months ago
version 1
30c689f5
11 months ago
7.x (base)
and
latest version
latest version
c62be258
3 commits,
11 months ago
version 3
c62be258
3 commits,
11 months ago
version 2
a2e7e555
2 commits,
11 months ago
version 1
30c689f5
1 commit,
11 months ago
1 file
+
18
−
11
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
modules/cloud_service_providers/k8s/src/Service/K8sClientExtension/K8sClient.php
+
18
−
11
Options
@@ -26,25 +26,32 @@ class K8sClient extends Client {
$method
,
$uri
,
$query
=
[],
$body
=
[]
,
$body
=
NULL
,
$namespace
=
TRUE
,
$apiVersion
=
NULL
,
array
$requestOptions
=
[],
)
{
// Normalize $body to either NULL or a non-empty string if appropriate.
$body
=
empty
(
$body
)
&&
!
is_bool
(
$body
)
&&
!
is_numeric
(
$body
)
?
NULL
:
$body
;
if
(
!
is_null
(
$body
)
&&
!
is_string
(
$body
))
{
throw
new
\InvalidArgumentException
(
'A variable $body must be a string, array, or NULL'
);
}
try
{
if
(
$method
===
'PUT'
||
$method
===
'POST'
)
{
//
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_e
n
code
(
$
array
,
JSON_PRETTY_PRINT
);
}
// If the resource type is K8s role or cluster role, the apiGroups maybe
//
empty, then it cannot be removed.
if
(
!
empty
(
$body
)
&&
in_array
(
$
method
,
[
'PUT'
,
'POST'
])
&&
!
in_array
(
$uri
,
[
'/roles'
,
'/clusterroles'
]
,
TRUE
))
{
$array
=
$this
->
removeEmptyProperties
(
json_
d
ecode
(
$
body
,
TRUE
)
);
$body
=
json_encode
(
$array
,
JSON_PRETTY_PRINT
);
}
if
(
empty
(
$this
->
namespace
))
{
$namespace
=
FALSE
;
}
// Fallback for namespace availability.
$namespace
=
!
empty
(
$this
->
namespace
);
// Handling different response statuses.
$response
=
parent
::
sendRequest
(
$method
,
$uri
,
Loading