diff --git a/.gitmodules b/.gitmodules index 20e0b98686..a3c5d9a4dd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/emojis"] path = vendor/emojis url = https://github.com/buildkite/emojis.git +[submodule "vendor/migration"] + path = vendor/migration + url = https://github.com/buildkite/migration diff --git a/Gemfile b/Gemfile index 9f6ac4c776..d8605732c6 100644 --- a/Gemfile +++ b/Gemfile @@ -79,3 +79,5 @@ end group :test do gem "buildkite-test_collector" end + +gem "parslet" diff --git a/Gemfile.lock b/Gemfile.lock index c5a439b522..ed88c47af4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,6 +81,7 @@ GEM nokogiri (1.15.2) mini_portile2 (~> 2.8.2) racc (~> 1.4) + parslet (2.0.0) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) @@ -175,6 +176,7 @@ DEPENDENCIES graphql-client lograge matrix + parslet pry puma railties (~> 6.0) diff --git a/app/controllers/migration_controller.rb b/app/controllers/migration_controller.rb new file mode 100644 index 0000000000..9c966b5c22 --- /dev/null +++ b/app/controllers/migration_controller.rb @@ -0,0 +1,20 @@ +class MigrationController < ApplicationController + skip_forgery_protection + + def show + @nav = default_nav + + render template: "migrate", layout: "homepage" + end + + def migrate + # Some request path rewriting for the compat server to slot in. + request.env["REQUEST_PATH"] = "/" + request.env["REQUEST_URI"] = "/" + request.env["PATH_INFO"] = "/" + + res = BK::Compat::Server.new.call(request.env) + + render body: res[2].string, status: res[0], content_type: res[1]["content-type"] + end +end diff --git a/app/models/nav.rb b/app/models/nav.rb index 7c74adda07..ddcba649b5 100644 --- a/app/models/nav.rb +++ b/app/models/nav.rb @@ -15,12 +15,7 @@ def current_item_root(request) # Returns the current nav item def current_item(request) - return nil if request.path == "/docs" - - item = route_map[request.path.sub("/docs/", "")] - raise ActionController::RoutingError.new("Missing navigation for #{request.path}") unless item - - item + route_map[request.path.sub("/docs/", "")] end # Returns a hash of routes, indexed by path diff --git a/app/views/migrate.html.erb b/app/views/migrate.html.erb new file mode 100644 index 0000000000..ab2369446c --- /dev/null +++ b/app/views/migrate.html.erb @@ -0,0 +1,175 @@ + + + +
+
+
+ + +
+
+ +
+
+
+ + diff --git a/config/initializers/migration.rb b/config/initializers/migration.rb new file mode 100644 index 0000000000..0756a728e5 --- /dev/null +++ b/config/initializers/migration.rb @@ -0,0 +1,2 @@ +require Rails.root.join('vendor/migration/app/lib/bk/compat').to_s +require Rails.root.join('vendor/migration/app/lib/bk/compat/server').to_s diff --git a/config/routes.rb b/config/routes.rb index 95b36f42df..020374fbcd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -143,6 +143,10 @@ # Homepage get "/docs" => "pages#index", as: :home_page + # Hosted migration/transform tool + get "/docs/migrate" => "migration#show" + post "/docs/migrate" => "migration#migrate", as: :migrate + # All other standard docs pages get "/docs/*path" => "pages#show", as: :docs_page diff --git a/vendor/migration b/vendor/migration new file mode 160000 index 0000000000..c9c42116eb --- /dev/null +++ b/vendor/migration @@ -0,0 +1 @@ +Subproject commit c9c42116eb9253b2a6d8d4e3674805c07b095205