cfengine / design-center

CFEngine community-contributed content
http://cfengine.com/
Other
80 stars 68 forks source link

Git style configuration for cf-sketch #340

Open nickanderson opened 11 years ago

nickanderson commented 11 years ago

It would really improve my work flow to have a git style config for cf-sketch. For example if I am working on two sperate infrastructures I'll have two sperate masterfiles clones. It would rock if I didn't have to specify the install target when working within the directory tree of each one. The ability to specify the install target relative to a config file found traversing up the directory tree would be awesome. It may be useful to have the configs merged as you go up the tree. (think about how git author, and email work)

My birthday is in September.... Hint hint

tzz commented 11 years ago

That sounds fairly easy to implement: start at pwd, then work up to a .git or .svn directory, then down to sketches or whatever the directory is named. It could be specified as VCS_ROOT/.../sketches for instance, where VCS_ROOT is a literal string and not a directory name. Let me know if this spec is what you had in mind.

nickanderson commented 11 years ago

I was thinking a .cf-sketch directory and then the config for it would be inherited from the top /etc/cf-sketch is inherited by ~/.cf-sketch which is inherited by the local .cf-sketch (just do an up tree directory traversal looking for it).

Thoughts?

tzz commented 11 years ago

I misunderstood and thought you wanted to autodetect just the installation directory. I think you're saying you want the cf-sketch configuration in a special file instead of in the command line. But does that include the API as well, or just cf-sketch the script? If the latter, what settings do you want to store in this config file?

nickanderson commented 11 years ago

Yes, I am more talking about cf-sketch cli tool, not the API. The two primary config options that I think I might want to set per policy repository are install location and sources. If I am working with customer A I might want to point to their private sketch repo. Customer B might use only our community repo. Similar desires for setting Authors and other sketch metadata might come into play for a sketchify tool.

tzz commented 11 years ago

OK, so cf-sketch will look in pwd and then upwards for .cfsketchconfig or something. That file will have

repolist R1
repolist R2
installsource S

If you want more options, speak up. You can have the runfile name and standalone mode; the test/verbose/activated setting, --force, apiconfig...

zzamboni commented 11 years ago

Why not have the config file be a JSON file like one that cf-sketch already reads?

On Jul 2, 2013, at 12:41 PM, Ted Zlatanov notifications@github.com wrote:

OK, so cf-sketch will look in pwd and then upwards for .cfsketchconfig or something. That file will have

repolist R1 repolist R2 installsource S If you want more options, speak up. You can have the runfile name and standalone mode; the test/verbose/activated setting, --force, apiconfig...

— Reply to this email directly or view it on GitHub.

nickanderson commented 11 years ago

I don't care if the config file is JSON, it might as well support any option that makes sense I just dont know how I would use the other options.

If the config file is JSON my next request will be tooling to help write it (think git config --global user.email )

Also I think inherited merging of the config as git does would be nice. Look in /etc/.cf-sketch/config then merge with ~/.cf-sketch/config then merge with pwd up to next .cf-sketch/config each time the more specific config will overwrite any options found in the parent.

tzz commented 11 years ago

Sorry, I don't know what config file cf-sketch reads today. If you mean the apiconfig, that's a different configuration from what @nickanderson is requesting.

zzamboni commented 11 years ago

You are correct, I was confused. The previous version of cf-sketch used to read a config file, the code is still there in perl-lib/DesignCenter/Config.pm but is not being used anymore. Maybe it (or an improved version) could be reused.

On Jul 2, 2013, at 12:50 PM, Ted Zlatanov notifications@github.com wrote:

Sorry, I don't know what config file cf-sketch reads today. If you mean the apiconfig, that's a different configuration from what @nickanderson is requesting.

— Reply to this email directly or view it on GitHub.

tzz commented 11 years ago

Cool. So it the format I proposed OK with @nickanderson? I think I could support that and a JSON format, autodetected, especially if there are only a few options.

nickanderson commented 11 years ago

If you think that configuration format is sufficient for whatever kind of option someone might want to have if they deal with multiple CFEngine masterfiles that are completely unrelated from the same workstation then cool.

Sorry I am only currently able to imagine altering the sketch repo and the install target.

And at least for the install target I should be able to specify the path relative to the configfile or the config directory or whatever so that I can move different repositories around without having to reconfigure the install target.