Adds login method and refactors run #10

Merged
merged 6 commits into from Jan 13, 2016

Conversation

Projects
None yet
4 participants
Collaborator

chuckbutler commented Jan 12, 2016

No description provided.

chuckbutler added some commits Jan 12, 2016

Collaborator

chuckbutler commented Jan 13, 2016

@marcoceppi Can I get a 🚢 on this?

or @AdamIsrael @tvansteenburgh @mbruzek

Collaborator

chuckbutler commented Jan 13, 2016

With the new comments, the doc came out pretty nice too

CLASSES
    Docker

    class Docker
     |  Wrapper class to communicate with the Docker daemon on behalf of
     |  a charmer. Provides stateless operations of a running docker daemon
     |
     |  Methods defined here:
     |
     |  __init__(self, socket='unix:///var/run/docker.sock', workspace=None)
     |      @param socket - URI to the Docker daemon socket
     |          default: unix://var/run/docker.sock
     |
     |      @param workspace - Path to directory containing a Dockerfile
     |          default: None
     |
     |  login(self, user, password, email)
     |      Docker login exposed as a method.
     |
     |      @param user - Username in the registry
     |      @param password - Password for the registry
     |      @param email - Email address on account (dockerhub)
     |
     |  ps(self)
     |      return a string of docker status output
     |
     |  run(self, image, options=[], commands=[], arg=[])
     |      Docker Run exposed as a method. This wont be as natural as the
     |      command line docker experience.
     |
     |      Docker CLI output example:
     |      Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
     |
     |      @param image - string of the container to pull from the registry,
     |                      eg: ubuntu:latest
     |      @param options - array of string  options, eg: ['-d', '-v /tmp:/tmp']
     |      @param commands - array of string commands, eg: ['ls']
     |      @param arg - array of string command args, eg: ['-al']
     |
     |  running(self)
     |      Predicate method to determine if the daemon we are talking to is
     |      actually online and recieving events.
     |
     |      ex: bootstrap = Docker(socket="unix://var/run/docker-boostrap.sock")
     |      bootstrap.running()
     |      > True

@chuckbutler chuckbutler changed the title from Adds login method to docker object to Adds login method and refactors run Jan 13, 2016

@chuckbutler chuckbutler added this to the v0.0.7 milestone Jan 13, 2016

👍

+ @param image - string of the container to pull from the registry,
+ eg: ubuntu:latest
+ @param options - array of string options, eg: ['-d', '-v /tmp:/tmp']
+ @param commands - array of string commands, eg: ['ls']
@mbruzek

mbruzek Jan 13, 2016

Contributor

Commands is an array? Can you give the docker images more than one command? From the usage it looks like just one command.

+ @param email - Email address on account (dockerhub)
+ '''
+ cmd = ['docker', 'login', '-u', user, '-p', password, '-e', email]
+ subprocess.check_call(cmd)
@mbruzek

mbruzek Jan 13, 2016

Contributor

Should we call the login command in an try/catch so that failed login does not exit the python program? It is fine for now but a possible future improvement.

Contributor

mbruzek commented Jan 13, 2016

I had a few minor questions but nothing blocking this excellent, docstringed code from landing in the upstream. Thanks for making these classes and tests!

mbruzek added a commit that referenced this pull request Jan 13, 2016

Merge pull request #10 from chuckbutler/docker-login
Adds login method and refactors run

@mbruzek mbruzek merged commit 5db2855 into juju-solutions:master Jan 13, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Owner

marcoceppi commented Jan 13, 2016

⛵️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment