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
!2309
Issue
#3458095
by yas, zterry95: Fix compatibility with Maclof\Kubernetes\Client
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3458095
by yas, zterry95: Fix compatibility with Maclof\Kubernetes\Client
issue/cloud-3458095:3458095-fix-the-compatibility-6.x
into
6.x
Overview
0
Commits
1
Pipelines
2
Changes
1
Merged
Yas Naoi
requested to merge
issue/cloud-3458095:3458095-fix-the-compatibility-6.x
into
6.x
11 months ago
Overview
0
Commits
1
Pipelines
2
Changes
1
Expand
Closes
#3458095
0
0
Merge request reports
Compare
6.x
version 1
a107a605
11 months ago
6.x (base)
and
latest version
latest version
a107a605
1 commit,
11 months ago
version 1
a107a605
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