You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is issue which i solved. This is just info sharing. Please close this issue.
Currently stackstorm.js script loads all enabled aliases of all packs installed in st2. For scaling of hubot necessary to restrict specific packs to specific hubot instance. I might send PR if i have time but basically i did below changes to stackstorm.js . Hope its helpful for someone. Concept is inspired from new environment variable introduced here #133 ST2_ALIAS_PACK_RESTRICTION
In st2chatops.env file:
export ST2_ALIAS_PACK_RESTRICTION=packs,pack1Name,pack2Name
In scripts/stackstorm.js file:
// To restrict adding aliases from only specific packs.
env.ST2_ALIAS_PACK_RESTRICTION = env.ST2_ALIAS_PACK_RESTRICTION || null;
var loadCommands = function() {
robot.logger.info('Loading commands....');
api.actionAlias.list()
.then(function (aliases) {
// Remove all the existing commands
command_factory.removeCommands();
if (env.ST2_ALIAS_PACK_RESTRICTION) {
robot.logger.info('Aliases only from following packs will be loaded: ' + env.ST2_ALIAS_PACK_RESTRICTION);
var packs = env.ST2_ALIAS_PACK_RESTRICTION;
var packsList = packs.split(",");
_.each(aliases, function (alias) {
if (packsList.indexOf(alias.pack) !== -1){
var name = alias.name;
var formats = alias.formats;
var description = alias.description;
if (alias.enabled === false) {
return;
}
if (!formats || formats.length === 0) {
robot.logger.error('No formats specified for command: ' + name);
return;
}
_.each(formats, function (format) {
var command = formatCommand(robot.logger, name, format.display || format, description);
command_factory.addCommand(command, name, format.display || format, alias,
format.display ? utils.DISPLAY : false);
_.each(format.representation, function (representation) {
command = formatCommand(robot.logger, name, representation, description);
command_factory.addCommand(command, name, representation, alias, utils.REPRESENTATION);
});
});
}});
}
else {
robot.logger.info('Env variable ST2_ALIAS_PACK_RESTRICTION is not set. No aliases from any pack will be loaded ');
}
robot.logger.info(command_factory.st2_hubot_commands.length + ' commands are loaded');
})
.catch(function (err) {
var error_msg = 'Failed to retrieve commands from "%s": %s';
robot.logger.error(util.format(error_msg, env.ST2_API, err.message));
});
};
The text was updated successfully, but these errors were encountered:
It's possible to simply disable aliases individually, and I think that might be the "proper" way to do this.
Is there a particular reason you want to disable all aliases on a per-pack basis? Since this is already possible to do for individual aliases, this feature is a "nice to have", and we probably won't be able to put resources to it for awhile. We would be happy to review PRs implementing this if you can justify why it's important enough.
This is issue which i solved. This is just info sharing. Please close this issue.
Currently stackstorm.js script loads all enabled aliases of all packs installed in st2. For scaling of hubot necessary to restrict specific packs to specific hubot instance. I might send PR if i have time but basically i did below changes to stackstorm.js . Hope its helpful for someone. Concept is inspired from new environment variable introduced here #133 ST2_ALIAS_PACK_RESTRICTION
In st2chatops.env file:
export ST2_ALIAS_PACK_RESTRICTION=packs,pack1Name,pack2Name
In scripts/stackstorm.js file:
// To restrict adding aliases from only specific packs.
env.ST2_ALIAS_PACK_RESTRICTION = env.ST2_ALIAS_PACK_RESTRICTION || null;
var loadCommands = function() {
robot.logger.info('Loading commands....');
};
The text was updated successfully, but these errors were encountered: