Self-Managed administrators define lasting custom <iframe> providers
What does this MR do?
Propagate config for admin-defined <iframe> providers. gitlab_rails['iframe_providers'] is rendered into gitlab.yml, where Self-Managed administrators define lasting cust... (gitlab!271233 - merged) reads it.
Note the feature itself is FF'd and pre-GA.
Test plan
I ran this on a Linux package install in Docker (a 19.5.0 gitlab-ee image), applying this MR's attribute and gitlab.yml.erb changes to the package's cookbooks in /opt/gitlab/embedded/cookbooks for step 2 and onward.
The value is written out with to_json, so the plan covers the values that matter: strings with {name} placeholders, nested lists of hashes, and booleans.
-
Without this MR (e.g. on
master), add the following to/etc/gitlab/gitlab.rb, and runsudo gitlab-ctl reconfigure:gitlab_rails['iframe_providers'] = { 'openstreetmap' => { 'name' => 'OpenStreetMap', 'matches' => [ { 'host' => 'www.openstreetmap.org', 'path' => '/export/embed.html', 'params' => ['bbox'] } ], 'src' => 'https://www.openstreetmap.org/export/embed.html?bbox={bbox}', 'view' => 'https://www.openstreetmap.org/export/embed.html?bbox={bbox}', 'sandbox' => ['allow-scripts', 'allow-same-origin'], 'require_activation' => false }, 'youtube' => { 'name' => 'YouTube (click to load)', 'matches' => [ { 'host' => 'www.youtube.com', 'path' => '/embed/{v}' }, { 'host' => 'www.youtube.com', 'path' => '/watch', 'params' => ['v'] }, { 'host' => 'youtu.be', 'path' => '/{v}' } ], 'src' => 'https://www.youtube.com/embed/{v}', 'view' => 'https://www.youtube.com/watch?v={v}', 'sandbox' => ['allow-scripts', 'allow-same-origin'], 'require_activation' => true } }Reconfigure succeeds, but nothing reaches
gitlab.yml:$ sudo /opt/gitlab/embedded/bin/ruby -ryaml -e 'p YAML.safe_load_file("/var/opt/gitlab/gitlab-rails/etc/gitlab.yml", aliases: true).dig("production", "gitlab", "iframe_providers")&.transform_values { |v| v.slice("src", "require_activation") }' nil -
With this MR, take the providers back out of
gitlab.rb, and reconfigure. The command from step 1 still printsnil: nothing is rendered by default. -
Add the providers back, and reconfigure. They're now rendered under
production.gitlab, placeholders and booleans intact:$ sudo /opt/gitlab/embedded/bin/ruby -ryaml -e 'p YAML.safe_load_file("/var/opt/gitlab/gitlab-rails/etc/gitlab.yml", aliases: true).dig("production", "gitlab", "iframe_providers")&.transform_values { |v| v.slice("src", "require_activation") }' {"openstreetmap" => {"src" => "https://www.openstreetmap.org/export/embed.html?bbox={bbox}", "require_activation" => false}, "youtube" => {"src" => "https://www.youtube.com/embed/{v}", "require_activation" => true}}The whole parsed value is equal to the hash set in
gitlab.rb, including YouTube's threematches. -
Rails sees them:
$ sudo gitlab-rails runner 'p = Gitlab.config.gitlab.iframe_providers.to_hash; puts p.keys.inspect; puts p["youtube"]["name"]; puts p["openstreetmap"]["sandbox"].inspect' ["openstreetmap", "youtube"] YouTube (click to load) ["allow-scripts", "allow-same-origin"](Released Rails only exposes the setting; loading them as embed providers needs gitlab!271233 (merged), validated end-to-end against Self-Managed administrators define lasting cust... (gitlab-org/charts/gitlab!5608).)
Related issues
- <iframe> embeds in Markdown content (gitlab#282443) — the feature work item.
- Self-Managed administrators define lasting cust... (gitlab!271233 - merged) — the monolith-side MR to merge these in, including docs.
- Self-Managed administrators define lasting cust... (gitlab-org/charts/gitlab!5608) — the Charts-side MR to provide these settings.
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion.
Required
- MR title and description are up to date, accurate, and descriptive.
- MR targeting the appropriate branch.
- Latest Merge Result pipeline is green.
- When ready for review, MR is labeled workflowready for review per the Distribution MR workflow.
For GitLab team members
If you don't have access to this, the reviewer should trigger these jobs for you during the review process.
- The manual
Trigger:ee-packagejobs have a green pipeline running against latest commit. -
Ifconfig/softwareorconfig/patchesdirectories are changed, make sure thebuild-package-on-all-osjob within theTrigger:ee-packagedownstream pipeline succeeded. -
If you are changing anything SSL related, then theTrigger:package:fipsmanual job within theTrigger:ee-packagedownstream pipeline must succeed. -
If CI configuration is changed, the branch must be pushed todev.gitlab.orgto confirm regular branch builds aren't broken.
Expected (please provide an explanation if not completing)
- Test plan indicating conditions for success has been posted and passes.
- Documentation created/updated.
- Tests added.
-
Integration tests added toGitLab QA.- imho it's overkill and unwarranted (and not really in step with other similar MRs). Covered by ChefSpec.
- Equivalent MR/issue for the GitLab Chart opened: Self-Managed administrators define lasting cust... (gitlab-org/charts/gitlab!5608).
- Validate potential values for new configuration settings. Formats such as integer
10, duration10s, URIscheme://user:passwd@host:portmay require quotation or other special handling when rendered in a template and written to a configuration file.