require 'auth' require 'config' require 'git_fusion' require 'hws_p4_cleanup' require 'hws_helpers' require 'hws_settings' require 'helix_sync' require 'helix_web_services/version' require 'helix_versioning_engine' require 'projects' require 'rack/parser' require 'sinatra/base' require 'sinatra/namespace' require 'P4' module HelixWebServices # A master Sinatra instance that basically sets up routing to each of the # sub-applications, and connects the authorization mechanism. # # In the future, we may have status and health check functionality available # here. # # We mount each application under a "versioned" subpath. This allows us to # keep an old and new version of a sub-application in the system at the # same time, ideally to allow for migration to breaking changes. class Master < Sinatra::Base register Sinatra::Namespace # Without this set, the return content type is always text/html before do content_type 'application/json' end # Inject Rack::Parser into the middleware stack so that it # automatically parses json bodies in post requests into the params # array. use Rack::Parser, content_types: { 'application/json' => proc { |body| ::MultiJson.decode body } } use HWSSettings use HWSP4Cleanup use Auth::Middleware, unauthenticated_paths: [ {method: 'POST', path: '/auth/v1/login'} ] @@handle_error = lambda do |env| err = env['sinatra.error'] puts "err #{err}" if err.is_a?(P4Exception) # Can happen when we're not passing a block to # open_p4. Convert to a P4WebAPI error. This is not ideal # as it always uses the same code, but then we have no idea # what actually happened here. err = P4Error.default_error(err.to_s) # Fall through... end if err.is_a?(P4Error) if err.message_code == 7480 || err.message_code == 7189 halt 401 else return { MessageCode: err.message_code, MessageSeverity: err.message_severity, MessageText: err.message_text }.to_json end end return { MessageCode: 15_361, MessageSeverity: P4::E_FATAL, MessageText: 'Unknown server issue' }.to_json end error do @@handle_error.call(env) end not_found do status 404 '' end class << self def register_app(app) use app app.before do content_type 'application/json' headers['X-Helix-Web-Services-Version'] = HelixWebServices::PRODUCT_ID end app.helpers HWSHelpers app.error do @@handle_error.call(env) end app.not_found do status 404 '' end end end get '/status' do {'status':'OK'}.to_json end register_app(Auth::App) register_app(Config::App) register_app(HelixVersioningEngine::App) register_app(Projects::App) register_app(GitFusion::App) register_app(HelixSync::App) end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#10 | 17271 | tjuricek | Remove deprecated Ruby implementation. | ||
#9 | 16294 | tjuricek | Correct symlink location to init.d script and set up call to update_rc.d for Ubuntu machines | ||
#8 | 16146 | tjuricek |
Allow custom middleware to be loaded right after settings are set up on the request via the .use_after_settings method. This will allow each implementation to devise their own rules for blocking requests. |
||
#7 | 16095 | tjuricek | Shorten /helix_versioning_engine URLs to /p4 | ||
#6 | 16094 | tjuricek |
Move /auth/v1/login -> /projects/v1/login The more generic login method is now /helix_versioning_engine/vAPI/login |
||
#5 | 16091 | tjuricek |
Alter Helix Sync client options and the 'latest pending changelist' query (via Alan Teague) The 'fetch pending changelist' method now requires that the changelist have the 'shelved' status. This is generally appropriate, but requires a bit more client usage, to make simple unit tests... kind of annoying actually. Since this function is used by some of the other Helix Sync workflow tests, I've just removed the smaller tests. |
||
#4 | 15969 | tjuricek |
Add support for repo creation/update and deletion, same for SSH keys. Add util module for supporting methods, modify temp client to dissapear. (Modified submit of review 15549 by @ptomiak) |
||
#3 | 15700 | tjuricek | Allow custom scripts to be loaded into the process in order to modify HWS or add some functionality. | ||
#2 | 15687 | tjuricek |
Associate 400 status codes for severity 3 exceptions and 500 for severity 4. We don't throw P4Exception for severity < 3 at the moment, since those are typically just warnings, like "you have no files in that directory". |
||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services/lib/helix_web_services.rb | |||||
#11 | 15600 | tjuricek | Add /status method back to verify that the user's session actually works. | ||
#10 | 15513 | tjuricek |
Add a product ID header for debugging purposes. This will generally display INVALID unless the version file has been created during the build. |
||
#9 | 15297 | tjuricek |
Implement of 'cluster services' configuration. The configuration will be stored in a local JSON file, which is expected to be maintained by the systems admin. Eventually, it's expected to have this sort of thing implemented via Helix Admin. |
||
#8 | 15242 | tjuricek | Add Helix Sync stubs and documentation | ||
#7 | 15241 | tjuricek | Add Git Fusion stubs and documentation. | ||
#6 | 15110 | tjuricek | Revise changes methods for new p4 connection handling, add server specs, remove model references in client, and update asciidoc documentation. | ||
#5 | 15099 | tjuricek | Revise project services to be our simple 'container' for other systems. | ||
#4 | 15077 | tjuricek |
Add new 'model' technique, revised branch spec operations, test Auth::Middleware. The Ruby client now does *not* strictly type anything, but extends OpenStruct with helper methods to help deal with inconsistent data formats. See the OpenModel class documentation for more details. The Auth::Middleware class is also *finally* implemented as well. This does not take into account all possible variations of server behavior (yet), but that will happen in follow-up work. |
||
#3 | 15032 | tjuricek |
Starting config and doc revisions. System is now broken while revisions underway. Configuration of the p4d connection is now done via a single HWSSettings middleware object injected into the Rack env. The HWSP4Cleanup middleware now cleans up any p4 injected into the Rack env. The Auth::App class now mostly just contains one method to generate a p4 ticket. /auth/v1/login. Added yard documentation for the main project. Yard docs have been reconfigured to dump into build/ directories. This should probably be done with each release. Hm... The top level rake file contains a task, 'all:doc', to update our documentation. This should probably be run for each checkin. Hm... Specs are now using Rack::Test on top of a 'live' p4d. I'd suggest you still use the p4util mechanism, which now dumps to a /tmp folder, so we can safely add P4IGNORE rules back into your local .p4config file. Old 'perforce' application now called 'helix_versioning_engine'. Removing cache data. Helix Sync may be slow. It may also get axed. We'll see. |
||
#2 | 13941 | tjuricek |
Re-implemented the sync project methods at the HTTP level. The Qt API is missing the "members" concept, but it's likely not quite usable just yet. It's existing logic does work, however. |
||
#1 | 13799 | tjuricek |
Start with branch specs hosting in a new monolithic 'helix web services' project. Converting from a microservice to a monolithic architecture due to resource constraints at getting a deployable system running. Additionally, since it's not expected that people will upgrade often, the major benefit of microservices - being able to add services individually without affecting others - is not really a major benefit. The Ruby SDK will be consolidated into a single 'helix web services client' project. It may end up being distributed via Rubygems. This only runs branch specs at the moment. I want to get a CD pipeline setup for the monolithic server before revising more methods. |