Skip to content

Commit e59be43

Browse files
committed
added limitRange api support
1 parent 8cdcb68 commit e59be43

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const Secrets = require('./secrets');
1414
const SideCars = require('./sidecars');
1515
const PVC = require('./pvc');
1616
const CRDs = require('./crds');
17+
const LimitRanges = require('./limitRanges');
1718

1819
class Client {
1920
async init(options) {
@@ -41,6 +42,7 @@ class Client {
4142
this.sidecars = new SideCars(client, namespace, this.kubeVersion, this.configMaps);
4243
this.pvc = new PVC(client, namespace, this.kubeVersion);
4344
this.crds = new CRDs(client, namespace, this.kubeVersion);
45+
this.limitRanges = new LimitRanges(client, namespace, this.kubeVersion);
4446
}
4547
}
4648

lib/limitRanges.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const Client = require('./client-base');
2+
3+
/**
4+
* Client for interacting with Kubernetes LimitRanges.
5+
* Extends the base Kubernetes client.
6+
*/
7+
class LimitRanges extends Client {
8+
/**
9+
* Get a specific LimitRange or a list of LimitRanges.
10+
*
11+
* @param {Object} [options={}] - Query options.
12+
* @param {string} [options.name] - Name of the LimitRange to retrieve.
13+
* @param {string} [options.labelSelector] - Label selector for filtering resources.
14+
* @param {boolean} [options.useNamespace=true] - Whether to scope the request to the current namespace.
15+
* @returns {Promise<Object>} - The retrieved LimitRange(s).
16+
*/
17+
get({ name, labelSelector, useNamespace = true } = {}) {
18+
const prefix = useNamespace
19+
? this._prefix.namespaces(this._namespace).limitranges(name)
20+
: this._client.api.v1.limitranges;
21+
22+
return prefix.get({ qs: { labelSelector } });
23+
}
24+
25+
/**
26+
* Get all LimitRanges (namespaced or cluster-wide).
27+
*
28+
* @param {boolean} [useNamespace=false] - Whether to scope the request to the current namespace.
29+
* @returns {Promise<Object>} - The list of LimitRanges.
30+
*/
31+
all(useNamespace = false) {
32+
return this.get({ useNamespace });
33+
}
34+
}
35+
36+
module.exports = LimitRanges;

0 commit comments

Comments
 (0)