Skip to content

Commit

Permalink
frontend KubeObject: Fix type of the patch method
Browse files Browse the repository at this point in the history
Previously it was typed as if it accepted Patch Operations but in fact
it accepts json merge patch. This method wasn't used anywhere so this
bug wasn't visible

Signed-off-by: Oleksandr Dubenko <[email protected]>
  • Loading branch information
sniok committed Jan 14, 2025
1 parent 4b223b8 commit 3fa16d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions frontend/src/lib/k8s/KubeObject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { OpPatch } from 'json-patch';
import { JSONPath } from 'jsonpath-plus';
import { cloneDeep, unset } from 'lodash';
import React, { useMemo } from 'react';
Expand All @@ -7,6 +6,7 @@ import { getCluster } from '../cluster';
import { createRouteURL } from '../router';
import { timeAgo } from '../util';
import { useClusterGroup, useConnectApi } from '.';
import { RecursivePartial } from './api/v1/factories';
import { useKubeObject } from './api/v2/hooks';
import { makeListRequests, useKubeObjectList } from './api/v2/useKubeObjectList';
import { ApiError, apiFactory, apiFactoryWithNamespace, post, QueryParameters } from './apiProxy';
Expand Down Expand Up @@ -457,7 +457,7 @@ export class KubeObject<T extends KubeObjectInterface | KubeEvent = any> {
);
}

patch(body: OpPatch[]) {
patch(body: RecursivePartial<T>) {
const args: any[] = [body];

if (this.isNamespaced) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/k8s/api/v1/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type ApiFactoryWithNamespaceArguments =
| SimpleApiFactoryWithNamespaceArguments
| MultipleApiFactoryWithNamespaceArguments;

type RecursivePartial<T> = {
export type RecursivePartial<T> = {
[P in keyof T]?: T[P] extends (infer U)[]
? RecursivePartial<U>[]
: T[P] extends object | undefined
Expand Down

0 comments on commit 3fa16d5

Please sign in to comment.