mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix cron jobs not being viewable on newer kube (#6542)
* Replace use of legacy globals with injectables Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove dead code Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix error shown to users when load fails Signed-off-by: Sebastian Malton <sebastian@malton.name> * Switch CronJob default apiBase Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
95ec86a2db
commit
5c34d65de8
5 files changed
+37
-24
No files matched your search
@@ -13,7 +13,12 @@ const cronJobApiInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
assert(di.inject(storesAndApisCanBeCreatedInjectionToken), "cronJobApi is only available in certain environments");
|
||||
|
||||
return new CronJobApi();
|
||||
return new CronJobApi({
|
||||
fallbackApiBases: [
|
||||
"/apis/batch/v1beta1/cronjobs",
|
||||
],
|
||||
checkPreferredVersion: true,
|
||||
});
|
||||
},
|
||||
|
||||
injectionToken: kubeApiInjectionToken,
|
||||
|
||||
@@ -73,7 +73,7 @@ export class CronJob extends KubeObject<
|
||||
> {
|
||||
static readonly kind = "CronJob";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/batch/v1beta1/cronjobs";
|
||||
static readonly apiBase = "/apis/batch/v1/cronjobs";
|
||||
|
||||
getSuspendFlag() {
|
||||
return (this.spec.suspend ?? false).toString();
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { ClusterContext } from "./cluster-context";
|
||||
|
||||
import { action, computed, makeObservable, observable, reaction, when } from "mobx";
|
||||
import type { Disposer } from "../utils";
|
||||
import { waitUntilDefined, autoBind, includes, isRequestError, noop, rejectPromiseBy } from "../utils";
|
||||
import { waitUntilDefined, autoBind, includes, noop, rejectPromiseBy } from "../utils";
|
||||
import type { KubeJsonApiDataFor, KubeObject } from "./kube-object";
|
||||
import { KubeStatus } from "./kube-object";
|
||||
import type { IKubeWatchEvent } from "./kube-watch-event";
|
||||
@@ -221,11 +221,7 @@ export abstract class KubeObjectStore<
|
||||
try {
|
||||
return await res ?? [];
|
||||
} catch (error) {
|
||||
onLoadFailure((
|
||||
isRequestError(error)
|
||||
? error.message || error.toString()
|
||||
: "Unknown error"
|
||||
));
|
||||
onLoadFailure(String(error));
|
||||
|
||||
// reset the store because we are loading all, so that nothing is displayed
|
||||
this.items.clear();
|
||||
|
||||
Reference in new issue
Block a user