require 'sinatra/base' require 'sinatra/json' require 'hws_helpers' require 'projects/client_service' require 'sync/sync_project_service' module Sync class App < Sinatra::Base # Automatically parse content as JSON use Rack::Parser, content_types: { 'application/json' => proc { |body| ::MultiJson.decode body } } before do content_type 'application/json' end helpers HWSHelpers # configure do # set(:p4, 'host' => 'localhost', 'port' => '1666') # set(:token_path, '/tmp/perforce/tokens') # set(:workspace_folder, '/tmp/perforce/workspaces') # # # This is the URL that Helix Sync clients should use to connect to the # # project. Right now, it's only one server. # set :project_p4_url, 'p4://localhost:1666' # # # This should be an existing streams depot that users should have # # access to create streams under. # set :default_stream_depot, '//projects' # # set :metadata_depot, '//.projects' # # set :project_path_template, '//.projects/<%= project.id %>.json' # end get '/sync/v1/projects' do args = {} args[:members] = params['members'] if params.key?('members') projects = nil open_p4_as_user do |p4| sync_project_service = Sync::SyncProjectService.new(p4: p4, settings: settings) projects = sync_project_service.find(args) end projects.to_json end get '/sync/v1/projects/*' do project_id = params[:splat].join('/') project = nil open_p4_as_user do |p4| sync_project_service = Sync::SyncProjectService.new(p4: p4, settings: settings) project = sync_project_service.find_by_id(project_id) end project.to_json end post '/sync/v1/projects' do depotDir = params['depotDir'] project = HelixWebServicesClient::Models::Project.json_create(params) open_p4_temp_user_client(depot_paths) do |p4, root| sync_project_service = Sync::SyncProjectService.new( p4: p4, settings: settings, client_name: p4.client, client_root: root ) sync_project_service.create(project, depot_dir: depotDir) end project.to_json end patch '/sync/v1/projects/*' do project_id = params[:splat].join('/') project = HelixWebServicesClient::Models::Project.json_create(params) project.id = project_id open_p4_temp_user_client(depot_paths) do |p4, root| sync_project_service = Sync::SyncProjectService.new( p4: p4, settings: settings, client_name: p4.client, client_root: root ) sync_project_service.update(project) end project.to_json end # This will generate a new temporary client # # Expected parameters: # # - host # - root post '/sync/v1/clients/:project_id' do |project_id| host = params['host'] root = params['root'] client_name = nil open_p4_as_user do |p4| client_service = Projects::ClientService.new(p4: p4) client_name = client_service.create_workspace( project: project_id, hostname: host, root: root ) end { client_name: client_name }.to_json end get '/sync/v1/status' do '{}' end def depot_paths ["//#{settings.default_stream_depot}/...", "//#{settings.metadata_depot}/..."] end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 15098 | tjuricek |
Revised project services to GET-only forms. With Helix Sync revising to integrate purely with Helix Cloud, this is the only thing we can reasonably define. |
||
#8 | 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. |
||
#7 | 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. |
||
#6 | 14174 | tjuricek | Call the underlying service with a second named parameter, even if it's nil | ||
#5 | 14151 | tjuricek |
Add depot tree control and selection to the create projects page. Styling and error checking is kept to a minimum for the time being. Our goal is just internal workflow and feedback. |
||
#4 | 14049 | tjuricek |
Add methods to generate client workspaces for a user. The Qt SDK was updated based on immediate need. Also, add Ruby client SDK documentation to the docs site. Everything is early, but there's *some* reference available at least. |
||
#3 | 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. |
||
#2 | 13939 | tjuricek |
First pass at sync project service. Includes a first pass at validating projects enabled for Sync. (There's only one branch check at the moment.) Does not include the HTTP layer. |
||
#1 | 13839 | tjuricek |
Conversion of the p4_project_service microservice to new monolithic system. This may not have an HTTP front end in the monolithic system. Project services are really just about how the core object model is structured. It's likely that each application will add their own wrinkles and extensions to the system, so it's unlikely we'll need a generic "project model". Exactly how extensions are registered and used is still a bit TBD at the moment. Previously they were to be registered webhooks, that model may change. Does not include tests yet. |