diff --git a/CHANGELOG.md b/CHANGELOG.md index ea0766e..7be1afb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Latest +- [Improvement] Rename "config [non]interactive" command to "config save [--silent]" - [Improvement] More explicit logging during environment generation - [Improvement] Configurable docker images (#122) - [Bugfix] Fix "android pullimage" command diff --git a/Makefile b/Makefile index 94317a1..8323032 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ retag: git push origin $(TAG) travis: bundle ## Run tests on travis-ci - ./dist/tutor config noninteractive + ./dist/tutor config save --silent ./dist/tutor images env ./dist/tutor images build all ./dist/tutor local databases @@ -43,7 +43,7 @@ ci-bundle: ## Create bundle cp ./dist/tutor ./releases/tutor-$$(uname -s)_$$(uname -m) ci-test: ## Run basic tests - ./dist/tutor config noninteractive + ./dist/tutor config save --silent ./dist/tutor images env ./dist/tutor local env diff --git a/docs/configuration.rst b/docs/configuration.rst index fdb9677..de7893e 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -3,7 +3,7 @@ Configuration ============= -With Tutor, all Open edX deployment parameters are stored in a single ``config.yml`` file. This is the file that is generated when you run ``tutor local quickstart`` or ``tutor config interactive``. To view the content of this file, run:: +With Tutor, all Open edX deployment parameters are stored in a single ``config.yml`` file. This is the file that is generated when you run ``tutor local quickstart`` or ``tutor config save``. To view the content of this file, run:: cat $(tutor config printroot)/config.yml @@ -13,7 +13,7 @@ By default, this file contains only the required configuration parameters for ru Alternatively, you can set each parameter from the command line:: - tutor config noninteractive --set PARAM1=VALUE1 --set PARAM2=VALUE2 + tutor config save --silent --set PARAM1=VALUE1 --set PARAM2=VALUE2 After changing a configuration parameter, it will be taken into account next time the environment is generated. For instance, in a local installation:: diff --git a/docs/local.rst b/docs/local.rst index 5d6edf1..06b69c8 100644 --- a/docs/local.rst +++ b/docs/local.rst @@ -21,9 +21,9 @@ Configuration :: - tutor config interactive + tutor config save -This is the only non-automatic step in the install process. You will be asked various questions about your Open edX platform and appropriate configuration files will be generated. If you would like to automate this step then you should run ``tutor config interactive`` once. After that, there will be a ``config.yml`` file at the root of the project folder: this file contains all the configuration values for your platform, such as randomly generated passwords, domain names, etc. +This is the only non-automatic step in the install process. You will be asked various questions about your Open edX platform and appropriate configuration files will be generated. If you would like to automate this step then you should run ``tutor config save`` once. After that, there will be a ``config.yml`` file at the root of the project folder: this file contains all the configuration values for your platform, such as randomly generated passwords, domain names, etc. If you want to run a fully automated install, upload the ``config.yml`` file to wherever you want to run Open edX. You can then entirely skip the configuration step. diff --git a/tutor/config.py b/tutor/config.py index ccf38f0..a9c70a1 100644 --- a/tutor/config.py +++ b/tutor/config.py @@ -14,37 +14,24 @@ from . import opts short_help="Configure Open edX", help="""Configure Open edX and store configuration values in $TUTOR_ROOT/config.yml""" ) -@opts.root -def config(root): +def config(): pass -@click.command( - help="Create and save configuration interactively", -) +@click.command(help="Create and save configuration interactively") @opts.root +@click.option("--silent", is_flag=True, help="Run non-interactively") @opts.key_value -def interactive(root, set_): +def save(root, silent, set_): config = {} load_files(config, root) for k, v in set_: config[k] = v - load_interactive(config) - save(config, root) + if not silent: + load_interactive(config) + save_config(config, root) @click.command( - help="Create and save configuration without user interaction", -) -@opts.root -@opts.key_value -def noninteractive(root, set_): - config = {} - load_files(config, root) - for k, v in set_: - config[k] = v - save(config, root) - -@click.command( - help="Print the tutor project root", + help="Print the project root", ) @opts.root def printroot(root): @@ -60,7 +47,7 @@ def load(root): if not os.path.exists(config_path(root)): load_interactive(config) - save(config, root) + save_config(config, root) load_defaults(config) @@ -156,11 +143,11 @@ def convert_json2yml(root): ) with open(json_path) as fi: config = json.load(fi) - save(config, root) + save_config(config, root) os.remove(json_path) click.echo(fmt.info("File config.json detected in {} and converted to config.yml".format(root))) -def save(config, root): +def save_config(config, root): env.render_dict(config) path = config_path(root) directory = os.path.dirname(path) @@ -173,6 +160,5 @@ def save(config, root): def config_path(root): return os.path.join(root, "config.yml") -config.add_command(interactive) -config.add_command(noninteractive) +config.add_command(save) config.add_command(printroot) diff --git a/tutor/k8s.py b/tutor/k8s.py index 3794df4..e1f16a6 100644 --- a/tutor/k8s.py +++ b/tutor/k8s.py @@ -20,7 +20,7 @@ def k8s(): @opts.root def quickstart(root): click.echo(fmt.title("Interactive platform configuration")) - tutor_config.interactive.callback(root, []) + tutor_config.save.callback(root, False, []) click.echo(fmt.title("Environment generation")) env.callback(root) click.echo(fmt.title("Stopping any existing platform")) diff --git a/tutor/local.py b/tutor/local.py index 25c7bd1..1eb8aa3 100644 --- a/tutor/local.py +++ b/tutor/local.py @@ -27,7 +27,7 @@ def local(): @opts.root def quickstart(pullimages_, root): click.echo(fmt.title("Interactive platform configuration")) - tutor_config.interactive.callback(root, []) + tutor_config.save.callback(root, False, []) click.echo(fmt.title("Environment generation")) env.callback(root) click.echo(fmt.title("Stopping any existing platform"))