Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctor 713 custom cloud kuberneted custom change kubenetes api path v1beta in v1 #5109

Merged
39 changes: 28 additions & 11 deletions src/cloud/kubernetes/custom/api.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ sub new {

if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },
'token:s' => { name => 'token' },
'timeout:s' => { name => 'timeout' },
'limit:s' => { name => 'limit' },
'config-file:s' => { name => 'config_file' },
'namespace:s' => { name => 'namespace' }
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },
'token:s' => { name => 'token' },
'timeout:s' => { name => 'timeout' },
'limit:s' => { name => 'limit' },
'config-file:s' => { name => 'config_file' },
'namespace:s' => { name => 'namespace' },
'legacy-api-beta:s' => { name => 'legacy_api_beta' }
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
Expand Down Expand Up @@ -190,9 +191,14 @@ sub request_api_paginate {
sub kubernetes_list_cronjobs {
my ($self, %options) = @_;

my $url_path=$self->{namespace} ne '' ? '/apis/batch/v1/namespaces/' . $self->{namespace} . '/cronjobs' : '/apis/batch/v1/cronjobs';
if (defined($self->{legacy_api_beta})){
$url_path=$self->{namespace} ne '' ? '/apis/batch/v1beta1/namespaces/' . $self->{namespace} . '/cronjobs' : '/apis/batch/v1beta1/cronjobs';
};

my $response = $self->request_api_paginate(
method => 'GET',
url_path => $self->{namespace} ne '' ? '/apis/batch/v1beta1/namespaces/' . $self->{namespace} . '/cronjobs' : '/apis/batch/v1beta1/cronjobs'
url_path => $url_path
);

return $response;
Expand Down Expand Up @@ -234,9 +240,14 @@ sub kubernetes_list_events {
sub kubernetes_list_ingresses {
my ($self, %options) = @_;

my $url_path=$self->{namespace} ne '' ? '/apis/networking.k8s.io/v1/namespaces/' . $self->{namespace} . '/ingresses' : '/apis/networking.k8s.io/v1/ingresses';
if (defined($self->{legacy_api_beta})){
$url_path=$self->{namespace} ne '' ? '/apis/extensions/v1beta1/namespaces/' . $self->{namespace} . '/ingresses' : '/apis/extensions/v1beta1/ingresses';
};

my $response = $self->request_api_paginate(
method => 'GET',
url_path => $self->{namespace} ne '' ? '/apis/extensions/v1beta1/namespaces/' . $self->{namespace} . '/ingresses' : '/apis/extensions/v1beta1/ingresses'
url_path => $url_path
);

return $response;
Expand Down Expand Up @@ -369,7 +380,13 @@ See https://kubernetes.io/docs/reference/kubernetes-api/common-parameters/common

=item B<--namespace>

Set namespace to get informations.
Set namespace to get information.

=item B<--legacy-api-beta>

If this option is set the legacy API path are set for this API calls:
kubernetes_list_cronjobs will use this path: /apis/batch/v1beta1/namespaces/
kubernetes_list_ingresses will use this path: /apis/extensions/v1beta1/namespaces/

=back

Expand Down
5 changes: 5 additions & 0 deletions tests/resources/spellcheck/stopwords.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
--force-oid
--get-param
--ignore-orgs-api-disabled
--legacy-api-beta
--lookup-perfdatas-nagios
--map-speed-dsl
--mqtt
Expand Down Expand Up @@ -122,3 +123,7 @@ uptime
userpass
v1
v2
VDSL2
Veeam
WSMAN
Kubernetes
Loading