appsody / controller

Appsody controller running in the development container. This repo will be archived soon.
https://appsody.dev
Apache License 2.0
2 stars 12 forks source link

Make ignoring of file watching event actions configurable #39

Open kewegner opened 5 years ago

kewegner commented 5 years ago

In an earlier issue it was found it might be useful to ignore one of the six types of events, specifically DIR WRITE.

We could create additional APPSODY environment variables which allow our users to turn off any of the six actions for either FILES, DIRs or both

The six actions supported by the watcher include:

CREATE WRITE RENAME MOVE REMOVE CHMOD

kewegner commented 4 years ago

These comments assume that directory events would be re-enabled. If not there is no need for the directory piece of this work.

First it must be noted no one has asked for this feature as of yet.

To approach the problem the following would need to be done.

Declare either a single variable or multiple variables in the Dockerfile-stack on two axis: e.g. APPSODY_FILE_CONTROLLER_ACTIONS=chmod,write,create,remove,rename, move APPSODY_DIRECTORY_CONTROLLER_ACTIONS=chmod,write,create,remove,rename, move

-- we may need NONE as an option, and if both are none we might not want to enable the watcher.

The default would be that all actions are allowed for both if no variables are present,

The controller would then need to read in these environment variables.

The watcher could have a map for directory actions allowed and a map for file actions allowed.

The pollEvents loop would need to basically check:

  1. Is the current item a file or a directory.
  2. what is the action being performed and is it allowed for this type (file/directory).

The filter might need to be different in the sense that the action would need to be known, whereas today only the regex or type (file/directory) would need to be known.

If directory events are not needed, or the events are deemed to be the same for file and directory we could also investigate using the filterOps method on the watcher.

// FilterOps filters which event op types should be returned // when an event occurs. func (w *Watcher) FilterOps(ops ...Op) {