ricecooker
ricecooker copied to clipboard
Create json record that contains the generated channel ids for chef classes
Currently if the source domain or source id is not set consistently for a chef, then a ricecooker user could accidentally create a new channel rather than update their previously existing one.
To resolve this, when a chef is first run and no previous channel id is detected, then the generated channel id from the source domain and source id should be written to a module in the same folder as the chef file called channel_ids.json
. This should contain the single object with key value pairs of: "<module_name + "_" + chef_class_name>": "<32 digit hex channel id>"
Where <module_name + "_" + chef_class_name>
is the name of the module the chef class is defined in and the name of the class itself, joined by an underscore. This should describe a unique name within the module namespace, although someone could try to force a malicious collision by judicious use of underscores in their variable names. So be it, as it would only be an act of self harm.
In subsequent runs, ricecooker should attempt to load this JSON file, by doing a relative file load from the file that the chef is defined in. If this is defined, then the defined channel_id constant for that chef class should be cross checked against the generated channel id for the chef, based on the source domain and source id. If they do not match, the chef run should immediately abort with a loud error message informing the user to either revert the source domain and source id change, or to delete channel_ids.json
, or the entry for this specific chef from channel_ids.json
.