@k8slens/extensions 5.6.0-git.dce7e89878.0 → 5.6.0-git.de43df1cca.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ import type { KubeconfigManager } from "../../main/kubeconfig-manager/kubeconfig
9
9
  import type { KubeResource } from "../rbac";
10
10
  import type { VersionDetector } from "../../main/cluster-detectors/version-detector";
11
11
  import type { DetectorRegistry } from "../../main/cluster-detectors/detector-registry";
12
- import type { ClusterState, ClusterRefreshOptions, ClusterMetricsResourceType, ClusterId, ClusterMetadata, ClusterModel, ClusterPreferences, ClusterPrometheusPreferences, UpdateClusterModel } from "../cluster-types";
12
+ import type { ClusterState, ClusterRefreshOptions, ClusterMetricsResourceType, ClusterId, ClusterMetadata, ClusterModel, ClusterPreferences, ClusterPrometheusPreferences, UpdateClusterModel, ClusterConfigData } from "../cluster-types";
13
13
  import { ClusterStatus } from "../cluster-types";
14
14
  import type { CanI } from "./authorization-review.injectable";
15
15
  import type { ListNamespaces } from "./list-namespaces.injectable";
@@ -187,7 +187,7 @@ export declare class Cluster implements ClusterModel, ClusterState {
187
187
  * @internal
188
188
  */
189
189
  get defaultNamespace(): string | undefined;
190
- constructor(dependencies: ClusterDependencies, model: ClusterModel);
190
+ constructor(dependencies: ClusterDependencies, model: ClusterModel, configData: ClusterConfigData);
191
191
  /**
192
192
  * Update cluster data model
193
193
  *
@@ -1,4 +1,4 @@
1
- import type { ClusterModel } from "../cluster-types";
1
+ import type { ClusterConfigData, ClusterModel } from "../cluster-types";
2
2
  import type { Cluster } from "./cluster";
3
- export declare type CreateCluster = (model: ClusterModel) => Cluster;
3
+ export declare type CreateCluster = (model: ClusterModel, configData: ClusterConfigData) => Cluster;
4
4
  export declare const createClusterInjectionToken: import("@ogre-tools/injectable").InjectionToken<CreateCluster, void>;
@@ -5,11 +5,14 @@
5
5
  import { BaseStore } from "../base-store";
6
6
  import { Cluster } from "../cluster/cluster";
7
7
  import type { ClusterModel, ClusterId } from "../cluster-types";
8
+ import type { CreateCluster } from "../cluster/create-cluster-injection-token";
9
+ import type { ReadClusterConfigSync } from "./read-cluster-config.injectable";
8
10
  export interface ClusterStoreModel {
9
11
  clusters?: ClusterModel[];
10
12
  }
11
13
  interface Dependencies {
12
- createCluster: (model: ClusterModel) => Cluster;
14
+ createCluster: CreateCluster;
15
+ readClusterConfigSync: ReadClusterConfigSync;
13
16
  }
14
17
  export declare class ClusterStore extends BaseStore<ClusterStoreModel> {
15
18
  private dependencies;
@@ -0,0 +1,4 @@
1
+ import type { ClusterConfigData, ClusterModel } from "../cluster-types";
2
+ export declare type ReadClusterConfigSync = (model: ClusterModel) => ClusterConfigData;
3
+ declare const readClusterConfigSyncInjectable: import("@ogre-tools/injectable").Injectable<ReadClusterConfigSync, unknown, void>;
4
+ export default readClusterConfigSyncInjectable;
@@ -53,6 +53,14 @@ export interface ClusterModel {
53
53
  */
54
54
  labels?: Record<string, string>;
55
55
  }
56
+ /**
57
+ * This data is retreived from the kubeconfig file before calling the cluster constructor.
58
+ *
59
+ * That is done to remove the external dependency on the construction of Cluster instances.
60
+ */
61
+ export interface ClusterConfigData {
62
+ clusterServerUrl: string;
63
+ }
56
64
  /**
57
65
  * The complete set of cluster settings or preferences
58
66
  */
@@ -0,0 +1,3 @@
1
+ export declare type ReadFileSync = (filePath: string) => string;
2
+ declare const readFileSyncInjectable: import("@ogre-tools/injectable").Injectable<ReadFileSync, unknown, void>;
3
+ export default readFileSyncInjectable;
@@ -23,7 +23,7 @@ export interface ConfigResult {
23
23
  export declare function loadConfigFromString(content: string): ConfigResult;
24
24
  export interface SplitConfigEntry {
25
25
  config: KubeConfig;
26
- error?: string;
26
+ validationResult: ValidateKubeConfigResult;
27
27
  }
28
28
  /**
29
29
  * Breaks kube config into several configs. Each context as it own KubeConfig object
@@ -35,10 +35,18 @@ export declare function splitConfig(kubeConfig: KubeConfig): SplitConfigEntry[];
35
35
  * @returns The yaml representation of the kubeconfig object
36
36
  */
37
37
  export declare function dumpConfigYaml(kubeConfig: PartialDeep<KubeConfig>): string;
38
+ export declare type ValidateKubeConfigResult = {
39
+ error: Error;
40
+ } | {
41
+ error?: undefined;
42
+ context: Context;
43
+ cluster: Cluster;
44
+ user: User;
45
+ };
38
46
  /**
39
47
  * Checks if `config` has valid `Context`, `User`, `Cluster`, and `exec` fields (if present when required)
40
48
  *
41
49
  * Note: This function returns an error instead of throwing it, returning `undefined` if the validation passes
42
50
  */
43
- export declare function validateKubeConfig(config: KubeConfig, contextName: string): Error | undefined;
51
+ export declare function validateKubeConfig(config: KubeConfig, contextName: string): ValidateKubeConfigResult;
44
52
  export {};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@k8slens/extensions",
3
3
  "productName": "OpenLens extensions",
4
4
  "description": "OpenLens - Open Source Kubernetes IDE: extensions",
5
- "version": "5.6.0-git.dce7e89878.0",
5
+ "version": "5.6.0-git.de43df1cca.0",
6
6
  "copyright": "© 2022 OpenLens Authors",
7
7
  "license": "MIT",
8
8
  "main": "dist/src/extensions/extension-api.js",