[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[atomic] Thoughts on the atomic cli



While thinking about
https://github.com/projectatomic/atomic/issues/43, I also started
looking at how to implement some ideas.  The existing `atomic` script
isn't particularly modular, so I ended up rewriting the bulk of the
functionality using Python's "cliff" framework.  The results are here:

  https://github.com/larsks/atomic-cli/

This is not intended to be either (a) a drop-in replacement or (b)
entirely functional; it's really just meant as a conversation started
about how the tool is implemented.

These are some of the significant changes:

- Because this is implemented using cliff, each subcommand is a
  separate Python module.  This encourages modularity and makes it
  easy to experiment with new commands.

- The existing script was using a combination of the Docker Python API
  and the Docker CLI for different operations, which made it hard to
  ensure consistent behavior.  This isolates all the Docker operations
  inside a "atomic.dockerapi" module, which at the moment is
  implemented entirely in terms of the "docker" CLI.  The dockerapi
  module provides high-level abstractions for images and containers,
  such that the implementation of most "atomic" subcommands is
  relatively simple.

- The ad-hoc templating (for 'NAME=NAME', 'IMAGE=IMAGE', et al) is
  replaced with the standard python '...string...'.format() call.  In command lines,
  '{image}' is replaced with the image name and '{name}' is replaced
  with the container name, and it is trivial to add additional values
  to the dictionary passed to the format method.

- I tried to write a simple spec to describe the desired behavior.
  It's not half complete, but it's hard to write a tool without some
  sort of end-goal in site.

-- 
Lars Kellogg-Stedman <lars redhat com> | larsks @ {freenode,twitter,github}
Cloud Engineering / OpenStack          | http://blog.oddbit.com/

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]