Commit Graph

1257 Commits

Author SHA1 Message Date
Régis Behmo 15b219e235 feat: migrate to plugins.v1 with filters & actions
This is a very large refactoring which aims at making Tutor both more
extendable and more generic. Historically, the Tutor plugin system was
designed as an ad-hoc solution to allow developers to modify their own
Open edX platforms without having to fork Tutor. The plugin API was
simple, but limited, because of its ad-hoc nature. As a consequence,
there were many things that plugin developers could not do, such as
extending different parts of the CLI or adding custom template filters.

Here, we refactor the whole codebase to make use of a generic plugin
system. This system was inspired by the Wordpress plugin API and the
Open edX "hooks and filters" API. The various components are added to a
small core thanks to a set of actions and filters. Actions are callback
functions that can be triggered at different points of the application
lifecycle. Filters are functions that modify some data. Both actions and
filters are collectively named as "hooks". Hooks can optionally be
created within a certain context, which makes it easier to keep track of
which application created which callback.

This new hooks system allows us to provide a Python API that developers
can use to extend their applications. The API reference is added to the
documentation, along with a new plugin development tutorial.

The plugin v0 API remains supported for backward compatibility of
existing plugins.

Done:
- Do not load commands from plugins which are not enabled.
- Load enabled plugins once on start.
- Implement contexts for actions and filters, which allow us to keep track of
  the source of every hook.
- Migrate patches
- Migrate commands
- Migrate plugin detection
- Migrate templates_root
- Migrate config
- Migrate template environment globals and filters
- Migrate hooks to tasks
- Generate hook documentation
- Generate patch reference documentation
- Add the concept of action priority

Close #499.
2022-04-15 15:30:54 +02:00
Gábor Boros 649244d6c4 style: update template formatting 2022-04-15 10:43:28 +02:00
Gábor Boros 060a0c7d32 refactor: split user and password creation 2022-04-15 10:43:28 +02:00
Gábor Boros b71ae61f09 fix: remove quotes 2022-04-15 10:43:28 +02:00
Gábor Boros bc17d47ebc fix: ensure mysql8 compatibility
MySQL 8 drop the support for creating users by executing `GRANT ALL`. This commit splits the user creation and permission granting, therefore the newer MySQL versions are supported too.

MySQL 8 is supported by edx-platform: 1cdb0347c5/playbooks/roles/mysql/tasks/mysql.yml (L93-L98)
2022-04-15 10:43:28 +02:00
Kyle McCormick b6999824a7 feat: add `tutor [dev|local|k8s] status` command 2022-04-15 09:29:02 +02:00
Florian Haas 407a8566df fix: Correct EDX_PLATFORM_VERSION default for local edx-platform forks
PR #619 set the EDX_PLATFORM_VERSION build arg's default to
OPENEDX_COMMON_VERSION. While this works fine for setting a
non-default branch to run edx code from (say, "master"), it may break
if the user sets OPENEDX_COMMON_VERSION to a branch or tag name that
does not exist upstream in repositories *other than*
EDX_PLATFORM_REPOSITORY.

Thus, introduce a separate configuration parameter,
EDX_PLATFORM_VERSION, to match the build arg of the same name. Set its
default to OPENEDX_COMMON_VERSION.

This way, the user can deploy an arbitrarily-named fork of
edx-platform, while retaining the default OPENEDX_COMMON_VERSION
(like, for example "open-release/maple.3") for everything else.
2022-04-15 09:24:15 +02:00
Régis Behmo cac9d14e01 feat: run `tutor k8s exec ...` commands with multiple args
Previously, the `k8s exec` command did not support unknown "--options". This
made it impossible to launch, say, a django shell in the lms container.

While implementing this feature we saw an opportunity to simplify the way jobs
are handled in the k8s commands.

Close #636.
Another related issue is: https://github.com/overhangio/2u-tutor-adoption/issues/52
2022-04-15 09:21:36 +02:00
Kyle McCormick 5f4159c030 docs: wrap `tutor[full]` in quotes for zsh compatibility
The docs recommend commands like:

    pip install tutor[full]
    pip install -e ./tutor[full]

for installing Tutor. These work fine in bash. For zsh,
though, which is now the default on macOS, quotes are
needed, otherwise zsh will interpret the brackets as
special syntax:

    pip install "tutor[full]"
    pip install -e "./tutor[full]"

Caveat: I have not tested this myself since I don't
own a Mac, but I've read several issue reports to this
effect, such as:
https://github.com/pypa/pipenv/issues/2830#issuecomment-419593199
2022-04-15 09:20:21 +02:00
Kyle McCormick 3ca4522f68 docs: update Nightly docs to reference `[full]` installation
The full installation will include all the plugins that
come bundled with Tutor stable. This is made possible by
a recent change to Tutor Nightly
(https://github.com/overhangio/tutor/pull/626).
2022-04-15 09:20:21 +02:00
Régis Behmo 7f7138f050 v13.1.11 (2022-04-12)
- [Security] Apply SAML security fix.
- [Improvement] In addition to the Docker build arguments
  `EDX_PLATFORM_REPOSITORY` and `NPM_REGISTRY`, also support two corresponding
  and identically-named `config.yml` values serving the same purpose.
2022-04-12 17:37:55 +02:00
Régis Behmo 16b2378165 sec: fix SAML vulnerability 2022-04-12 17:36:59 +02:00
Florian Haas eaa578eabd feat: Make the platform repository and NPM registry configurable from config.yml
Previously, the only way for Tutor users to use a fork of edx-platform
or a custom NPM registry was to use build args during the image build.

This is suboptimal in the case of automatically building images from
CI pipelines, which may want to auto-detect when an image needs to be
rebuilt based on config.yml changes.

In addition, the EDX_PLATFORM_VERSION build argument can already be
set via a corresponding config.yml parameter (OPENEDX_COMMON_VERSION),
so it's reasonable to follow that precedent and also introduce
config.yml parameters to correspond with the EDX_PLATFORM_REPOSITORY
and NPM_REGISTRY build arguments.

Thus, introduce two new configuration parameters:

- EDX_PLATFORM_REPOSITORY
- NPM_REGISTRY

These parameters can now optionally be used instead of the
aforementioned build args.
2022-04-12 15:46:50 +02:00
Régis Behmo 11bfa96971 v13.1.10 (2022-04-11)
- [Feature] Upgrade all applications to open-release/maple.3.
2022-04-11 18:45:28 +02:00
Régis Behmo 0b86568ad5 feat: upgrade all apps to open-release/maple.3
Fresh out of the oven!
2022-04-11 18:44:15 +02:00
Rebecca Graber 7822f4e217 v13.1.9 (2022-04-06) 2022-04-06 22:56:40 +02:00
Florian Haas baf7d03cf8 fix: Fix typo ("MongDB")
An user-facing echo_info message in the upgrade commands rendered
MongoDB as "MongDB". Trivial fix.
2022-04-01 11:29:14 +02:00
Régis Behmo 5aa1d53167 fix: remove duplicate `LOCAL_PROJECT_NAME` config entry 2022-03-31 16:31:03 +02:00
Régis Behmo 0500bfe9a6 fix: package version in nightly
The string returned by "make version" should not include the "-nightly"
suffix, otherwise tests fail.
2022-03-31 15:36:30 +02:00
Régis Behmo fa32269e91 fix: nightly package version
The version of the nightly python package should not include the "-nightly"
suffix. That's because when we `pip install -e` tutor plugins, pip also
installs the latest tutor release, as part of the requirements. This overrides
the local (nightly) installation of tutor.

See: https://app.slack.com/client/T02SNA1T6/C02V3GHE3UP
2022-03-29 08:49:54 +02:00
Emad Rad a25ae73031 minor typos fixed 2022-03-29 08:44:33 +02:00
Régis Behmo 43c5177187 v13.1.8 (2022-03-18)
- [Bugfix] Fix "evalsymlink failure" during `k8s quickstart` (#611).
- [Bugfix] Fix "TypeError: upgrade() got an unexpected keyword argument 'non_interactive'" during `local upgrade`.
2022-03-24 09:41:41 +01:00
Régis Behmo 6e2cef0db5 fix: "evalsymlink failure" during k8s namespace creation
Close #611 (again).
2022-03-24 08:25:56 +01:00
Régis Behmo 8779bbd8b6 fix: TypeError during local quickstart
See: https://discuss.overhang.io/t/upgrade-error-upgrade-got-an-unexpected-keyword-argument-non-interactive/2582
2022-03-24 08:25:56 +01:00
Régis Behmo c6009abbcf docs: fix demo course link
See: https://discuss.overhang.io/t/demo-test-course-vs-edx-demo-course/2549
2022-03-24 08:17:59 +01:00
Régis Behmo 3e2c4aebf4 v13.1.7 (2022-03-17)
- [Bugfix] Fix dockerize on arm64 by switching to the [powerman/dockerize](https://github.com/powerman/dockerize) fork (#591).
- [Bugfix] Fix "Unexpected args" error during service initialization on Kubernetes (#611).
2022-03-17 11:26:40 +01:00
Régis Behmo 766f392189 docs: fix sample saml plugin
See: https://github.com/overhangio/tutor/pull/604
2022-03-17 11:26:40 +01:00
Régis Behmo a24b29271a fix: dockerize on arm64
The version of dockerize that shipped with the "openedx" image was not
compatible with arm64. The original project is unmaintained, but there
is a fork that provides a version that is compatible with arm64.

This was tested on arm64 with buildx:

    docker buildx build --tag=openedx --platform=linux/arm64 ~/.local/share/tutor/env/build/openedx

Close #591
2022-03-17 11:26:40 +01:00
Régis Behmo f13c3db833 fix: "unexpected args" error on k8s
`kubectl_apply` was missing a "root" argument.

Close #611.
2022-03-17 10:40:57 +01:00
Régis Behmo 8e052f703f docs: clarify image building on arm64
Close #590.
2022-03-17 10:38:55 +01:00
Régis Behmo c63c952392 v13.1.6 (2022-03-15)
- [Bugfix] Fix `local/k8s quickstart` commands when upgrading from an older release (#595).
- [Bugfix] Fix running the default exim-relay SMTP server on arm64 (#600).
- [Feature] Add `tutor k8s apply` comand, which is a direct interface with `kubectl apply`.
- [Feature] Add `openedx-dockerfile-minimal` patch, which you can use to install custom packages and run commands as root in the Docker image.
2022-03-15 13:36:49 +01:00
Régis Behmo 653e4dc57d fix: "unexpected keyword argument" during quickstart upgrade
Close #595.
2022-03-15 13:35:44 +01:00
Emad Rad dde22f3832 openedx-dockerfile-minimal added 2022-03-14 13:34:11 +01:00
Emad Rad 6393de9862 dockerfile patch added in the minimal section 2022-03-14 13:34:11 +01:00
Régis Behmo 49f11dd3a0 fix: upgrade exim-relay SMTP image to make it work on arm64
Close #600.
2022-03-14 12:45:17 +01:00
Kyle McCormick 38a67e6c64 squash: docs: grammar, typos 2022-03-10 19:26:18 +01:00
Kyle McCormick 0d2d6c58e8 squash: docs: address reveiw comments 2022-03-10 19:26:18 +01:00
Kyle McCormick 87f8348a01 docs: clarify YAML vs. Python plugins & CLI customization
I found the existing docs a bit light on the particulars
of how the YAML and Python plugin APIs relate. I was
able to figure it out (there's a nice congruence
between them) but I think these tweaks should it make
it more immediately obvious to readers how the Python
API is a essentially a superset of the YAML API that
allows for dynamic behavior.
2022-03-10 19:26:18 +01:00
Kyle McCormick bb888a8af5 docs: change "Reference" heading to "CLI Reference"
because it only contains CLI reference information currently.

The folder structure implies that eventually there will be
more reference material, so the name of 'reference.rst'
was *not* changed to 'cli-reference.rst'.
2022-03-10 19:26:18 +01:00
Régis Behmo 2d20a04363 feat: add a convenient `tutor k8s apply` command
This is convenient to check k8s template validity.
2022-02-25 14:50:36 +01:00
Régis Behmo 79f14b7e7e chore: fix various linting warnings in f-strings and docs 2022-02-25 14:50:36 +01:00
Régis Behmo a8d60d753b chore: resolve "deprecated django-admin.py is deprecated" warning
See: https://docs.djangoproject.com/en/dev/internals/deprecation/#deprecation-removed-in-4-0
2022-02-25 14:50:29 +01:00
Régis Behmo d63b9aced2 docs: clarify how to run commands in k8s containers
This problem emerged here: https://discuss.overhang.io/t/discovery-user-creation-in-kubernetes-deployment/2442
2022-02-25 14:50:12 +01:00
Régis Behmo 89520c016f chore: upgrade mypy
As a consequence, we need to resolve a typing issue.
2022-02-21 10:59:53 +01:00
Régis Behmo b78feec895 v13.1.5 (2022-02-14)
- [Improvement] Upgrade all services to open-release/maple.2.
2022-02-14 16:53:01 +01:00
Régis Behmo 156ef063ce feat: upgrade all services to open-release/maple.2 2022-02-14 14:38:43 +01:00
Régis Behmo ec2598e114 v13.1.4 (2022-02-08)
- [Security] Fix vulnerability in redirect url during authentication (see
  [commit](06550411e3)).
2022-02-08 10:33:37 +01:00
Régis Behmo c6cfa24dcc security: fix vulnerability in redirect url during auth 2022-02-08 09:52:28 +01:00
Régis Behmo 68b46aa720 v13.1.3 (2022-02-01)
- [Security] Fix vulnerability in call to invalid enrollment API (see [commit](e9369cffde)).
- [Bugfix] Fix "Internal Server Error / AttributeError / object has no attribute 'get_metadata'" in learning MFE.
- [Improvement] Replace all links to github.com/edx by github.com/openedx, following the migration of all repositories.
- [Bugfix] Fix `k8s start caddy` command.
2022-02-01 17:50:44 +01:00
Régis Behmo 89b4ce1202 security: fix enrollment API vulnerability 2022-02-01 17:40:53 +01:00