Compare commits
	
		
			189 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					e7f9faf70c | ||
| 
						 | 
					6294db4ba7 | ||
| 
						 | 
					7523bae996 | ||
| 
						 | 
					68f03b7790 | ||
| 
						 | 
					03f88676a9 | ||
| 
						 | 
					e6661d5f20 | ||
| 
						 | 
					72b5cf8199 | ||
| 
						 | 
					de987026b0 | ||
| 
						 | 
					b7bfe1cb7a | ||
| 
						 | 
					309c0240c0 | ||
| 
						 | 
					bc89a91795 | ||
| 
						 | 
					7e4c82a9ab | ||
| 
						 | 
					64e2f44bf5 | ||
| 
						 | 
					c1dea09711 | ||
| 
						 | 
					e1ef638c5f | ||
| 
						 | 
					867a453500 | ||
| 
						 | 
					8032b1dc83 | ||
| 
						 | 
					19053a8d15 | ||
| 
						 | 
					17e1d82d84 | ||
| 
						 | 
					fd866288f0 | ||
| 
						 | 
					e7f8e14e8f | ||
| 
						 | 
					6adce272b7 | ||
| 
						 | 
					dee0655c8f | ||
| 
						 | 
					628c5aead2 | ||
| 
						 | 
					2f7846aeb9 | ||
| 
						 | 
					ae0972963c | ||
| 
						 | 
					e2ad58a090 | ||
| 
						 | 
					6779db113a | ||
| 
						 | 
					ec50054d52 | ||
| 
						 | 
					7e65313765 | ||
| 
						 | 
					e6de703443 | ||
| 
						 | 
					2b7cfc6ef4 | ||
| 
						 | 
					46736c6137 | ||
| 
						 | 
					7a33417e45 | ||
| 
						 | 
					0cd617d1ea | ||
| 
						 | 
					70fae98a51 | ||
| 
						 | 
					87dd7c3d3b | ||
| 
						 | 
					512b03c098 | ||
| 
						 | 
					bfda0ceb84 | ||
| 
						 | 
					29f8fe0b51 | ||
| 
						 | 
					40f4d51562 | ||
| 
						 | 
					8d59ecee88 | ||
| 
						 | 
					dbc9359c3d | ||
| 
						 | 
					11ed955b37 | ||
| 
						 | 
					88ebe6655b | ||
| 
						 | 
					817a5c5c8e | ||
| 
						 | 
					fbc7b6bb1b | ||
| 
						 | 
					890d62864c | ||
| 
						 | 
					2d1fb4c198 | ||
| 
						 | 
					036ce7d98a | ||
| 
						 | 
					35769b0d5e | ||
| 
						 | 
					03eab4c5f8 | ||
| 
						 | 
					9e92f9621b | ||
| 
						 | 
					4debc53baa | ||
| 
						 | 
					76f6c8fb4f | ||
| 
						 | 
					455ec91735 | ||
| 
						 | 
					43db357466 | ||
| 
						 | 
					97213ac0fc | ||
| 
						 | 
					5087ff02f0 | ||
| 
						 | 
					f9a47face0 | ||
| 
						 | 
					5797c16407 | ||
| 
						 | 
					8c129b2695 | ||
| 
						 | 
					a97662f3f9 | ||
| 
						 | 
					36c0d327c7 | ||
| 
						 | 
					117a58e6b8 | ||
| 
						 | 
					b29fd24f92 | ||
| 
						 | 
					6c5323fb67 | ||
| 
						 | 
					4dc3e32e76 | ||
| 
						 | 
					b7004b2068 | ||
| 
						 | 
					3772d36e41 | ||
| 
						 | 
					86fd8cb82e | ||
| 
						 | 
					2f472ecd36 | ||
| 
						 | 
					d430e7f7fd | ||
| 
						 | 
					5602edb322 | ||
| 
						 | 
					a1066dee5d | ||
| 
						 | 
					30f23ccaa9 | ||
| 
						 | 
					72cc1a08f8 | ||
| 
						 | 
					37bd1d1163 | ||
| 
						 | 
					9d76c260e8 | ||
| 
						 | 
					dba2349f9e | ||
| 
						 | 
					e09818969c | ||
| 
						 | 
					5dd1bf971d | ||
| 
						 | 
					66262869b7 | ||
| 
						 | 
					a7e71687ba | ||
| 
						 | 
					137c71e50d | ||
| 
						 | 
					7c27dde94c | ||
| 
						 | 
					6b432803ff | ||
| 
						 | 
					6394fcea39 | ||
| 
						 | 
					ace93d5e73 | ||
| 
						 | 
					6d3fafb8d3 | ||
| 
						 | 
					875aede316 | ||
| 
						 | 
					667c096ef5 | ||
| 
						 | 
					e06d6a111a | ||
| 
						 | 
					537e1a1b5b | ||
| 
						 | 
					b49d391e73 | ||
| 
						 | 
					0ab4f7ab51 | ||
| 
						 | 
					b41f20ecf2 | ||
| 
						 | 
					9a0e1571c5 | ||
| 
						 | 
					d50282a9ed | ||
| 
						 | 
					169d5e88f9 | ||
| 
						 | 
					488d1aa532 | ||
| 
						 | 
					26a1367cae | ||
| 
						 | 
					0cb83dc4c8 | ||
| 
						 | 
					c9428ae749 | ||
| 
						 | 
					804c0e6971 | ||
| 
						 | 
					fd06872223 | ||
| 
						 | 
					7a3f0cade2 | ||
| 
						 | 
					eb622b5408 | ||
| 
						 | 
					8812f80bb8 | ||
| 
						 | 
					c479121bc6 | ||
| 
						 | 
					bcdba14302 | ||
| 
						 | 
					21674ef7d8 | ||
| 
						 | 
					efb03b2840 | ||
| 
						 | 
					716e8c6db5 | ||
| 
						 | 
					4f7598ada6 | ||
| 
						 | 
					5dcde91936 | ||
| 
						 | 
					64ba618188 | ||
| 
						 | 
					b2ac37c322 | ||
| 
						 | 
					72839fea10 | ||
| 
						 | 
					262ba5e9f4 | ||
| 
						 | 
					d0e1614e08 | ||
| 
						 | 
					da62f2543f | ||
| 
						 | 
					9462adaae2 | ||
| 
						 | 
					952c38e7b3 | ||
| 
						 | 
					00615f5ffa | ||
| 
						 | 
					38f90f396f | ||
| 
						 | 
					4a2f757754 | ||
| 
						 | 
					2016a4c59c | ||
| 
						 | 
					09a8ace624 | ||
| 
						 | 
					8c2ad64439 | ||
| 
						 | 
					e0c6244d54 | ||
| 
						 | 
					2a837762ed | ||
| 
						 | 
					19ce377ee9 | ||
| 
						 | 
					b4532bf9f7 | ||
| 
						 | 
					033636dd46 | ||
| 
						 | 
					769de61657 | ||
| 
						 | 
					9d59278035 | ||
| 
						 | 
					1f510cdd4e | ||
| 
						 | 
					52bfda2ab2 | ||
| 
						 | 
					b92de8a508 | ||
| 
						 | 
					957a5104b8 | ||
| 
						 | 
					a4981f1b2c | ||
| 
						 | 
					beaeecd457 | ||
| 
						 | 
					dcc9088e31 | ||
| 
						 | 
					27e8129caa | ||
| 
						 | 
					7d801379db | ||
| 
						 | 
					420da8c363 | ||
| 
						 | 
					917384a2d9 | ||
| 
						 | 
					e97e69a0e1 | ||
| 
						 | 
					87d51409ff | ||
| 
						 | 
					551b1f04c7 | ||
| 
						 | 
					a35f4ef32e | ||
| 
						 | 
					441f234398 | ||
| 
						 | 
					dc452e2847 | ||
| 
						 | 
					b9ee28ca8d | ||
| 
						 | 
					474ce714db | ||
| 
						 | 
					988afbe1c0 | ||
| 
						 | 
					f9a0d4e881 | ||
| 
						 | 
					78dd5b1d8b | ||
| 
						 | 
					ede15194a1 | ||
| 
						 | 
					88838ec63d | ||
| 
						 | 
					66b902a5e0 | ||
| 
						 | 
					e4d4d5251b | ||
| 
						 | 
					0c50ff7c91 | ||
| 
						 | 
					427edaa1ef | ||
| 
						 | 
					b8c82af838 | ||
| 
						 | 
					57ad1b98ff | ||
| 
						 | 
					9d2bdb6a53 | ||
| 
						 | 
					d97f7c5c6f | ||
| 
						 | 
					abd334f3b8 | ||
| 
						 | 
					33de8a4f07 | ||
| 
						 | 
					93cfd0e597 | ||
| 
						 | 
					537f7c0a01 | ||
| 
						 | 
					e114f877c1 | ||
| 
						 | 
					55bc51c9c2 | ||
| 
						 | 
					d93b662907 | ||
| 
						 | 
					3eec6cdd14 | ||
| 
						 | 
					3b9adf8260 | ||
| 
						 | 
					dde707a97a | ||
| 
						 | 
					50ccf6311b | ||
| 
						 | 
					705a339e49 | ||
| 
						 | 
					f81c240a47 | ||
| 
						 | 
					262095e5bb | ||
| 
						 | 
					ba900c4374 | ||
| 
						 | 
					9dc6b3790d | ||
| 
						 | 
					b96785f2be | ||
| 
						 | 
					dd6f4b1e31 | ||
| 
						 | 
					651291ecad | ||
| 
						 | 
					a5bcec68cb | 
@@ -10,10 +10,8 @@ trim_trailing_whitespace = true
 | 
			
		||||
max_line_length = 120
 | 
			
		||||
 | 
			
		||||
[*.go]
 | 
			
		||||
indent_size = 4
 | 
			
		||||
 | 
			
		||||
[Makefile]
 | 
			
		||||
indent_style = tab
 | 
			
		||||
indent_size = 4
 | 
			
		||||
 | 
			
		||||
[package.json]
 | 
			
		||||
indent_size = 1
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
*.snapshot binary
 | 
			
		||||
							
								
								
									
										6
									
								
								.github/golang/Dockerfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.github/golang/Dockerfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
FROM golang:1.12
 | 
			
		||||
 | 
			
		||||
COPY entrypoint.sh /entrypoint.sh
 | 
			
		||||
 | 
			
		||||
ENTRYPOINT ["/entrypoint.sh"]
 | 
			
		||||
CMD [""]
 | 
			
		||||
							
								
								
									
										4
									
								
								.github/golang/entrypoint.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								.github/golang/entrypoint.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
go test -cover ./...
 | 
			
		||||
							
								
								
									
										9
									
								
								.github/goreleaser/Dockerfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								.github/goreleaser/Dockerfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
FROM goreleaser/goreleaser:v0.106
 | 
			
		||||
 | 
			
		||||
RUN go get -u github.com/gobuffalo/packr/packr
 | 
			
		||||
RUN apk --no-cache add nodejs-current nodejs-npm && npm i -g npm
 | 
			
		||||
 | 
			
		||||
COPY entrypoint.sh /entrypoint.sh
 | 
			
		||||
 | 
			
		||||
ENTRYPOINT ["/entrypoint.sh"]
 | 
			
		||||
CMD [""]
 | 
			
		||||
							
								
								
									
										18
									
								
								.github/goreleaser/entrypoint.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										18
									
								
								.github/goreleaser/entrypoint.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
if [ -n "$DOCKER_USERNAME" ] && [ -n "$DOCKER_PASSWORD" ]; then
 | 
			
		||||
    echo "Login to the docker..."
 | 
			
		||||
    docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Workaround for github actions when access to different repositories is needed.
 | 
			
		||||
# Github actions provides a GITHUB_TOKEN secret that can only access the current
 | 
			
		||||
# repository and you cannot configure it's value.
 | 
			
		||||
# Access to different repositories is needed by brew for example.
 | 
			
		||||
 | 
			
		||||
if [ -n "$GORELEASER_GITHUB_TOKEN" ] ; then
 | 
			
		||||
  export GITHUB_TOKEN=$GORELEASER_GITHUB_TOKEN
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
npm ci
 | 
			
		||||
goreleaser $@
 | 
			
		||||
							
								
								
									
										23
									
								
								.github/main.workflow
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								.github/main.workflow
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
workflow "Release" {
 | 
			
		||||
  on = "push"
 | 
			
		||||
  resolves = [
 | 
			
		||||
    "release",
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
action "test" {
 | 
			
		||||
  uses = "./.github/golang/"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
action "is-tag" {
 | 
			
		||||
  uses = "actions/bin/filter@master"
 | 
			
		||||
  needs = ["test"]
 | 
			
		||||
  args = "tag"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
action "release" {
 | 
			
		||||
  uses = "./.github/goreleaser/"
 | 
			
		||||
  needs = ["is-tag"]
 | 
			
		||||
  args = "release"
 | 
			
		||||
  secrets = ["GITHUB_TOKEN", "DOCKER_USERNAME", "DOCKER_PASSWORD"]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -4,4 +4,5 @@ node_modules
 | 
			
		||||
.cache
 | 
			
		||||
static
 | 
			
		||||
a_main-packr.go
 | 
			
		||||
dozzle
 | 
			
		||||
dozzle
 | 
			
		||||
gin-bin
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								.reflex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.reflex
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
-r '\.go$' -R '^node_modules/' -R '^static/' -R '^.cache/' -G '*_test.go' -s -- go run main.go --level debug
 | 
			
		||||
							
								
								
									
										26
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								.travis.yml
									
									
									
									
									
								
							@@ -1,26 +0,0 @@
 | 
			
		||||
language: go
 | 
			
		||||
 | 
			
		||||
go:
 | 
			
		||||
  - "1.11"
 | 
			
		||||
 | 
			
		||||
services:
 | 
			
		||||
  - docker
 | 
			
		||||
 | 
			
		||||
before_install:
 | 
			
		||||
  - nvm install --lts
 | 
			
		||||
  - npm i -g npm
 | 
			
		||||
  - npm ci
 | 
			
		||||
  - go get -u github.com/gobuffalo/packr/packr
 | 
			
		||||
 | 
			
		||||
after_success:
 | 
			
		||||
  # docker login is required if you want to push docker images.
 | 
			
		||||
  # DOCKER_PASSWORD should be a secret in your .travis.yml configuration.
 | 
			
		||||
  # - test -n "$TRAVIS_TAG" && docker login -u=myuser -p="$DOCKER_PASSWORD"
 | 
			
		||||
 | 
			
		||||
deploy:
 | 
			
		||||
  - provider: script
 | 
			
		||||
    skip_cleanup: true
 | 
			
		||||
    script: curl -sL https://git.io/goreleaser | bash
 | 
			
		||||
    on:
 | 
			
		||||
      tags: true
 | 
			
		||||
      condition: $TRAVIS_OS_NAME = linux
 | 
			
		||||
							
								
								
									
										76
									
								
								CODE_OF_CONDUCT.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								CODE_OF_CONDUCT.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,76 @@
 | 
			
		||||
# Contributor Covenant Code of Conduct
 | 
			
		||||
 | 
			
		||||
## Our Pledge
 | 
			
		||||
 | 
			
		||||
In the interest of fostering an open and welcoming environment, we as
 | 
			
		||||
contributors and maintainers pledge to making participation in our project and
 | 
			
		||||
our community a harassment-free experience for everyone, regardless of age, body
 | 
			
		||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
 | 
			
		||||
level of experience, education, socio-economic status, nationality, personal
 | 
			
		||||
appearance, race, religion, or sexual identity and orientation.
 | 
			
		||||
 | 
			
		||||
## Our Standards
 | 
			
		||||
 | 
			
		||||
Examples of behavior that contributes to creating a positive environment
 | 
			
		||||
include:
 | 
			
		||||
 | 
			
		||||
* Using welcoming and inclusive language
 | 
			
		||||
* Being respectful of differing viewpoints and experiences
 | 
			
		||||
* Gracefully accepting constructive criticism
 | 
			
		||||
* Focusing on what is best for the community
 | 
			
		||||
* Showing empathy towards other community members
 | 
			
		||||
 | 
			
		||||
Examples of unacceptable behavior by participants include:
 | 
			
		||||
 | 
			
		||||
* The use of sexualized language or imagery and unwelcome sexual attention or
 | 
			
		||||
 advances
 | 
			
		||||
* Trolling, insulting/derogatory comments, and personal or political attacks
 | 
			
		||||
* Public or private harassment
 | 
			
		||||
* Publishing others' private information, such as a physical or electronic
 | 
			
		||||
 address, without explicit permission
 | 
			
		||||
* Other conduct which could reasonably be considered inappropriate in a
 | 
			
		||||
 professional setting
 | 
			
		||||
 | 
			
		||||
## Our Responsibilities
 | 
			
		||||
 | 
			
		||||
Project maintainers are responsible for clarifying the standards of acceptable
 | 
			
		||||
behavior and are expected to take appropriate and fair corrective action in
 | 
			
		||||
response to any instances of unacceptable behavior.
 | 
			
		||||
 | 
			
		||||
Project maintainers have the right and responsibility to remove, edit, or
 | 
			
		||||
reject comments, commits, code, wiki edits, issues, and other contributions
 | 
			
		||||
that are not aligned to this Code of Conduct, or to ban temporarily or
 | 
			
		||||
permanently any contributor for other behaviors that they deem inappropriate,
 | 
			
		||||
threatening, offensive, or harmful.
 | 
			
		||||
 | 
			
		||||
## Scope
 | 
			
		||||
 | 
			
		||||
This Code of Conduct applies both within project spaces and in public spaces
 | 
			
		||||
when an individual is representing the project or its community. Examples of
 | 
			
		||||
representing a project or community include using an official project e-mail
 | 
			
		||||
address, posting via an official social media account, or acting as an appointed
 | 
			
		||||
representative at an online or offline event. Representation of a project may be
 | 
			
		||||
further defined and clarified by project maintainers.
 | 
			
		||||
 | 
			
		||||
## Enforcement
 | 
			
		||||
 | 
			
		||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
 | 
			
		||||
reported by contacting the project team at findamir@gmail.com. All
 | 
			
		||||
complaints will be reviewed and investigated and will result in a response that
 | 
			
		||||
is deemed necessary and appropriate to the circumstances. The project team is
 | 
			
		||||
obligated to maintain confidentiality with regard to the reporter of an incident.
 | 
			
		||||
Further details of specific enforcement policies may be posted separately.
 | 
			
		||||
 | 
			
		||||
Project maintainers who do not follow or enforce the Code of Conduct in good
 | 
			
		||||
faith may face temporary or permanent repercussions as determined by other
 | 
			
		||||
members of the project's leadership.
 | 
			
		||||
 | 
			
		||||
## Attribution
 | 
			
		||||
 | 
			
		||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
 | 
			
		||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
 | 
			
		||||
 | 
			
		||||
[homepage]: https://www.contributor-covenant.org
 | 
			
		||||
 | 
			
		||||
For answers to common questions about this code of conduct, see
 | 
			
		||||
https://www.contributor-covenant.org/faq
 | 
			
		||||
@@ -7,4 +7,3 @@ ENV DOCKER_API_VERSION 1.38
 | 
			
		||||
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
 | 
			
		||||
COPY dozzle /
 | 
			
		||||
ENTRYPOINT ["/dozzle"]
 | 
			
		||||
EXPOSE 8080
 | 
			
		||||
							
								
								
									
										28
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								README.md
									
									
									
									
									
								
							@@ -1,3 +1,9 @@
 | 
			
		||||
[](https://goreportcard.com/report/github.com/amir20/dozzle)
 | 
			
		||||
[](https://travis-ci.org/amir20/dozzle)
 | 
			
		||||
[](https://hub.docker.com/r/amir20/dozzle/)
 | 
			
		||||
[](https://hub.docker.com/r/amir20/dozzle/)
 | 
			
		||||
[](https://hub.docker.com/r/amir20/dozzle/)
 | 
			
		||||
 | 
			
		||||
# dozzle
 | 
			
		||||
 | 
			
		||||
Dozzle is a log viewer for Docker. It's free. It's small. And it's right in your browser. Oh, did I mention it is also real-time?
 | 
			
		||||
@@ -33,24 +39,24 @@ will bind to `localhost` on port `1224`. You can then use a reverse proxy to con
 | 
			
		||||
#### Changing base URL
 | 
			
		||||
 | 
			
		||||
dozzle by default mounts to "/". If you want to control the base path you can use the `--base` option. For example, if you want to mount at "/foobar",
 | 
			
		||||
then you can override by using `--base /foobar`.
 | 
			
		||||
then you can override by using `--base /foobar`. See env variables below for using `DOZZLE_BASE` to change this.
 | 
			
		||||
 | 
			
		||||
    $ docker run --volume=/var/run/docker.sock:/var/run/docker.sock -p 8888:8080 amir20/dozzle:latest --base /foobar
 | 
			
		||||
    $ docker run --volume=/var/run/docker.sock:/var/run/docker.sock -p 8080:8080 amir20/dozzle:latest --base /foobar
 | 
			
		||||
 | 
			
		||||
dozzle will be available at [http://localhost:8080/foobar/](http://localhost:8080/foobar/).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#### Environment variable, DOCKER_API_VERSION
 | 
			
		||||
#### Environment variables and configuration
 | 
			
		||||
 | 
			
		||||
If you see
 | 
			
		||||
Dozzle follows the [12-factor](https://12factor.net/) model. Configurations can use the CLI flags or enviroment variables. The table below outlines all supported options and their respective env vars.
 | 
			
		||||
 | 
			
		||||
    2018/10/31 08:53:17 Error response from daemon: client version 1.40 is too new. Maximum supported API version is 1.38
 | 
			
		||||
 | 
			
		||||
Then you need to modify `DOCKER_API_VERSION` to let dozzle know which version of the API is supported. By default, `DOCKER_API_VERSION=1.38` and you can change it by passing `-e` flag. For example, this would change the `DOCKER_API_VERSION` to `1.20`
 | 
			
		||||
 | 
			
		||||
    $ docker run --volume=/var/run/docker.sock:/var/run/docker.sock -e DOCKER_API_VERSION=1.20 -p 8888:8080 amir20/dozzle:latest
 | 
			
		||||
 | 
			
		||||
If you are not sure what to set `DOCKER_API_VERSION` then run `docker version` which will show supported API version.
 | 
			
		||||
| Flag | Env Variable | Default |
 | 
			
		||||
| --- | --- | --- |
 | 
			
		||||
| `--addr` | `DOZZLE_ADDR` | `:8080` |
 | 
			
		||||
| `--base` | `DOZZLE_BASE` | `/` |
 | 
			
		||||
| `--level` | `DOZZLE_LEVEL` | `info` |
 | 
			
		||||
| n/a | `DOCKER_API_VERSION` | `1.38` |
 | 
			
		||||
| `--tailSize` | `DOZZLE_TAILSIZE` | `300` |
 | 
			
		||||
 | 
			
		||||
## License
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										77
									
								
								__snapshots__/dozzle.snapshot
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								__snapshots__/dozzle.snapshot
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
			
		||||
/* snapshot: Test_createRoutes_foobar */
 | 
			
		||||
HTTP/1.1 200 OK
 | 
			
		||||
Connection: close
 | 
			
		||||
Content-Type: text/plain; charset=utf-8
 | 
			
		||||
 | 
			
		||||
foo page
 | 
			
		||||
 | 
			
		||||
/* snapshot: Test_createRoutes_index */
 | 
			
		||||
HTTP/1.1 200 OK
 | 
			
		||||
Connection: close
 | 
			
		||||
Content-Type: text/plain; charset=utf-8
 | 
			
		||||
 | 
			
		||||
index page
 | 
			
		||||
 | 
			
		||||
/* snapshot: Test_createRoutes_redirect */
 | 
			
		||||
HTTP/1.1 301 Moved Permanently
 | 
			
		||||
Connection: close
 | 
			
		||||
Content-Type: text/html; charset=utf-8
 | 
			
		||||
Location: /foobar/
 | 
			
		||||
 | 
			
		||||
<a href="/foobar/">Moved Permanently</a>.
 | 
			
		||||
 | 
			
		||||
/* snapshot: Test_createRoutes_version */
 | 
			
		||||
HTTP/1.1 200 OK
 | 
			
		||||
Connection: close
 | 
			
		||||
Content-Type: text/plain; charset=utf-8
 | 
			
		||||
 | 
			
		||||
dev
 | 
			
		||||
none
 | 
			
		||||
unknown
 | 
			
		||||
 | 
			
		||||
/* snapshot: Test_handler_listContainers_happy */
 | 
			
		||||
HTTP/1.1 200 OK
 | 
			
		||||
Connection: close
 | 
			
		||||
Content-Type: text/plain; charset=utf-8
 | 
			
		||||
 | 
			
		||||
[{"id":"1234567890","names":null,"name":"test","image":"image","imageId":"image_id","command":"command","created":0,"state":"state","status":"status"}]
 | 
			
		||||
 | 
			
		||||
/* snapshot: Test_handler_streamEvents_error */
 | 
			
		||||
HTTP/1.1 200 OK
 | 
			
		||||
Connection: close
 | 
			
		||||
Cache-Control: no-cache
 | 
			
		||||
Connection: keep-alive
 | 
			
		||||
Content-Type: text/event-stream
 | 
			
		||||
 | 
			
		||||
/* snapshot: Test_handler_streamEvents_error_request */
 | 
			
		||||
HTTP/1.1 200 OK
 | 
			
		||||
Connection: close
 | 
			
		||||
Cache-Control: no-cache
 | 
			
		||||
Connection: keep-alive
 | 
			
		||||
Content-Type: text/event-stream
 | 
			
		||||
 | 
			
		||||
/* snapshot: Test_handler_streamEvents_happy */
 | 
			
		||||
HTTP/1.1 200 OK
 | 
			
		||||
Connection: close
 | 
			
		||||
Cache-Control: no-cache
 | 
			
		||||
Connection: keep-alive
 | 
			
		||||
Content-Type: text/event-stream
 | 
			
		||||
 | 
			
		||||
event: containers-changed
 | 
			
		||||
data: start
 | 
			
		||||
 | 
			
		||||
/* snapshot: Test_handler_streamLogs_error_reading */
 | 
			
		||||
HTTP/1.1 200 OK
 | 
			
		||||
Connection: close
 | 
			
		||||
Cache-Control: no-cache
 | 
			
		||||
Connection: keep-alive
 | 
			
		||||
Content-Type: text/event-stream
 | 
			
		||||
 | 
			
		||||
/* snapshot: Test_handler_streamLogs_happy */
 | 
			
		||||
HTTP/1.1 200 OK
 | 
			
		||||
Connection: close
 | 
			
		||||
Cache-Control: no-cache
 | 
			
		||||
Connection: keep-alive
 | 
			
		||||
Content-Type: text/event-stream
 | 
			
		||||
 | 
			
		||||
data: INFO Testing logs...
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
<template lang="html">
 | 
			
		||||
  <div class="columns is-marginless">
 | 
			
		||||
    <aside class="column menu is-2">
 | 
			
		||||
    <aside class="column menu is-2-desktop is-3-tablet">
 | 
			
		||||
      <a
 | 
			
		||||
        role="button"
 | 
			
		||||
        class="navbar-burger burger is-white is-hidden-tablet is-pulled-right"
 | 
			
		||||
        @click="showNav = !showNav;"
 | 
			
		||||
        @click="showNav = !showNav"
 | 
			
		||||
        :class="{ 'is-active': showNav }"
 | 
			
		||||
      >
 | 
			
		||||
        <span></span> <span></span> <span></span>
 | 
			
		||||
@@ -13,32 +13,55 @@
 | 
			
		||||
      <p class="menu-label is-hidden-mobile" :class="{ 'is-active': showNav }">Containers</p>
 | 
			
		||||
      <ul class="menu-list is-hidden-mobile" :class="{ 'is-active': showNav }">
 | 
			
		||||
        <li v-for="item in containers">
 | 
			
		||||
          <router-link
 | 
			
		||||
            :to="{ name: 'container', params: { id: item.Id } }"
 | 
			
		||||
            active-class="is-active"
 | 
			
		||||
            class="tooltip is-tooltip-right is-tooltip-info"
 | 
			
		||||
            :data-tooltip="item.Names[0]"
 | 
			
		||||
          >
 | 
			
		||||
            <div class="hide-overflow">{{ item.Names[0] }}</div>
 | 
			
		||||
          <router-link :to="{ name: 'container', params: { id: item.id, name: item.name } }" active-class="is-active">
 | 
			
		||||
            <div class="hide-overflow">{{ item.name }}</div>
 | 
			
		||||
          </router-link>
 | 
			
		||||
        </li>
 | 
			
		||||
      </ul>
 | 
			
		||||
    </aside>
 | 
			
		||||
    <div class="column is-offset-2"><router-view></router-view></div>
 | 
			
		||||
    <div class="column is-offset-2-desktop is-offset-3-tablet">
 | 
			
		||||
      <router-view></router-view>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
let es;
 | 
			
		||||
export default {
 | 
			
		||||
  name: "App",
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      title: "Dozzle",
 | 
			
		||||
      containers: [],
 | 
			
		||||
      showNav: false
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  metaInfo() {
 | 
			
		||||
    return {
 | 
			
		||||
      title: this.title
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  async created() {
 | 
			
		||||
    this.containers = await (await fetch(`${BASE_PATH}/api/containers.json`)).json();
 | 
			
		||||
    await this.fetchContainerList();
 | 
			
		||||
    this.title = `${this.containers.length} containers - Dozzle`;
 | 
			
		||||
    es = new EventSource(`${BASE_PATH}/api/events/stream`);
 | 
			
		||||
    es.addEventListener("containers-changed", e => setTimeout(this.fetchContainerList, 1000), false);
 | 
			
		||||
  },
 | 
			
		||||
  beforeDestroy() {
 | 
			
		||||
    if (es) {
 | 
			
		||||
      es.close();
 | 
			
		||||
      es = null;
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    async fetchContainerList() {
 | 
			
		||||
      this.containers = await (await fetch(`${BASE_PATH}/api/containers.json`)).json();
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  watch: {
 | 
			
		||||
    $route(to, from) {
 | 
			
		||||
      this.showNav = false;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
@@ -57,6 +80,13 @@ aside {
 | 
			
		||||
  z-index: 2;
 | 
			
		||||
  padding: 1em;
 | 
			
		||||
 | 
			
		||||
  @media screen and (min-width: 769px) {
 | 
			
		||||
    & {
 | 
			
		||||
      height: 100vh;
 | 
			
		||||
      overflow: auto;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @media screen and (max-width: 768px) {
 | 
			
		||||
    & {
 | 
			
		||||
      position: sticky;
 | 
			
		||||
@@ -66,11 +96,6 @@ aside {
 | 
			
		||||
      background: #222;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    .tooltip::after,
 | 
			
		||||
    .tooltip::before {
 | 
			
		||||
      display: none !important;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    .menu-label {
 | 
			
		||||
      margin-top: 1em;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,7 @@ export default {
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  watch: {
 | 
			
		||||
    messages(newValue, oldValue) {
 | 
			
		||||
    messages() {
 | 
			
		||||
      if (this.visible) {
 | 
			
		||||
        this.hasNew = true;
 | 
			
		||||
      } else {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								assets/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 88 KiB  | 
@@ -3,12 +3,13 @@
 | 
			
		||||
  <head>
 | 
			
		||||
    <meta charset="utf-8" />
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1" />
 | 
			
		||||
    <title>{{ .Hostname }} - Dozzle</title>
 | 
			
		||||
    <title>Dozzle</title>
 | 
			
		||||
    <link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono|Gafata" rel="stylesheet" />
 | 
			
		||||
    <link rel="manifest" href="manifest.webmanifest" />
 | 
			
		||||
    <link href="styles.scss" rel="stylesheet" />
 | 
			
		||||
    <link rel="icon" href="favicon.ico">
 | 
			
		||||
    <script>
 | 
			
		||||
      window["BASE_PATH"] = "{{ .Base }}";
 | 
			
		||||
      window["SSL_ENABLED"] = "{{ .SSL }}".toLowerCase() === "true";
 | 
			
		||||
    </script>
 | 
			
		||||
    <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
 | 
			
		||||
  </head>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,12 @@
 | 
			
		||||
import Vue from "vue";
 | 
			
		||||
import VueRouter from "vue-router";
 | 
			
		||||
import Meta from "vue-meta";
 | 
			
		||||
import App from "./App.vue";
 | 
			
		||||
import Container from "./pages/Container.vue";
 | 
			
		||||
import Index from "./pages/Index.vue";
 | 
			
		||||
 | 
			
		||||
Vue.use(VueRouter);
 | 
			
		||||
Vue.use(Meta);
 | 
			
		||||
 | 
			
		||||
const routes = [
 | 
			
		||||
  {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								assets/manifest.webmanifest
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								assets/manifest.webmanifest
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "Dozzle Log Viewer",
 | 
			
		||||
  "short_name": "Dozzle",
 | 
			
		||||
  "theme_color": "#111111",
 | 
			
		||||
  "background_color": "#111111",
 | 
			
		||||
  "display": "standalone",
 | 
			
		||||
  "scope": "/",
 | 
			
		||||
  "start_url": "/"
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,20 @@
 | 
			
		||||
<template lang="html">
 | 
			
		||||
  <div class="is-fullheight">
 | 
			
		||||
    <ul ref="events" class="events">
 | 
			
		||||
      <li v-for="item in messages" class="event" :key="item.key">
 | 
			
		||||
        <span class="date">{{ item.dateRelative }}</span> <span class="text">{{ item.message }}</span>
 | 
			
		||||
    <div class="search columns is-gapless is-vcentered" v-show="showSearch">
 | 
			
		||||
      <div class="column">
 | 
			
		||||
        <p class="control has-icons-left">
 | 
			
		||||
          <input class="input" type="text" placeholder="Filter" ref="filter" v-model="filter" />
 | 
			
		||||
          <span class="icon is-small is-left"><i class="fas fa-search"></i></span>
 | 
			
		||||
        </p>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="column is-1 has-text-centered">
 | 
			
		||||
        <button class="delete is-medium" @click="resetSearch()"></button>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <ul class="events">
 | 
			
		||||
      <li v-for="item in filtered" class="event" :key="item.key">
 | 
			
		||||
        <span class="date">{{ item.dateRelative }}</span> <span class="text" v-html="item.message"></span>
 | 
			
		||||
      </li>
 | 
			
		||||
    </ul>
 | 
			
		||||
    <scrollbar-notification :messages="messages"></scrollbar-notification>
 | 
			
		||||
@@ -13,7 +25,7 @@
 | 
			
		||||
import { formatRelative } from "date-fns";
 | 
			
		||||
import ScrollbarNotification from "../components/ScrollbarNotification";
 | 
			
		||||
 | 
			
		||||
let ws = null;
 | 
			
		||||
let es = null;
 | 
			
		||||
let nextId = 0;
 | 
			
		||||
const parseMessage = data => {
 | 
			
		||||
  const date = new Date(data.substring(0, 30));
 | 
			
		||||
@@ -29,22 +41,39 @@ const parseMessage = data => {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  props: ["id"],
 | 
			
		||||
  props: ["id", "name"],
 | 
			
		||||
  name: "Container",
 | 
			
		||||
  components: {
 | 
			
		||||
    ScrollbarNotification
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      messages: []
 | 
			
		||||
      messages: [],
 | 
			
		||||
      showSearch: false,
 | 
			
		||||
      title: "",
 | 
			
		||||
      filter: ""
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  metaInfo() {
 | 
			
		||||
    return {
 | 
			
		||||
      title: this.title,
 | 
			
		||||
      titleTemplate: "%s - Dozzle"
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  mounted() {
 | 
			
		||||
    window.addEventListener("keydown", this.onKeyDown);
 | 
			
		||||
  },
 | 
			
		||||
  destroyed() {
 | 
			
		||||
    window.removeEventListener("keydown", this.onKeyDown);
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    this.loadLogs(this.id);
 | 
			
		||||
  },
 | 
			
		||||
  beforeDestroy() {
 | 
			
		||||
    ws.close();
 | 
			
		||||
    ws = null;
 | 
			
		||||
    if (es) {
 | 
			
		||||
      es.close();
 | 
			
		||||
      es = null;
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  watch: {
 | 
			
		||||
    id(newValue, oldValue) {
 | 
			
		||||
@@ -55,20 +84,45 @@ export default {
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    loadLogs(id) {
 | 
			
		||||
      if (ws) {
 | 
			
		||||
        ws.close();
 | 
			
		||||
        ws = null;
 | 
			
		||||
      if (es) {
 | 
			
		||||
        es.close();
 | 
			
		||||
        es = null;
 | 
			
		||||
        this.messages = [];
 | 
			
		||||
      }
 | 
			
		||||
      const protocol = SSL_ENABLED ? "wss" : "ws";
 | 
			
		||||
      ws = new WebSocket(`${protocol}://${window.location.host}${BASE_PATH}/api/logs?id=${this.id}`);
 | 
			
		||||
      ws.onopen = e => console.log("Connection opened.");
 | 
			
		||||
      ws.onclose = e => console.log("Connection closed.");
 | 
			
		||||
      ws.onerror = e => console.error("Connection error: " + e.data);
 | 
			
		||||
      ws.onmessage = e => {
 | 
			
		||||
        const message = parseMessage(e.data);
 | 
			
		||||
        this.messages.push(message);
 | 
			
		||||
      };
 | 
			
		||||
      es = new EventSource(`${BASE_PATH}/api/logs/stream?id=${id}`);
 | 
			
		||||
      es.onmessage = e => this.messages.push(parseMessage(e.data));
 | 
			
		||||
      this.title = `${this.name} - Dozzle`;
 | 
			
		||||
    },
 | 
			
		||||
    onKeyDown(e) {
 | 
			
		||||
      if ((e.metaKey || e.ctrlKey) && e.key === "f") {
 | 
			
		||||
        this.showSearch = true;
 | 
			
		||||
        this.$nextTick(() => this.$refs.filter.focus());
 | 
			
		||||
        e.preventDefault();
 | 
			
		||||
      } else if ((e.metaKey || e.ctrlKey) && e.key === "k") {
 | 
			
		||||
        this.messages = [];
 | 
			
		||||
      } else if (e.key === "Escape") {
 | 
			
		||||
        this.resetSearch();
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    resetSearch() {
 | 
			
		||||
      this.showSearch = false;
 | 
			
		||||
      this.filter = "";
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  computed: {
 | 
			
		||||
    filtered() {
 | 
			
		||||
      const { filter } = this;
 | 
			
		||||
      if (filter) {
 | 
			
		||||
        const isSmartCase = filter === filter.toLowerCase();
 | 
			
		||||
        const regex = isSmartCase ? new RegExp(filter, "i") : new RegExp(filter);
 | 
			
		||||
        return this.messages
 | 
			
		||||
          .filter(d => d.message.match(regex))
 | 
			
		||||
          .map(d => ({
 | 
			
		||||
            ...d,
 | 
			
		||||
            message: d.message.replace(regex, "<mark>$&</mark>")
 | 
			
		||||
          }));
 | 
			
		||||
      }
 | 
			
		||||
      return this.messages;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
@@ -93,4 +147,37 @@ export default {
 | 
			
		||||
.is-fullheight {
 | 
			
		||||
  min-height: 100vh;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.text {
 | 
			
		||||
  white-space: pre-wrap;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.search {
 | 
			
		||||
  width: 350px;
 | 
			
		||||
  position: fixed;
 | 
			
		||||
  padding: 10px;
 | 
			
		||||
  background: rgba(50, 50, 50, 0.9);
 | 
			
		||||
  top: 0;
 | 
			
		||||
  right: 0;
 | 
			
		||||
  border-radius: 0 0 0 5px;
 | 
			
		||||
}
 | 
			
		||||
.delete {
 | 
			
		||||
  margin-left: 1em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/deep/ mark {
 | 
			
		||||
  border-radius: 2px;
 | 
			
		||||
  background-color: #ffdd57;
 | 
			
		||||
  animation: pops 0.2s ease-out;
 | 
			
		||||
  display: inline-block;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@keyframes pops {
 | 
			
		||||
  0% {
 | 
			
		||||
    transform: scale(1.5);
 | 
			
		||||
  }
 | 
			
		||||
  100% {
 | 
			
		||||
    transform: scale(1.05);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@ $menu-item-active-background-color: hsl(171, 100%, 41%);
 | 
			
		||||
$menu-item-color: hsl(0, 6%, 87%);
 | 
			
		||||
 | 
			
		||||
@import "../node_modules/bulma/bulma.sass";
 | 
			
		||||
@import "../node_modules/bulma-tooltip/src/sass";
 | 
			
		||||
 | 
			
		||||
.is-dark {
 | 
			
		||||
    color: #ddd;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										126
									
								
								docker/client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								docker/client.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,126 @@
 | 
			
		||||
package docker
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/binary"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	"github.com/docker/docker/api/types/events"
 | 
			
		||||
	"github.com/docker/docker/client"
 | 
			
		||||
	"io"
 | 
			
		||||
	"log"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type dockerClient struct {
 | 
			
		||||
	cli dockerProxy
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type dockerProxy interface {
 | 
			
		||||
	ContainerList(context.Context, types.ContainerListOptions) ([]types.Container, error)
 | 
			
		||||
	ContainerLogs(context.Context, string, types.ContainerLogsOptions) (io.ReadCloser, error)
 | 
			
		||||
	Events(context.Context, types.EventsOptions) (<-chan events.Message, <-chan error)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Client is a proxy around the docker client
 | 
			
		||||
type Client interface {
 | 
			
		||||
	ListContainers() ([]Container, error)
 | 
			
		||||
	ContainerLogs(context.Context, string, int) (<-chan string, <-chan error)
 | 
			
		||||
	Events(context.Context) (<-chan events.Message, <-chan error)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewClient creates a new instance of Client
 | 
			
		||||
func NewClient() Client {
 | 
			
		||||
	cli, err := client.NewClientWithOpts(client.FromEnv)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	return &dockerClient{cli}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *dockerClient) ListContainers() ([]Container, error) {
 | 
			
		||||
	list, err := d.cli.ContainerList(context.Background(), types.ContainerListOptions{})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var containers []Container
 | 
			
		||||
	for _, c := range list {
 | 
			
		||||
 | 
			
		||||
		container := Container{
 | 
			
		||||
			ID:      c.ID[:12],
 | 
			
		||||
			Names:   c.Names,
 | 
			
		||||
			Name:    strings.TrimPrefix(c.Names[0], "/"),
 | 
			
		||||
			Image:   c.Image,
 | 
			
		||||
			ImageID: c.ImageID,
 | 
			
		||||
			Command: c.Command,
 | 
			
		||||
			Created: c.Created,
 | 
			
		||||
			State:   c.State,
 | 
			
		||||
			Status:  c.Status,
 | 
			
		||||
		}
 | 
			
		||||
		containers = append(containers, container)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	sort.Slice(containers, func(i, j int) bool {
 | 
			
		||||
		return containers[i].Name < containers[j].Name
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	if containers == nil {
 | 
			
		||||
		containers = []Container{}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return containers, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *dockerClient) ContainerLogs(ctx context.Context, id string, tailSize int) (<-chan string, <-chan error) {
 | 
			
		||||
	options := types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true, Follow: true, Tail: strconv.Itoa(tailSize), Timestamps: true}
 | 
			
		||||
	reader, err := d.cli.ContainerLogs(ctx, id, options)
 | 
			
		||||
	errChannel := make(chan error, 1)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		errChannel <- err
 | 
			
		||||
		close(errChannel)
 | 
			
		||||
		return nil, errChannel
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	messages := make(chan string)
 | 
			
		||||
	go func() {
 | 
			
		||||
		<-ctx.Done()
 | 
			
		||||
		reader.Close()
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		defer close(messages)
 | 
			
		||||
		defer close(errChannel)
 | 
			
		||||
		defer reader.Close()
 | 
			
		||||
 | 
			
		||||
		hdr := make([]byte, 8)
 | 
			
		||||
		var buffer bytes.Buffer
 | 
			
		||||
		for {
 | 
			
		||||
			_, err := reader.Read(hdr)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				errChannel <- err
 | 
			
		||||
				break
 | 
			
		||||
			}
 | 
			
		||||
			count := binary.BigEndian.Uint32(hdr[4:])
 | 
			
		||||
			_, err = io.CopyN(&buffer, reader, int64(count))
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				errChannel <- err
 | 
			
		||||
				break
 | 
			
		||||
			}
 | 
			
		||||
			select {
 | 
			
		||||
			case messages <- buffer.String():
 | 
			
		||||
			case <-ctx.Done():
 | 
			
		||||
			}
 | 
			
		||||
			buffer.Reset()
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	return messages, errChannel
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *dockerClient) Events(ctx context.Context) (<-chan events.Message, <-chan error) {
 | 
			
		||||
	return d.cli.Events(ctx, types.EventsOptions{})
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										143
									
								
								docker/client_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										143
									
								
								docker/client_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,143 @@
 | 
			
		||||
package docker
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/binary"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"github.com/stretchr/testify/mock"
 | 
			
		||||
	"github.com/stretchr/testify/require"
 | 
			
		||||
	"io"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type mockedProxy struct {
 | 
			
		||||
	mock.Mock
 | 
			
		||||
	dockerProxy
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *mockedProxy) ContainerList(context.Context, types.ContainerListOptions) ([]types.Container, error) {
 | 
			
		||||
	args := m.Called()
 | 
			
		||||
	containers, ok := args.Get(0).([]types.Container)
 | 
			
		||||
	if !ok && args.Get(0) != nil {
 | 
			
		||||
		panic("containers is not of type []types.Container")
 | 
			
		||||
	}
 | 
			
		||||
	return containers, args.Error(1)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *mockedProxy) ContainerLogs(ctx context.Context, id string, options types.ContainerLogsOptions) (io.ReadCloser, error) {
 | 
			
		||||
	args := m.Called(ctx, id, options)
 | 
			
		||||
	reader, ok := args.Get(0).(io.ReadCloser)
 | 
			
		||||
	if !ok && args.Get(0) != nil {
 | 
			
		||||
		panic("reader is not of type io.ReadCloser")
 | 
			
		||||
	}
 | 
			
		||||
	return reader, args.Error(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_dockerClient_ListContainers_null(t *testing.T) {
 | 
			
		||||
	proxy := new(mockedProxy)
 | 
			
		||||
	proxy.On("ContainerList", mock.Anything, mock.Anything).Return(nil, nil)
 | 
			
		||||
	client := &dockerClient{proxy}
 | 
			
		||||
 | 
			
		||||
	list, err := client.ListContainers()
 | 
			
		||||
	assert.Empty(t, list, "list should be empty")
 | 
			
		||||
	require.NoError(t, err, "error should not return an error.")
 | 
			
		||||
 | 
			
		||||
	proxy.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_dockerClient_ListContainers_error(t *testing.T) {
 | 
			
		||||
	proxy := new(mockedProxy)
 | 
			
		||||
	proxy.On("ContainerList", mock.Anything, mock.Anything).Return(nil, errors.New("test"))
 | 
			
		||||
	client := &dockerClient{proxy}
 | 
			
		||||
 | 
			
		||||
	list, err := client.ListContainers()
 | 
			
		||||
	assert.Nil(t, list, "list should be nil")
 | 
			
		||||
	require.Error(t, err, "test.")
 | 
			
		||||
 | 
			
		||||
	proxy.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_dockerClient_ListContainers_happy(t *testing.T) {
 | 
			
		||||
	containers := []types.Container{
 | 
			
		||||
		{
 | 
			
		||||
			ID:    "abcdefghijklmnopqrst",
 | 
			
		||||
			Names: []string{"/z_test_container"},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			ID:    "1234567890_abcxyzdef",
 | 
			
		||||
			Names: []string{"/a_test_container"},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	proxy := new(mockedProxy)
 | 
			
		||||
	proxy.On("ContainerList", mock.Anything, mock.Anything).Return(containers, nil)
 | 
			
		||||
	client := &dockerClient{proxy}
 | 
			
		||||
 | 
			
		||||
	list, err := client.ListContainers()
 | 
			
		||||
	require.NoError(t, err, "error should not return an error.")
 | 
			
		||||
 | 
			
		||||
	assert.Equal(t, list, []Container{
 | 
			
		||||
		{
 | 
			
		||||
			ID:    "1234567890_a",
 | 
			
		||||
			Name:  "a_test_container",
 | 
			
		||||
			Names: []string{"/a_test_container"},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			ID:    "abcdefghijkl",
 | 
			
		||||
			Name:  "z_test_container",
 | 
			
		||||
			Names: []string{"/z_test_container"},
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	proxy.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_dockerClient_ContainerLogs_happy(t *testing.T) {
 | 
			
		||||
	id := "123456"
 | 
			
		||||
 | 
			
		||||
	proxy := new(mockedProxy)
 | 
			
		||||
	expected := "INFO Testing logs..."
 | 
			
		||||
	b := make([]byte, 8)
 | 
			
		||||
 | 
			
		||||
	binary.BigEndian.PutUint32(b[4:], uint32(len(expected)))
 | 
			
		||||
	b = append(b, []byte(expected)...)
 | 
			
		||||
 | 
			
		||||
	var reader io.ReadCloser
 | 
			
		||||
	reader = ioutil.NopCloser(bytes.NewReader(b))
 | 
			
		||||
	options := types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true, Follow: true, Tail: "300", Timestamps: true}
 | 
			
		||||
	proxy.On("ContainerLogs", mock.Anything, id, options).Return(reader, nil)
 | 
			
		||||
 | 
			
		||||
	client := &dockerClient{proxy}
 | 
			
		||||
	messages, _ := client.ContainerLogs(context.Background(), id, 300)
 | 
			
		||||
 | 
			
		||||
	actual, _ := <-messages
 | 
			
		||||
	assert.Equal(t, expected, actual, "message doesn't match expected")
 | 
			
		||||
 | 
			
		||||
	_, ok := <-messages
 | 
			
		||||
	assert.False(t, ok, "channel should have been closed")
 | 
			
		||||
	proxy.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_dockerClient_ContainerLogs_error(t *testing.T) {
 | 
			
		||||
	id := "123456"
 | 
			
		||||
	proxy := new(mockedProxy)
 | 
			
		||||
 | 
			
		||||
	proxy.On("ContainerLogs", mock.Anything, id, mock.Anything).Return(nil, errors.New("test"))
 | 
			
		||||
 | 
			
		||||
	client := &dockerClient{proxy}
 | 
			
		||||
 | 
			
		||||
	messages, err := client.ContainerLogs(context.Background(), id, 300)
 | 
			
		||||
 | 
			
		||||
	assert.Nil(t, messages, "messages should be nil")
 | 
			
		||||
 | 
			
		||||
	e, _ := <-err
 | 
			
		||||
	assert.Error(t, e, "error should have been returned")
 | 
			
		||||
	_, ok := <-err
 | 
			
		||||
	assert.False(t, ok, "error channel should have been closed")
 | 
			
		||||
	proxy.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								docker/types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								docker/types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
package docker
 | 
			
		||||
 | 
			
		||||
// Container represents an internal representation of docker containers
 | 
			
		||||
type Container struct {
 | 
			
		||||
	ID      string   `json:"id"`
 | 
			
		||||
	Names   []string `json:"names"`
 | 
			
		||||
	Name    string   `json:"name"`
 | 
			
		||||
	Image   string   `json:"image"`
 | 
			
		||||
	ImageID string   `json:"imageId"`
 | 
			
		||||
	Command string   `json:"command"`
 | 
			
		||||
	Created int64    `json:"created"`
 | 
			
		||||
	State   string   `json:"state"`
 | 
			
		||||
	Status  string   `json:"status"`
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										44
									
								
								go.mod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								go.mod
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
module github.com/amir20/dozzle
 | 
			
		||||
 | 
			
		||||
replace github.com/docker/docker v0.0.0-20170601211448-f5ec1e2936dc => github.com/docker/engine v0.0.0-20180718150940-a3ef7e9a9bda
 | 
			
		||||
 | 
			
		||||
// github.com/docker/engine v18.06.1-ce
 | 
			
		||||
replace github.com/docker/docker => github.com/docker/engine v0.0.0-20180816081446-320063a2ad06
 | 
			
		||||
 | 
			
		||||
// github.com/docker/distribution master
 | 
			
		||||
// a proper tagged release is expected in early fall(September 2018)
 | 
			
		||||
// see; https://github.com/docker/distribution/issues/2693
 | 
			
		||||
replace github.com/docker/distribution => github.com/docker/distribution v2.6.0-rc.1.0.20180820212402-02bf4a2887a4+incompatible
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
 | 
			
		||||
	github.com/Microsoft/go-winio v0.4.12 // indirect
 | 
			
		||||
	github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
 | 
			
		||||
	github.com/beme/abide v0.0.0-20181227202223-4c487ef9d895
 | 
			
		||||
	github.com/docker/distribution v2.7.1+incompatible // indirect
 | 
			
		||||
	github.com/docker/docker v0.0.0-20170601211448-f5ec1e2936dc
 | 
			
		||||
	github.com/docker/go-connections v0.4.0 // indirect
 | 
			
		||||
	github.com/docker/go-units v0.4.0 // indirect
 | 
			
		||||
	github.com/gobuffalo/packd v0.1.0 // indirect
 | 
			
		||||
	github.com/gobuffalo/packr v1.25.0
 | 
			
		||||
	github.com/gogo/protobuf v1.2.1 // indirect
 | 
			
		||||
	github.com/google/go-cmp v0.3.0 // indirect
 | 
			
		||||
	github.com/gorilla/mux v1.7.1
 | 
			
		||||
	github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
 | 
			
		||||
	github.com/magiconair/properties v1.8.1
 | 
			
		||||
	github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
 | 
			
		||||
	github.com/opencontainers/image-spec v1.0.1 // indirect
 | 
			
		||||
	github.com/sergi/go-diff v1.0.0 // indirect
 | 
			
		||||
	github.com/sirupsen/logrus v1.4.1
 | 
			
		||||
	github.com/spf13/pflag v1.0.3
 | 
			
		||||
	github.com/spf13/viper v1.3.2
 | 
			
		||||
	github.com/stretchr/objx v0.2.0 // indirect
 | 
			
		||||
	github.com/stretchr/testify v1.3.0
 | 
			
		||||
	golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect
 | 
			
		||||
	golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
 | 
			
		||||
	golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 // indirect
 | 
			
		||||
	golang.org/x/text v0.3.2 // indirect
 | 
			
		||||
	golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
 | 
			
		||||
	google.golang.org/grpc v1.20.1 // indirect
 | 
			
		||||
	gotest.tools v2.2.0+incompatible // indirect
 | 
			
		||||
)
 | 
			
		||||
							
								
								
									
										167
									
								
								go.sum
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										167
									
								
								go.sum
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,167 @@
 | 
			
		||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 | 
			
		||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
 | 
			
		||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
 | 
			
		||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 | 
			
		||||
github.com/Microsoft/go-winio v0.4.12 h1:xAfWHN1IrQ0NJ9TBC0KBZoqLjzDTr1ML+4MywiUOryc=
 | 
			
		||||
github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
 | 
			
		||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
 | 
			
		||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
 | 
			
		||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
 | 
			
		||||
github.com/beme/abide v0.0.0-20181227202223-4c487ef9d895 h1:gKYojZRR5Nko2XJrcAEiQpBQbir/wzsNqGqtOjKJU6g=
 | 
			
		||||
github.com/beme/abide v0.0.0-20181227202223-4c487ef9d895/go.mod h1:6+8gCKsZnxzhGTmKRh4BSkLos9CbWRJNcrp55We4SqQ=
 | 
			
		||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
 | 
			
		||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 | 
			
		||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
 | 
			
		||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
github.com/docker/distribution v2.6.0-rc.1.0.20180820212402-02bf4a2887a4+incompatible h1:x3ZXVm6ovZmIA+s9MEdSXjdyd5Zbd5VPBcda2KrSuWk=
 | 
			
		||||
github.com/docker/distribution v2.6.0-rc.1.0.20180820212402-02bf4a2887a4+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
 | 
			
		||||
github.com/docker/engine v0.0.0-20180816081446-320063a2ad06 h1:CcxlLWAS/9b46iqHDTBlALJZF9atXVNjeymdCNrUfnY=
 | 
			
		||||
github.com/docker/engine v0.0.0-20180816081446-320063a2ad06/go.mod h1:3CPr2caMgTHxxIAZgEMd3uLYPDlRvPqCpyeRf6ncPcY=
 | 
			
		||||
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
 | 
			
		||||
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
 | 
			
		||||
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
 | 
			
		||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
 | 
			
		||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
 | 
			
		||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 | 
			
		||||
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
 | 
			
		||||
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
 | 
			
		||||
github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
 | 
			
		||||
github.com/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU=
 | 
			
		||||
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
 | 
			
		||||
github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs=
 | 
			
		||||
github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
 | 
			
		||||
github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk=
 | 
			
		||||
github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28=
 | 
			
		||||
github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw=
 | 
			
		||||
github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360=
 | 
			
		||||
github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8=
 | 
			
		||||
github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
 | 
			
		||||
github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
 | 
			
		||||
github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0 h1:P6naWPiHm/7R3eYx/ub3VhaW9G+1xAMJ6vzACePaGPI=
 | 
			
		||||
github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
 | 
			
		||||
github.com/gobuffalo/packd v0.1.0 h1:4sGKOD8yaYJ+dek1FDkwcxCHA40M4kfKgFHx8N2kwbU=
 | 
			
		||||
github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
 | 
			
		||||
github.com/gobuffalo/packr v1.25.0 h1:NtPK45yOKFdTKHTvRGKL+UIKAKmJVWIVJOZBDI/qEdY=
 | 
			
		||||
github.com/gobuffalo/packr v1.25.0/go.mod h1:NqsGg8CSB2ZD+6RBIRs18G7aZqdYDlYNNvsSqP6T4/U=
 | 
			
		||||
github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
 | 
			
		||||
github.com/gobuffalo/packr/v2 v2.1.0/go.mod h1:n90ZuXIc2KN2vFAOQascnPItp9A2g9QYSvYvS3AjQEM=
 | 
			
		||||
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754 h1:tpom+2CJmpzAWj5/VEHync2rJGi+epHNIeRSWjzGA+4=
 | 
			
		||||
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
 | 
			
		||||
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
 | 
			
		||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
 | 
			
		||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
 | 
			
		||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
 | 
			
		||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 | 
			
		||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
 | 
			
		||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 | 
			
		||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
 | 
			
		||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 | 
			
		||||
github.com/gorilla/mux v1.7.1 h1:Dw4jY2nghMMRsh1ol8dv1axHkDwMQK2DHerMNJsIpJU=
 | 
			
		||||
github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
 | 
			
		||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
 | 
			
		||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
 | 
			
		||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
 | 
			
		||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
 | 
			
		||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
 | 
			
		||||
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
 | 
			
		||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
 | 
			
		||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
 | 
			
		||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 | 
			
		||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
 | 
			
		||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 | 
			
		||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 | 
			
		||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 | 
			
		||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 | 
			
		||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
 | 
			
		||||
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
 | 
			
		||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
 | 
			
		||||
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
 | 
			
		||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
 | 
			
		||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
 | 
			
		||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 | 
			
		||||
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
 | 
			
		||||
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
 | 
			
		||||
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
 | 
			
		||||
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
 | 
			
		||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
 | 
			
		||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
 | 
			
		||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
			
		||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
 | 
			
		||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
			
		||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 | 
			
		||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 | 
			
		||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
 | 
			
		||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
 | 
			
		||||
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 | 
			
		||||
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
 | 
			
		||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
 | 
			
		||||
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
 | 
			
		||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
 | 
			
		||||
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
 | 
			
		||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 | 
			
		||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
 | 
			
		||||
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
 | 
			
		||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
 | 
			
		||||
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
 | 
			
		||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 | 
			
		||||
github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
 | 
			
		||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
 | 
			
		||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
			
		||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
			
		||||
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
 | 
			
		||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
 | 
			
		||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 | 
			
		||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
 | 
			
		||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 | 
			
		||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
 | 
			
		||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 | 
			
		||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
 | 
			
		||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
 | 
			
		||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 | 
			
		||||
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 h1:6M3SDHlHHDCx2PcQw3S4KsR170vGqDhJDOmpVd4Hjak=
 | 
			
		||||
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 | 
			
		||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 | 
			
		||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
 | 
			
		||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
 | 
			
		||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 h1:rM0ROo5vb9AdYJi1110yjWGMej9ITfKddS89P3Fkhug=
 | 
			
		||||
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
			
		||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
			
		||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
 | 
			
		||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
 | 
			
		||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
 | 
			
		||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
			
		||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
			
		||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
			
		||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 | 
			
		||||
golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 | 
			
		||||
golang.org/x/tools v0.0.0-20190404132500-923d25813098/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 | 
			
		||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
 | 
			
		||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
 | 
			
		||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
 | 
			
		||||
google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU=
 | 
			
		||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
 | 
			
		||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
			
		||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
			
		||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
 | 
			
		||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
 | 
			
		||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
			
		||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
 | 
			
		||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
 | 
			
		||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 | 
			
		||||
							
								
								
									
										326
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										326
									
								
								main.go
									
									
									
									
									
								
							@@ -1,146 +1,236 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
    "context"
 | 
			
		||||
    "encoding/binary"
 | 
			
		||||
    "encoding/json"
 | 
			
		||||
    "fmt"
 | 
			
		||||
    "html/template"
 | 
			
		||||
    "log"
 | 
			
		||||
    "net/http"
 | 
			
		||||
    "os"
 | 
			
		||||
    "strings"
 | 
			
		||||
 | 
			
		||||
    "github.com/docker/docker/api/types"
 | 
			
		||||
    "github.com/docker/docker/client"
 | 
			
		||||
    "github.com/gobuffalo/packr"
 | 
			
		||||
    "github.com/gorilla/mux"
 | 
			
		||||
    "github.com/gorilla/websocket"
 | 
			
		||||
    flag "github.com/spf13/pflag"
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/amir20/dozzle/docker"
 | 
			
		||||
	"github.com/gobuffalo/packr"
 | 
			
		||||
	"github.com/gorilla/mux"
 | 
			
		||||
	log "github.com/sirupsen/logrus"
 | 
			
		||||
	"github.com/spf13/pflag"
 | 
			
		||||
	"github.com/spf13/viper"
 | 
			
		||||
	"html/template"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
	"os/signal"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
    cli      *client.Client
 | 
			
		||||
    addr     = ""
 | 
			
		||||
    ssl      = false
 | 
			
		||||
    base     = "/"
 | 
			
		||||
    upgrader = websocket.Upgrader{}
 | 
			
		||||
    version  = "dev"
 | 
			
		||||
    commit   = "none"
 | 
			
		||||
    date     = "unknown"
 | 
			
		||||
	addr    = ""
 | 
			
		||||
	base    = ""
 | 
			
		||||
	level   = ""
 | 
			
		||||
	tailSize = 300
 | 
			
		||||
	version = "dev"
 | 
			
		||||
	commit  = "none"
 | 
			
		||||
	date    = "unknown"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
    flag.StringVar(&addr, "addr", ":8080", "http service address")
 | 
			
		||||
    flag.StringVar(&base, "base", "/", "base address of the application to mount")
 | 
			
		||||
    flag.BoolVarP(&ssl, "ssl", "s", false, "Uses websockets over ssl if enabled")
 | 
			
		||||
type handler struct {
 | 
			
		||||
	client docker.Client
 | 
			
		||||
	box    packr.Box
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    var err error
 | 
			
		||||
    cli, err = client.NewClientWithOpts(client.FromEnv)
 | 
			
		||||
    if err != nil {
 | 
			
		||||
        log.Fatal(err)
 | 
			
		||||
    }
 | 
			
		||||
    flag.Parse()
 | 
			
		||||
func init() {
 | 
			
		||||
	pflag.String("addr", ":8080", "http service address")
 | 
			
		||||
	pflag.String("base", "/", "base address of the application to mount")
 | 
			
		||||
	pflag.String("level", "info", "logging level")
 | 
			
		||||
	pflag.Int("tailSize", 300, "Tail size to use for initial container logs")
 | 
			
		||||
	pflag.Parse()
 | 
			
		||||
 | 
			
		||||
	viper.AutomaticEnv()
 | 
			
		||||
	viper.SetEnvPrefix("DOZZLE")
 | 
			
		||||
	viper.BindPFlags(pflag.CommandLine)
 | 
			
		||||
 | 
			
		||||
	addr = viper.GetString("addr")
 | 
			
		||||
	base = viper.GetString("base")
 | 
			
		||||
	level = viper.GetString("level")
 | 
			
		||||
	tailSize = viper.GetInt("tailSize")
 | 
			
		||||
 | 
			
		||||
	l, _ := log.ParseLevel(level)
 | 
			
		||||
	log.SetLevel(l)
 | 
			
		||||
 | 
			
		||||
	log.SetFormatter(&log.TextFormatter{
 | 
			
		||||
		DisableTimestamp:       true,
 | 
			
		||||
		DisableLevelTruncation: true,
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func createRoutes(base string, h *handler) *mux.Router {
 | 
			
		||||
	r := mux.NewRouter()
 | 
			
		||||
	if base != "/" {
 | 
			
		||||
		r.HandleFunc(base, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
 | 
			
		||||
			http.Redirect(w, req, base+"/", http.StatusMovedPermanently)
 | 
			
		||||
		}))
 | 
			
		||||
	}
 | 
			
		||||
	s := r.PathPrefix(base).Subrouter()
 | 
			
		||||
	s.HandleFunc("/api/containers.json", h.listContainers)
 | 
			
		||||
	s.HandleFunc("/api/logs/stream", h.streamLogs)
 | 
			
		||||
	s.HandleFunc("/api/events/stream", h.streamEvents)
 | 
			
		||||
	s.HandleFunc("/version", h.version)
 | 
			
		||||
	s.PathPrefix("/").Handler(http.StripPrefix(base, http.HandlerFunc(h.index)))
 | 
			
		||||
	return r
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
    r := mux.NewRouter()
 | 
			
		||||
	log.Infof("Dozzle version %s", version)
 | 
			
		||||
	dockerClient := docker.NewClient()
 | 
			
		||||
	_, err := dockerClient.ListContainers()
 | 
			
		||||
 | 
			
		||||
    if base != "/" {
 | 
			
		||||
        r.HandleFunc(base, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
 | 
			
		||||
            http.Redirect(w, req, base+"/", http.StatusMovedPermanently)
 | 
			
		||||
        }))
 | 
			
		||||
    }
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatalf("Could not connect to Docker Engine: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    s := r.PathPrefix(base).Subrouter()
 | 
			
		||||
    box := packr.NewBox("./static")
 | 
			
		||||
	box := packr.NewBox("./static")
 | 
			
		||||
	r := createRoutes(base, &handler{dockerClient, box})
 | 
			
		||||
	srv := &http.Server{Addr: addr, Handler: r}
 | 
			
		||||
 | 
			
		||||
    s.HandleFunc("/api/containers.json", listContainers)
 | 
			
		||||
    s.HandleFunc("/api/logs", logs)
 | 
			
		||||
    s.HandleFunc("/version", versionHandler)
 | 
			
		||||
    s.PathPrefix("/").Handler(http.StripPrefix(base, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
 | 
			
		||||
        fileServer := http.FileServer(box)
 | 
			
		||||
        if box.Has(req.URL.Path) && req.URL.Path != "" && req.URL.Path != "/" {
 | 
			
		||||
            fileServer.ServeHTTP(w, req)
 | 
			
		||||
        } else {
 | 
			
		||||
            handleIndex(box, w)
 | 
			
		||||
        }
 | 
			
		||||
    })))
 | 
			
		||||
	go func() {
 | 
			
		||||
		log.Infof("Accepting connections on %s", srv.Addr)
 | 
			
		||||
		if err := srv.ListenAndServe(); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
    log.Fatal(http.ListenAndServe(addr, r))
 | 
			
		||||
	c := make(chan os.Signal, 1)
 | 
			
		||||
	signal.Notify(c, os.Interrupt)
 | 
			
		||||
	signal.Notify(c, os.Kill)
 | 
			
		||||
	<-c
 | 
			
		||||
	log.Infof("Shutting down...")
 | 
			
		||||
	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
 | 
			
		||||
	defer cancel()
 | 
			
		||||
	srv.Shutdown(ctx)
 | 
			
		||||
	os.Exit(0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func versionHandler(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
    fmt.Fprintln(w, version)
 | 
			
		||||
    fmt.Fprintln(w, commit)
 | 
			
		||||
    fmt.Fprintln(w, date)
 | 
			
		||||
func (h *handler) index(w http.ResponseWriter, req *http.Request) {
 | 
			
		||||
	fileServer := http.FileServer(h.box)
 | 
			
		||||
	if h.box.Has(req.URL.Path) && req.URL.Path != "" && req.URL.Path != "/" {
 | 
			
		||||
		fileServer.ServeHTTP(w, req)
 | 
			
		||||
	} else {
 | 
			
		||||
		text, _ := h.box.FindString("index.html")
 | 
			
		||||
		text = strings.Replace(text, "__BASE__", "{{ .Base }}", -1)
 | 
			
		||||
		tmpl, err := template.New("index.html").Parse(text)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			panic(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		path := ""
 | 
			
		||||
		if base != "/" {
 | 
			
		||||
			path = base
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		data := struct{ Base string }{path}
 | 
			
		||||
		err = tmpl.Execute(w, data)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func listContainers(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
    containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
 | 
			
		||||
    if err != nil {
 | 
			
		||||
        log.Fatal(err)
 | 
			
		||||
    }
 | 
			
		||||
    json.NewEncoder(w).Encode(containers)
 | 
			
		||||
func (h *handler) listContainers(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	containers, err := h.client.ListContainers()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	err = json.NewEncoder(w).Encode(containers)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func handleIndex(box packr.Box, w http.ResponseWriter) {
 | 
			
		||||
    text, _ := box.FindString("index.html")
 | 
			
		||||
    text = strings.Replace(text, "__BASE__", "{{ .Base }}", -1)
 | 
			
		||||
    tmpl, err := template.New("index.html").Parse(text)
 | 
			
		||||
    if err != nil {
 | 
			
		||||
        panic(err)
 | 
			
		||||
    }
 | 
			
		||||
func (h *handler) streamLogs(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	id := r.URL.Query().Get("id")
 | 
			
		||||
	if id == "" {
 | 
			
		||||
		http.Error(w, "id is required", http.StatusBadRequest)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    path := ""
 | 
			
		||||
    if base != "/" {
 | 
			
		||||
        path = base
 | 
			
		||||
    }
 | 
			
		||||
    hostname, _ := os.Hostname()
 | 
			
		||||
    data := struct {
 | 
			
		||||
        Base     string
 | 
			
		||||
        SSL      bool
 | 
			
		||||
        Hostname string
 | 
			
		||||
    }{path, ssl, hostname}
 | 
			
		||||
    err = tmpl.Execute(w, data)
 | 
			
		||||
    if err != nil {
 | 
			
		||||
        panic(err)
 | 
			
		||||
    }
 | 
			
		||||
	f, ok := w.(http.Flusher)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		http.Error(w, "Streaming unsupported!", http.StatusInternalServerError)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	messages, err := h.client.ContainerLogs(r.Context(), id, tailSize)
 | 
			
		||||
 | 
			
		||||
	w.Header().Set("Content-Type", "text/event-stream")
 | 
			
		||||
	w.Header().Set("Cache-Control", "no-cache")
 | 
			
		||||
	w.Header().Set("Connection", "keep-alive")
 | 
			
		||||
	w.Header().Set("Transfer-Encoding", "chunked")
 | 
			
		||||
 | 
			
		||||
	log.Debugf("Starting to stream logs for %s", id)
 | 
			
		||||
Loop:
 | 
			
		||||
	for {
 | 
			
		||||
		select {
 | 
			
		||||
		case message, ok := <-messages:
 | 
			
		||||
			if !ok {
 | 
			
		||||
				break Loop
 | 
			
		||||
			}
 | 
			
		||||
			_, e := fmt.Fprintf(w, "data: %s\n\n", message)
 | 
			
		||||
			if e != nil {
 | 
			
		||||
				log.Debugf("Error while writing to log stream: %v", e)
 | 
			
		||||
				break Loop
 | 
			
		||||
			}
 | 
			
		||||
			f.Flush()
 | 
			
		||||
		case e := <-err:
 | 
			
		||||
			log.Debugf("Error while reading from log stream: %v", e)
 | 
			
		||||
			break Loop
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.WithField("NumGoroutine", runtime.NumGoroutine()).Debug("runtime stats")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func logs(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
    id := r.URL.Query().Get("id")
 | 
			
		||||
    c, err := upgrader.Upgrade(w, r, nil)
 | 
			
		||||
    if err != nil {
 | 
			
		||||
        log.Fatal(err)
 | 
			
		||||
        return
 | 
			
		||||
    }
 | 
			
		||||
    defer c.Close()
 | 
			
		||||
func (h *handler) streamEvents(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	f, ok := w.(http.Flusher)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		http.Error(w, "Streaming unsupported!", http.StatusInternalServerError)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    options := types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true, Follow: true, Tail: "300", Timestamps: true}
 | 
			
		||||
    reader, err := cli.ContainerLogs(context.Background(), id, options)
 | 
			
		||||
    defer reader.Close()
 | 
			
		||||
    if err != nil {
 | 
			
		||||
        log.Fatal(err)
 | 
			
		||||
    }
 | 
			
		||||
	w.Header().Set("Content-Type", "text/event-stream")
 | 
			
		||||
	w.Header().Set("Cache-Control", "no-cache")
 | 
			
		||||
	w.Header().Set("Connection", "keep-alive")
 | 
			
		||||
	w.Header().Set("Transfer-Encoding", "chunked")
 | 
			
		||||
 | 
			
		||||
    hdr := make([]byte, 8)
 | 
			
		||||
    content := make([]byte, 1024, 1024*1024)
 | 
			
		||||
    for {
 | 
			
		||||
        _, err := reader.Read(hdr)
 | 
			
		||||
        if err != nil {
 | 
			
		||||
            log.Panicln(err)
 | 
			
		||||
        }
 | 
			
		||||
        count := binary.BigEndian.Uint32(hdr[4:])
 | 
			
		||||
        n, err := reader.Read(content[:count])
 | 
			
		||||
        if err != nil {
 | 
			
		||||
            log.Println(err)
 | 
			
		||||
            break
 | 
			
		||||
        }
 | 
			
		||||
        err = c.WriteMessage(websocket.TextMessage, content[:n])
 | 
			
		||||
        if err != nil {
 | 
			
		||||
            log.Println(err)
 | 
			
		||||
            break
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
	ctx := r.Context()
 | 
			
		||||
	messages, err := h.client.Events(ctx)
 | 
			
		||||
 | 
			
		||||
Loop:
 | 
			
		||||
	for {
 | 
			
		||||
		select {
 | 
			
		||||
		case message, ok := <-messages:
 | 
			
		||||
			if !ok {
 | 
			
		||||
				break Loop
 | 
			
		||||
			}
 | 
			
		||||
			switch message.Action {
 | 
			
		||||
			case "connect", "disconnect", "create", "destroy", "start", "stop":
 | 
			
		||||
				log.Debugf("Triggering docker event: %v", message.Action)
 | 
			
		||||
				_, err := fmt.Fprintf(w, "event: containers-changed\ndata: %s\n\n", message.Action)
 | 
			
		||||
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Debugf("Error while writing to event stream: %v", err)
 | 
			
		||||
					break
 | 
			
		||||
				}
 | 
			
		||||
				f.Flush()
 | 
			
		||||
			default:
 | 
			
		||||
				log.Debugf("Ignoring docker event: %v", message.Action)
 | 
			
		||||
			}
 | 
			
		||||
		case <-ctx.Done():
 | 
			
		||||
			break Loop
 | 
			
		||||
		case <-err:
 | 
			
		||||
			break Loop
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (h *handler) version(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	fmt.Fprintln(w, version)
 | 
			
		||||
	fmt.Fprintln(w, commit)
 | 
			
		||||
	fmt.Fprintln(w, date)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										287
									
								
								main_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										287
									
								
								main_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,287 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/magiconair/properties/assert"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
	"os"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/amir20/dozzle/docker"
 | 
			
		||||
	"github.com/beme/abide"
 | 
			
		||||
	"github.com/docker/docker/api/types/events"
 | 
			
		||||
	"github.com/gobuffalo/packr"
 | 
			
		||||
	"github.com/stretchr/testify/mock"
 | 
			
		||||
	"github.com/stretchr/testify/require"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type MockedClient struct {
 | 
			
		||||
	mock.Mock
 | 
			
		||||
	docker.Client
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *MockedClient) ListContainers() ([]docker.Container, error) {
 | 
			
		||||
	args := m.Called()
 | 
			
		||||
	containers, ok := args.Get(0).([]docker.Container)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		panic("containers is not of type []docker.Container")
 | 
			
		||||
	}
 | 
			
		||||
	return containers, args.Error(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *MockedClient) ContainerLogs(ctx context.Context, id string, tailSize int) (<-chan string, <-chan error) {
 | 
			
		||||
	args := m.Called(ctx, id, tailSize)
 | 
			
		||||
	channel, ok := args.Get(0).(chan string)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		panic("channel is not of type chan string")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err, ok := args.Get(1).(chan error)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		panic("error is not of type chan error")
 | 
			
		||||
	}
 | 
			
		||||
	return channel, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *MockedClient) Events(ctx context.Context) (<-chan events.Message, <-chan error) {
 | 
			
		||||
	args := m.Called(ctx)
 | 
			
		||||
	channel, ok := args.Get(0).(chan events.Message)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		panic("channel is not of type chan events.Message")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err, ok := args.Get(1).(chan error)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		panic("error is not of type chan error")
 | 
			
		||||
	}
 | 
			
		||||
	return channel, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_handler_listContainers_happy(t *testing.T) {
 | 
			
		||||
	req, err := http.NewRequest("GET", "/api/containers.json", nil)
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
	containers := []docker.Container{
 | 
			
		||||
		{
 | 
			
		||||
			ID:      "1234567890",
 | 
			
		||||
			Status:  "status",
 | 
			
		||||
			State:   "state",
 | 
			
		||||
			Name:    "test",
 | 
			
		||||
			Created: 0,
 | 
			
		||||
			Command: "command",
 | 
			
		||||
			ImageID: "image_id",
 | 
			
		||||
			Image:   "image",
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	mockedClient.On("ListContainers", mock.Anything).Return(containers, nil)
 | 
			
		||||
 | 
			
		||||
	h := handler{client: mockedClient}
 | 
			
		||||
	handler := http.HandlerFunc(h.listContainers)
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
	mockedClient.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_handler_streamLogs_happy(t *testing.T) {
 | 
			
		||||
	id := "123456"
 | 
			
		||||
	req, err := http.NewRequest("GET", "/api/logs/stream", nil)
 | 
			
		||||
	q := req.URL.Query()
 | 
			
		||||
	q.Add("id", id)
 | 
			
		||||
	req.URL.RawQuery = q.Encode()
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
 | 
			
		||||
	messages := make(chan string)
 | 
			
		||||
	errChannel := make(chan error)
 | 
			
		||||
	mockedClient.On("ContainerLogs", mock.Anything, id, 300).Return(messages, errChannel)
 | 
			
		||||
	go func() {
 | 
			
		||||
		messages <- "INFO Testing logs..."
 | 
			
		||||
		close(messages)
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	h := handler{client: mockedClient}
 | 
			
		||||
	handler := http.HandlerFunc(h.streamLogs)
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
	mockedClient.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_handler_streamLogs_error_reading(t *testing.T) {
 | 
			
		||||
	id := "123456"
 | 
			
		||||
	req, err := http.NewRequest("GET", "/api/logs/stream", nil)
 | 
			
		||||
	q := req.URL.Query()
 | 
			
		||||
	q.Add("id", "123456")
 | 
			
		||||
	req.URL.RawQuery = q.Encode()
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
	messages := make(chan string)
 | 
			
		||||
	errChannel := make(chan error)
 | 
			
		||||
	mockedClient.On("ContainerLogs", mock.Anything, id, 300).Return(messages, errChannel)
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		errChannel <- errors.New("test error")
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	h := handler{client: mockedClient}
 | 
			
		||||
	handler := http.HandlerFunc(h.streamLogs)
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
	mockedClient.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_handler_streamEvents_happy(t *testing.T) {
 | 
			
		||||
	req, err := http.NewRequest("GET", "/api/events/stream", nil)
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
	messages := make(chan events.Message)
 | 
			
		||||
	errChannel := make(chan error)
 | 
			
		||||
	mockedClient.On("Events", mock.Anything).Return(messages, errChannel)
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		messages <- events.Message{
 | 
			
		||||
			Action: "start",
 | 
			
		||||
		}
 | 
			
		||||
		messages <- events.Message{
 | 
			
		||||
			Action: "something-random",
 | 
			
		||||
		}
 | 
			
		||||
		close(messages)
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	h := handler{client: mockedClient}
 | 
			
		||||
	handler := http.HandlerFunc(h.streamEvents)
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
	mockedClient.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_handler_streamEvents_error(t *testing.T) {
 | 
			
		||||
	req, err := http.NewRequest("GET", "/api/events/stream", nil)
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
	messages := make(chan events.Message)
 | 
			
		||||
	errChannel := make(chan error)
 | 
			
		||||
	mockedClient.On("Events", mock.Anything).Return(messages, errChannel)
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		errChannel <- errors.New("fake error")
 | 
			
		||||
		close(messages)
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	h := handler{client: mockedClient}
 | 
			
		||||
	handler := http.HandlerFunc(h.streamEvents)
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
	mockedClient.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_handler_streamEvents_error_request(t *testing.T) {
 | 
			
		||||
	req, err := http.NewRequest("GET", "/api/events/stream", nil)
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
 | 
			
		||||
	messages := make(chan events.Message)
 | 
			
		||||
	errChannel := make(chan error)
 | 
			
		||||
	mockedClient.On("Events", mock.Anything).Return(messages, errChannel)
 | 
			
		||||
 | 
			
		||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
	req = req.WithContext(ctx)
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		cancel()
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	h := handler{client: mockedClient}
 | 
			
		||||
	handler := http.HandlerFunc(h.streamEvents)
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
	mockedClient.AssertExpectations(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_createRoutes_index(t *testing.T) {
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
	box := packr.NewBox("./virtual")
 | 
			
		||||
	require.NoError(t, box.AddString("index.html", "index page"), "AddString should have no error.")
 | 
			
		||||
 | 
			
		||||
	handler := createRoutes("/", &handler{mockedClient, box})
 | 
			
		||||
	req, err := http.NewRequest("GET", "/", nil)
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_createRoutes_redirect(t *testing.T) {
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
	box := packr.NewBox("./virtual")
 | 
			
		||||
 | 
			
		||||
	handler := createRoutes("/foobar", &handler{mockedClient, box})
 | 
			
		||||
	req, err := http.NewRequest("GET", "/foobar", nil)
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_createRoutes_foobar(t *testing.T) {
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
	box := packr.NewBox("./virtual")
 | 
			
		||||
	require.NoError(t, box.AddString("index.html", "foo page"), "AddString should have no error.")
 | 
			
		||||
 | 
			
		||||
	handler := createRoutes("/foobar", &handler{mockedClient, box})
 | 
			
		||||
	req, err := http.NewRequest("GET", "/foobar/", nil)
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_createRoutes_foobar_file(t *testing.T) {
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
	box := packr.NewBox("./virtual")
 | 
			
		||||
	require.NoError(t, box.AddString("/test", "test page"), "AddString should have no error.")
 | 
			
		||||
 | 
			
		||||
	handler := createRoutes("/foobar", &handler{mockedClient, box})
 | 
			
		||||
	req, err := http.NewRequest("GET", "/foobar/test", nil)
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	assert.Equal(t, rr.Body.String(), "test page", "page doesn't match")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_createRoutes_version(t *testing.T) {
 | 
			
		||||
	mockedClient := new(MockedClient)
 | 
			
		||||
	box := packr.NewBox("./virtual")
 | 
			
		||||
 | 
			
		||||
	handler := createRoutes("/", &handler{mockedClient, box})
 | 
			
		||||
	req, err := http.NewRequest("GET", "/version", nil)
 | 
			
		||||
	require.NoError(t, err, "NewRequest should not return an error.")
 | 
			
		||||
	rr := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	handler.ServeHTTP(rr, req)
 | 
			
		||||
	abide.AssertHTTPResponse(t, t.Name(), rr.Result())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMain(m *testing.M) {
 | 
			
		||||
	exit := m.Run()
 | 
			
		||||
	abide.Cleanup()
 | 
			
		||||
	os.Exit(exit)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										5185
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5185
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										48
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								package.json
									
									
									
									
									
								
							@@ -1,14 +1,15 @@
 | 
			
		||||
{
 | 
			
		||||
 "name": "dozzle",
 | 
			
		||||
 "version": "1.2.5",
 | 
			
		||||
 "description": "",
 | 
			
		||||
 "main": "index.js",
 | 
			
		||||
 "version": "1.10.1",
 | 
			
		||||
 "description": "Realtime log viewer for docker containers. ",
 | 
			
		||||
 "scripts": {
 | 
			
		||||
  "start": "concurrently 'go run main.go' 'npm run watch-assets'",
 | 
			
		||||
  "watch-assets": "parcel watch --public-url '__BASE__' assets/index.html -d static",
 | 
			
		||||
  "prestart": "npm run clean",
 | 
			
		||||
  "start": "DOCKER_API_VERSION=1.38 concurrently 'npm run watch-server' 'npm run watch-assets'",
 | 
			
		||||
  "watch-assets": "npx parcel watch --public-url '__BASE__' assets/index.html -d static",
 | 
			
		||||
  "watch-server": "reflex -c .reflex",
 | 
			
		||||
  "prebuild": "npm run clean",
 | 
			
		||||
  "build": "parcel build --no-source-maps --public-url '__BASE__' assets/index.html -d static",
 | 
			
		||||
  "clean": "rm -rf static",
 | 
			
		||||
  "build": "npx parcel build --no-source-maps --public-url '__BASE__' assets/index.html -d static",
 | 
			
		||||
  "clean": "rm -rf static/ a_main-packr.go",
 | 
			
		||||
  "release": "goreleaser --rm-dist"
 | 
			
		||||
 },
 | 
			
		||||
 "repository": {
 | 
			
		||||
@@ -22,24 +23,24 @@
 | 
			
		||||
 },
 | 
			
		||||
 "homepage": "https://github.com/amir20/dozzle#readme",
 | 
			
		||||
 "dependencies": {
 | 
			
		||||
  "bulma": "^0.7.2",
 | 
			
		||||
  "bulma-tooltip": "^2.0.2",
 | 
			
		||||
  "bulma": "^0.7.5",
 | 
			
		||||
  "date-fns": "^2.0.0-alpha.25",
 | 
			
		||||
  "vue": "^2.5.17",
 | 
			
		||||
  "vue-router": "^3.0.2"
 | 
			
		||||
  "vue": "^2.6.10",
 | 
			
		||||
  "vue-meta": "^1.6.0",
 | 
			
		||||
  "vue-router": "^3.0.6"
 | 
			
		||||
 },
 | 
			
		||||
 "devDependencies": {
 | 
			
		||||
  "@babel/core": "^7.1.6",
 | 
			
		||||
  "@babel/plugin-transform-runtime": "^7.1.0",
 | 
			
		||||
  "@vue/component-compiler-utils": "^2.3.0",
 | 
			
		||||
  "@babel/core": "^7.4.4",
 | 
			
		||||
  "@babel/plugin-transform-runtime": "^7.4.4",
 | 
			
		||||
  "@vue/component-compiler-utils": "^3.0.0",
 | 
			
		||||
  "concurrently": "^4.1.0",
 | 
			
		||||
  "husky": "^1.2.0",
 | 
			
		||||
  "lint-staged": "^8.1.0",
 | 
			
		||||
  "parcel-bundler": "^1.10.3",
 | 
			
		||||
  "prettier": "^1.15.2",
 | 
			
		||||
  "sass": "^1.15.1",
 | 
			
		||||
  "vue-hot-reload-api": "^2.3.1",
 | 
			
		||||
  "vue-template-compiler": "^2.5.17"
 | 
			
		||||
  "husky": "^2.3.0",
 | 
			
		||||
  "lint-staged": "^8.1.7",
 | 
			
		||||
  "parcel-bundler": "^1.12.3",
 | 
			
		||||
  "prettier": "^1.17.1",
 | 
			
		||||
  "sass": "^1.20.1",
 | 
			
		||||
  "vue-hot-reload-api": "^2.3.3",
 | 
			
		||||
  "vue-template-compiler": "^2.6.10"
 | 
			
		||||
 },
 | 
			
		||||
 "husky": {
 | 
			
		||||
  "hooks": {
 | 
			
		||||
@@ -55,5 +56,8 @@
 | 
			
		||||
 "browserslist": [
 | 
			
		||||
  ">5%",
 | 
			
		||||
  "not ie <= 8"
 | 
			
		||||
 ]
 | 
			
		||||
 ],
 | 
			
		||||
 "alias": {
 | 
			
		||||
  "vue": "./node_modules/vue/dist/vue.esm.js"
 | 
			
		||||
 }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user