Skip to content

Commit 382d621

Browse files
committed
Send NODE_ENV to nodered, auto detect kubernetes
1 parent b978ce0 commit 382d621

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

OpenFlow/src/Config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export class Config {
1212
public static db: DatabaseConnection = null;
1313
public static version: string = fs.readFileSync("VERSION", "utf8");
1414

15+
public static NODE_ENV: string = Config.getEnv("NODE_ENV", "development");
16+
1517
public static auto_create_users: boolean = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));
1618
public static auto_create_domains: string[] = Config.parseArray(Config.getEnv("auto_create_domains", ""));
1719
public static allow_user_registration: boolean = Config.parseBoolean(Config.getEnv("allow_user_registration", "false"));

OpenFlow/src/KubeUtil.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@ export class KubeUtil {
1616
}
1717
constructor() {
1818
const kc = new k8s.KubeConfig();
19-
kc.loadFromCluster();
19+
var success: boolean = false;
20+
try {
21+
kc.loadFromDefault();
22+
success = true;
23+
} catch (error) {
24+
console.log(error);
25+
}
26+
if (success == false) {
27+
try {
28+
kc.loadFromCluster();
29+
success = true;
30+
} catch (error) {
31+
console.log(error);
32+
}
33+
}
2034
this.CoreV1Api = kc.makeApiClient(k8s.CoreV1Api);
2135
this.AppsV1Api = kc.makeApiClient(k8s.AppsV1Api);
2236
this.ExtensionsV1beta1Api = kc.makeApiClient(k8s.ExtensionsV1beta1Api);

OpenFlow/src/Messages/Message.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ export class Message {
824824
{ name: "noderedusers", value: (name + "noderedusers") },
825825
{ name: "noderedadmins", value: (name + "noderedadmins") },
826826
{ name: "api_allow_anonymous", value: user.nodered.api_allow_anonymous.toString() },
827+
{ name: "NODE_ENV", value: Config.NODE_ENV },
827828
],
828829
livenessProbe: {
829830
httpGet: {

OpenFlowNodeRED/src/Config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export class Config {
99
public static nodered_sa: string = Config.getEnv("nodered_sa", "");
1010
public static queue_prefix: string = Config.getEnv("queue_prefix", "");
1111

12+
public static NODE_ENV: string = Config.getEnv("NODE_ENV", "development");
13+
1214
public static saml_federation_metadata: string = Config.getEnv("saml_federation_metadata", "");
1315
public static saml_issuer: string = Config.getEnv("saml_issuer", "");
1416
public static saml_entrypoint: string = Config.getEnv("saml_entrypoint", "");
@@ -23,9 +25,6 @@ export class Config {
2325
public static noderedusers: string = Config.getEnv("noderedusers", "");
2426
public static noderedadmins: string = Config.getEnv("noderedadmins", "");
2527

26-
27-
28-
2928
public static api_ws_url: string = Config.getEnv("api_ws_url", "ws://localhost:3000");
3029
public static amqp_url: string = Config.getEnv("amqp_url", "amqp://localhost");
3130

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.543
1+
0.0.544

0 commit comments

Comments
 (0)