mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
feat: Allow built versions to specify an environment (#7495)
* feat: Allow built versions to specify an environment - This should be hard coded at build time Signed-off-by: Sebastian Malton <sebastian@malton.name> * chore: Add default value to open-lens Signed-off-by: Sebastian Malton <sebastian@malton.name> * chore: Add --no-bail to test script invocations Signed-off-by: Sebastian Malton <sebastian@malton.name> * chore: Add tests for coverage of new code Signed-off-by: Sebastian Malton <sebastian@malton.name> --------- Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
af1808dbb3
commit
128b05d4d4
6 files changed
+55
-2
No files matched your search
@@ -14,6 +14,7 @@ import { buildVersionInjectionToken } from "../../common/vars/build-semantic-ver
|
||||
import { asLegacyGlobalForExtensionApi } from "../as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||
import enabledExtensionsInjectable from "../../features/extensions/enabled/common/enabled-extensions.injectable";
|
||||
import userPreferencesStateInjectable from "../../features/user-preferences/common/state.injectable";
|
||||
import { lensBuildEnvironmentInjectionToken } from "@k8slens/application";
|
||||
|
||||
const userStore = asLegacyGlobalForExtensionApi(userPreferencesStateInjectable);
|
||||
const enabledExtensions = asLegacyGlobalForExtensionApi(enabledExtensionsInjectable);
|
||||
@@ -53,6 +54,11 @@ export const App = {
|
||||
|
||||
return di.inject(isLinuxInjectable);
|
||||
},
|
||||
get lensBuildEnvironment() {
|
||||
const di = getLegacyGlobalDiForExtensionApi();
|
||||
|
||||
return di.inject(lensBuildEnvironmentInjectionToken);
|
||||
},
|
||||
/**
|
||||
* @deprecated This value is now `""` and is left here for backwards compatibility.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { lensBuildEnvironmentInjectionToken } from "@k8slens/application";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
|
||||
const lensBuildEnvironmentInjectable = getInjectable({
|
||||
id: "lens-build-environment",
|
||||
instantiate: () => "unknown",
|
||||
injectionToken: lensBuildEnvironmentInjectionToken,
|
||||
});
|
||||
|
||||
export default lensBuildEnvironmentInjectable;
|
||||
@@ -7,3 +7,5 @@ export { startApplicationInjectionToken } from "./src/start-application/start-ap
|
||||
|
||||
export { applicationInformationToken } from "./src/application-information-token.no-coverage";
|
||||
export type { ApplicationInformation } from "./src/application-information-token.no-coverage";
|
||||
|
||||
export { lensBuildEnvironmentInjectionToken } from "./src/environment-token";
|
||||
@@ -0,0 +1,22 @@
|
||||
import { createContainer, DiContainer, getInjectable } from "@ogre-tools/injectable";
|
||||
import { lensBuildEnvironmentInjectionToken } from "./environment-token";
|
||||
|
||||
describe("environment-token coverage tests", () => {
|
||||
let di: DiContainer;
|
||||
|
||||
beforeEach(() => {
|
||||
di = createContainer("irrelevant");
|
||||
});
|
||||
|
||||
it("should be able to specify a build environment", () => {
|
||||
di.register(
|
||||
getInjectable({
|
||||
id: "some-id",
|
||||
instantiate: () => "some-value",
|
||||
injectionToken: lensBuildEnvironmentInjectionToken,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(di.inject(lensBuildEnvironmentInjectionToken)).toBe("some-value");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
|
||||
export const lensBuildEnvironmentInjectionToken = getInjectionToken<string>({
|
||||
id: "lens-build-environment-token",
|
||||
});
|
||||
Reference in new issue
Block a user