-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker config file defaults from environment #126
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9327cb5
Initial implementation
stefanoborini 2513dbd
better documentation in the default config file, which is now rather …
stefanoborini a2c4876
Removed docker configuation class. Tests will be broken
stefanoborini 45a34a3
Fixed tests
stefanoborini eafff1e
Skipping creation of tls entry if there's no tls request
stefanoborini a841628
Removed documentation entry that is no longer used.
stefanoborini fd5eb41
Added tests for overriding
stefanoborini 5d4dc7d
Review
stefanoborini 9d3cbd5
Fixed test
stefanoborini e3045d3
trait names
stefanoborini fecaf1d
Punctualized use of tls vs tls_verify
stefanoborini 977c4e5
Fixed handling of tls
stefanoborini b237d91
Flipped the condition because tls takes precedence.
stefanoborini 3fd7249
Review
stefanoborini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,61 @@ | ||
import os | ||
import platform | ||
|
||
# Clarifies to be not intended to be passed to tornado config conflict. | ||
# Tornado extracts vars from global scope of the config file. | ||
_platform = platform.system() | ||
|
||
if _platform == 'Darwin': | ||
# For platforms that have a separate docker machine, we need to connect | ||
# using tls, but if we use self-signed certificates, using tls as True | ||
# will produce an error of incorrect CA validation. | ||
# As a consequence, we set tls to false, and tls_verify to true, honoring | ||
# docker documentation (although not very clear on this point) | ||
# See https://docs.docker.com/engine/security/https/ | ||
if "DOCKER_CERT_PATH" not in os.environ: | ||
raise ValueError("Docker environment has not been defined.") | ||
|
||
tls = False | ||
tls_verify = bool(int(os.path.expandvars("${DOCKER_TLS_VERIFY}"))) | ||
tls_ca = os.path.expandvars('${DOCKER_CERT_PATH}/ca.pem') | ||
tls_cert = os.path.expandvars('${DOCKER_CERT_PATH}/cert.pem') | ||
tls_key = os.path.expandvars('${DOCKER_CERT_PATH}/key.pem') | ||
docker_host = os.path.expandvars("${DOCKER_HOST}") | ||
elif _platform == 'Linux': | ||
# Linux works through unix socket, so we don't need tls. | ||
tls = False | ||
else: | ||
raise RuntimeError("Unknown platform {}".format(_platform)) | ||
|
||
|
||
# ----------------------------- | ||
# Define the accounting class | ||
# ----------------------------- | ||
# Notes on os.path: | ||
# 1. When running with system-user mode, both the current directory and '~' | ||
# are the system user's home directory. | ||
# 2. When running in virtual-user mode, the current directory is the | ||
# directory where jupyterhub is started, '~' would be evaluated according to | ||
# the spawned process's owner's home directory (not the virtual user's | ||
# home directory) | ||
|
||
# CSV database support | ||
# # -------------------- | ||
# # Docker configuration | ||
# # -------------------- | ||
# # | ||
# # Configuration options for connecting to the docker machine. | ||
# # These options override the default provided by the local environment | ||
# # variables. | ||
# # | ||
# # The endpoint of the docker machine, specified as a URL. | ||
# # By default, it is obtained by DOCKER_HOST envvar. On Linux in a vanilla | ||
# # install, the connection uses a unix socket by default. | ||
# | ||
# docker_host = "tcp://192.168.99.100:2376" | ||
# | ||
# # TLS configuration | ||
# # ----------------- | ||
# # | ||
# # Set this to True only if your docker machine has a certificate signed by | ||
# # a recognised CA. | ||
# # If using self-signed certificates, using tls as True will produce an error | ||
# # of incorrect CA validation. As a consequence, the default tls setting is | ||
# # False, and tls_verify is according to the current environment (likely True | ||
# # with default setup on OSX), honoring docker documentation. | ||
# # See https://docs.docker.com/engine/security/https/ for additional details | ||
# | ||
# tls = True | ||
# | ||
# # Enables verification of the certificates. By default, this is the | ||
# # result of the DOCKER_TLS_VERIFY envvar | ||
# | ||
# tls_verify = True | ||
# | ||
# # Full paths of the CA certificate, certificate and key of the docker | ||
# # machine. Normally these are computed from the DOCKER_CERT_PATH | ||
# | ||
# tls_ca = "/path/to/ca.pem" | ||
# tls_cert = "/path/to/cert.pem" | ||
# tls_key = "/path/to/key.pem" | ||
# | ||
# # ---------- | ||
# # Accounting | ||
# # ---------- | ||
# # Notes on os.path: | ||
# # 1. When running with system-user mode, both the current directory and '~' | ||
# # are the system user's home directory. | ||
# # 2. When running in virtual-user mode, the current directory is the | ||
# # directory where jupyterhub is started, '~' would be evaluated according to | ||
# # the spawned process's owner's home directory (not the virtual user's | ||
# # home directory) | ||
# | ||
# # CSV database support | ||
# | ||
# accounting_class = "remoteappmanager.db.csv_db.CSVAccounting" | ||
# accounting_kwargs = { | ||
# "csv_file_path": os.path.abspath("./remoteappmanager.csv")} | ||
|
||
# sqlite database support | ||
# | ||
# # Sqlite database support | ||
# | ||
# accounting_class = "remoteappmanager.db.orm.AppAccounting" | ||
# accounting_kwargs = { | ||
# "url": "sqlite:///"+os.path.abspath('./remoteappmanager.db')} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/simphony/simphony-remote/pull/126/files#r71502734 refers to here. Maybe we should take the hostname regardless of its scheme?