Skip to content

Commit 7c4ad3a

Browse files
committed
fix lint issues
1 parent ab31495 commit 7c4ad3a

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

src/serializer.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ObjectSerializer } from "./api";
2-
import { V1ObjectMeta } from "./gen/model/v1ObjectMeta";
1+
import { ObjectSerializer } from './api';
2+
import { V1ObjectMeta } from './gen/model/v1ObjectMeta';
33

44
type AttributeType = {
55
name: string;
@@ -9,36 +9,36 @@ type AttributeType = {
99

1010
class KubernetesObject {
1111
/**
12-
* APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
13-
*/
12+
* APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
13+
*/
1414
'apiVersion'?: string;
1515
/**
16-
* Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
17-
*/
16+
* Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
17+
*/
1818
'kind'?: string;
1919
'metadata'?: V1ObjectMeta;
2020

2121
static attributeTypeMap: AttributeType[] = [
2222
{
23-
"name": "apiVersion",
24-
"baseName": "apiVersion",
25-
"type": "string"
23+
name: 'apiVersion',
24+
baseName: 'apiVersion',
25+
type: 'string'
2626
},
2727
{
28-
"name": "kind",
29-
"baseName": "kind",
30-
"type": "string"
28+
name: 'kind',
29+
baseName: 'kind',
30+
type: 'string'
3131
},
3232
{
33-
"name": "metadata",
34-
"baseName": "metadata",
35-
"type": "V1ObjectMeta"
33+
name: 'metadata',
34+
baseName: 'metadata',
35+
type: 'V1ObjectMeta'
3636
},
3737
];
3838
}
3939

4040
const isKubernetesObject = (data: unknown): boolean =>
41-
!!data && typeof data === "object" && 'apiVersion' in data && 'kind' in data;
41+
!!data && typeof data === 'object' && 'apiVersion' in data && 'kind' in data;
4242

4343
/**
4444
* Wraps the ObjectSerializer to support custom resources and generic Kubernetes objects.
@@ -47,7 +47,7 @@ class KubernetesObjectSerializer {
4747

4848
private static _instance: KubernetesObjectSerializer;
4949

50-
public static get instance() {
50+
public static get instance(): KubernetesObjectSerializer {
5151
if (this._instance) {
5252
return this._instance;
5353
}
@@ -57,7 +57,7 @@ class KubernetesObjectSerializer {
5757

5858
private constructor() {}
5959

60-
public serialize(data: any, type: string) {
60+
public serialize(data: any, type: string): any {
6161
const obj = ObjectSerializer.serialize(data, type);
6262
if(obj !== data) {
6363
return obj;
@@ -82,7 +82,7 @@ class KubernetesObjectSerializer {
8282

8383
}
8484

85-
public deserialize(data: any, type: string) {
85+
public deserialize(data: any, type: string): any {
8686
const obj = ObjectSerializer.deserialize(data, type);
8787
if (obj !== data) {
8888
// the serializer knows the type and already deserialized it.

src/serializer_test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ describe('KubernetesObjectSerializer', () => {
179179
},
180180
});
181181
});
182+
183+
it('should deserialize a unknown primitive', () => {
184+
const s = {
185+
key: 'value',
186+
};
187+
const res = KubernetesObjectSerializer.serialize(s, 'unknown');
188+
expect(res).to.deep.equal(s);
189+
});
182190
});
183191

184192
});

0 commit comments

Comments
 (0)