This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Docs to go with the 0.1.0 release #14
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9998ecd
Module Restructuring
db2fdb9
Adds VERSION file to track project version
3de5650
bump to 0.1.0 per PR
aaad87f
Docs to accompany the 0.1.0 release
928d11c
Remove leftover traces that I copied the template tree from amulet
26debea
Correct the incorrect unix sockets
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
PY := .venv/bin/python | ||
|
||
.PHONY: clean | ||
clean: | ||
find . -name '*.pyc' -delete | ||
find . -name '*.bak' -delete | ||
find . -name __pycache__ -delete | ||
rm -f .coverage | ||
|
||
# DEPLOY | ||
.PHONY: docs | ||
docs: | ||
pip3 list | grep Sphinx || pip3 install -U sphinx | ||
cd docs && make html && cd - | ||
|
||
.PHONY: dist | ||
dist: docs | ||
$(PY) setup.py sdist | ||
|
||
.PHONY: publish | ||
publish: docs | ||
$(PY) setup.py sdist upload_docs --upload-dir=docs/build/html | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,4 @@ | ||
import os | ||
import subprocess | ||
|
||
from shlex import split | ||
|
||
from .workspace import Workspace | ||
|
||
|
||
class Docker: | ||
''' | ||
Wrapper class to communicate with the Docker daemon on behalf of | ||
a charmer. Provides stateless operations of a running docker daemon | ||
''' | ||
|
||
def __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 | ||
''' | ||
self.socket = socket | ||
if workspace: | ||
self.workspace = Workspace(workspace) | ||
|
||
def 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 | ||
''' | ||
# TODO: Add TCP:// support for running check | ||
return os.path.isfile(self.socket) | ||
|
||
def 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'] | ||
''' | ||
options = ' '.join(options) | ||
command = ' '.join(commands) | ||
args = ' '.join(arg) | ||
cmd = "docker run {0} {1} {2} {3}".format( | ||
options, image, command, args) | ||
|
||
try: | ||
subprocess.check_output(split(cmd)) | ||
except subprocess.CalledProcessError as expect: | ||
print("Error: ", expect.returncode, expect.output) | ||
|
||
def 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) | ||
''' | ||
cmd = ['docker', 'login', '-u', user, '-p', password, '-e', email] | ||
subprocess.check_call(cmd) | ||
|
||
def ps(self): | ||
''' | ||
return a string of docker status output | ||
''' | ||
cmd = ['docker', 'ps'] | ||
return subprocess.check_output(cmd) | ||
|
||
def pull(self, image): | ||
''' | ||
Pull an image from the docker hub | ||
''' | ||
cmd = ['docker', 'pull', image] | ||
return subprocess.check_output(cmd) | ||
from .docker import Docker # noqa | ||
from .compose import Compose # noqa | ||
from .dockeropts import DockerOpts # noqa | ||
from .workspace import Workspace # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import os | ||
import subprocess | ||
|
||
from shlex import split | ||
|
||
from .workspace import Workspace | ||
|
||
|
||
class Docker: | ||
''' | ||
Wrapper class to communicate with the Docker daemon on behalf of | ||
a charmer. Provides stateless operations of a running docker daemon | ||
''' | ||
|
||
def __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 | ||
''' | ||
self.socket = socket | ||
if workspace: | ||
self.workspace = Workspace(workspace) | ||
|
||
def 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 | ||
''' | ||
# TODO: Add TCP:// support for running check | ||
return os.path.isfile(self.socket) | ||
|
||
def 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'] | ||
''' | ||
options = ' '.join(options) | ||
command = ' '.join(commands) | ||
args = ' '.join(arg) | ||
cmd = "docker run {0} {1} {2} {3}".format( | ||
options, image, command, args) | ||
|
||
try: | ||
subprocess.check_output(split(cmd)) | ||
except subprocess.CalledProcessError as expect: | ||
print("Error: ", expect.returncode, expect.output) | ||
|
||
def 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) | ||
''' | ||
cmd = ['docker', 'login', '-u', user, '-p', password, '-e', email] | ||
subprocess.check_call(cmd) | ||
|
||
def ps(self): | ||
''' | ||
return a string of docker status output | ||
''' | ||
cmd = ['docker', 'ps'] | ||
return subprocess.check_output(cmd) | ||
|
||
def pull(self, image): | ||
''' | ||
Pull an image from the docker hub | ||
''' | ||
cmd = ['docker', 'pull', image] | ||
return subprocess.check_output(cmd) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many slashes here. I don't think you were intending for unix colon slash slash slash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? :) See the daemon options, specifically the -H option: https://docs.docker.com/engine/quickstart/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I see the issue, it is using the third slash as the root dir. If this is correct, you should fix all other uses that do not have three slashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and done. Thanks for pointing that out, I completely missed it even after you called out the funky one that was indeed correct. #whatamidoingwithmylife