kubernetes-client / kubernetes-client/javascript

LimitRange default field missing

Open
#855 4 comments 0 reactions 0 assignees View on GitHub
lifecycle/frozen
Dominant language
TypeScript
Stars
2.3k
Forks
568
Avg merge
17h 57m
Merged PRs (30d)
41

Description

When creating a LimitRange I found out that this wouldn't work as expected
```js
const lr_config = {
apiVersion: 'v1',
kind: 'LimitRange',
metadata: {
name: 'default',
},
spec: {
limits: [
{
type: 'Container',
default: {
cpu: '200m',
memory: '800Mi',
},
defaultRequest: {
cpu: '200m',
memory: '800Mi',
},
},
],
},
};
k8sApi_core.createNamespacedLimitRange("default", lr_config);
```
In fact the resource was deployed in the cluster without the field "default"
```
apiVersion: v1
kind: LimitRange
metadata:
creationTimestamp: ***
name: default
namespace: default
resourceVersion: ***
uid: ***
spec:
limits:
- defaultRequest:
cpu: 200m
memory: 800Mi
type: Container
```
Digging the source code I managed to track the issue to [this file](https://github.com/kubernetes-client/javascript/blob/9b09d6a69f92fc6fe22d80c2221be65d96fc358c/src/gen/model/v1LimitRangeItem.ts)

The solution for me was to replace "deafult" with "_default" as follows:
```js
const lr_config = {
apiVersion: 'v1',
kind: 'LimitRange',
...
spec: {
limits: [
{
type: 'Container',
_default: {
cpu: '200m',
memory: '800Mi',
},
...
},
],
},
};
k8sApi_core.createNamespacedLimitRange("default", lr_config);
```
If not possible to use the expected field name I think we should make it clear in the documentation for clarity sake

Contributor guide

Open the contributing guide

Research direction

Start with src/gen/model/v1LimitRangeItem.ts, the file identified in the report, and inspect how the LimitRange item fields are represented and serialized. Reproduce the supplied createNamespacedLimitRange example, then determine whether the expected default field is supported or must be documented under its generated name; done means the behavior or limitation is verified and covered by clear documentation or a regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.