stacker icon indicating copy to clipboard operation
stacker copied to clipboard

Document programatic way to use stacker

Open 1ab23c opened this issue 8 years ago • 4 comments

I have a use case where non-technical staff need access to build and destroy stacks. My goal is to put a simple web interface in place over top of whatever (trying to move away from my hand-coded stack builder). I can mimic command-line usage to run stacker commands, but have a sticking point with access to things like the output of info. Is there any documentation or suggestions on how I can accomplish this? Is there an official way to use stacker progamatically?

1ab23c avatar Jul 26 '17 22:07 1ab23c

Hey @1ab23c - thanks for the issue. There currently isn't any attempt to document the best way to use stacker as a library, other than to share the API documentation. That said, a little while back someone asked a similar question in the stacker Slack team, and @ejholmes provided some guidance here:

https://gist.github.com/ejholmes/1cd43e07bbb761e5544bcac826b10daf

Does that help?

phobologic avatar Jul 28 '17 21:07 phobologic

I'll have a play with that approach. What I have been using is code re-purposed from a test class (test_stacker) which uses parse_args to process an list of command-line arguments:

from stacker.commands import Stacker stacker = Stacker() args = stacker.parse_args([name, env, cfg]) stacker.configure(args) stacker.run(args)

where the name is "info", or "build" etc. and env and cfg are file paths.

My main stick point, however, is logging. I assumed that I could just add another handler to the logger object in either the main Stacker class or the action. So far that hasn't worked. Any tips in that regard?

1ab23c avatar Jul 29 '17 01:07 1ab23c

I fixed the logging issue - a problem with my lack of familiarity with python logging :( - and now have working code that parses the configuration and environment files to build the context arguments; it all seems to work well. Maybe a section could be added to the documentation with the code from @ejholmes and some explanation. Other than that I'm happy to close this issue.

1ab23c avatar Jul 29 '17 09:07 1ab23c

@1ab23c I'd be all for a new section in the documentation - if you're up for it, please submit a PR - otherwise I'll leave this open and change the title so someone can pick it up when they get the chance. Thanks again!

phobologic avatar Sep 17 '17 06:09 phobologic