Global plugin var (BOOL) for server and hack

Overview

I'm have kibana running in different environments (lets call them A and B) and have some plugins that only need to be ran in env A. I need to be able to set a BOOL that I can access in both the server config object and the the hack.js file.

What I have so far:

I have a BOOL that is being sent from the startup script and am able to set it in the server config and access it in all the server index.js files in my plugins.

What I need:

I'm trying to find a way to access this same BOOL in the hack.js files in various plugins. Not sure if there is a better way to handle this, or if there is a way to access or pass that BOOL to the hack.js

Based on your description, I'm assuming your hack.js file lives on the client-side. In your plugin configuration where you define your uiExports, try defining:

uiExports.injectDefaultVars = function(server) {
  const config = server.config();
  return {
    BOOL: config.get('BOOL')
  };
}

Then in your hack.js, you can just inject BOOL as a dependency, just like you inject other Angular dependencies.

Hope that helps,

Shaunak

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.