<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>Initializer for Perforce Servers</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <meta name="keywords" content=""> <meta name="generator" content"JBake"> <!-- Le styles --> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/asciidoctor.css" rel="stylesheet"> <link href="css/base.css" rel="stylesheet"> <link href="css/bootstrap-responsive.min.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="js/html5shiv.js"></script> <![endif]--> <!-- Fav and touch icons --> <!--<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">--> <link rel="shortcut icon" href="favicon.ico"> </head> <body> <div id="wrap"> <nav class="navbar navbar-default" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <ul class="nav navbar-nav"> <li><a href="index.html">Initializer</a></li> <li><a href="overview.html">Overview</a></li> <li><a href="data.html">Data</a></li> <li><a href="../javadoc/index.html">Javadoc</a></li> </ul> </div> </div> </nav> <div class="container"> <h1>Initializer Data</h1><p>The initializer is intended to be driven by data checked into a directory tree that probably looks something like this:</p> <pre><code>data/ 0001_user_superuser.json 0002_user_jdoe.json 0010_depot_commons.json 0020_trigger_commons-protection-updater.json 0200_changelist_some_files.json 0201_changelist_project_bar.json files/ foo.txt bar.doc </code></pre><p>The following conventions should be observed:</p> <ol> <li><p>The files read by the initializer are all in a directory, and end with the file extension <code>.json</code></p></li> <li><p>The test data files are either in the same directory, or in a sub directory.</p></li> <li><p>Create all your users first, and make sure the first user is a super user.</p></li> </ol><p>Note that with Java-based integration, you have a lot more flexibility, since you determine the resource loader yourself. For command line usage, you'll need to basically organize everything into a single tree location like the one above.</p><h2>JSON Metadata Types</h2><p>Currently, we only have these kinds of top level operations we define in each JSON file:</p> <ul> <li><code>perforceChangelist</code> Create a changelist (currently just adds and edits)</li> <li><code>perforceUser</code> Create a user</li> <li><code>perforceClient</code> Create a client (you might not need this, read about temporary clients later)</li> <li><code>perforceDepot</code> Create a depot</li> <li><code>perforceTrigger</code> Create a trigger</li> </ul><p>Each JSON file starts with a <code>rank</code> property that's used to order each file with each other. (Out of convention, I've used this rank in a zero-padded string to let my directory list resemble the order the files will be read in.)</p><h4>Temporary Clients</h4><p>Each user will get a client just for the initialization run named <code>initializer-LOGIN</code>, e.g., <code>initializer-jdoe</code> for the login <code>jdoe</code>. Just reference this client by name in the JSON file to add files using this client. These clients should only exist during the initialization run; they should be deleted at the end of the run.</p><p>The clients you create directly using JSON files will stay around after the initialization run. This isn't widely used yet, so chances are you'll want to add features to really make use of them.</p><h2>Changelist JSON</h2><p>Here's an example that adds a file:</p> <pre><code>{ "rank": 10, "perforceChangelist": { "login": "dumbo", "client": "initializer-dumbo", "description": "Just checkin things out", "adds": [ { "clientPath": "dev/main/wat.txt", "resource": "stuff/wat.txt" } ] } } </code></pre><p>Here's an example that edits the file in the next changelist:</p> <pre><code>{ "rank": 11, "perforceChangelist": { "login": "dumbo", "client": "initializer-dumbo", "description": "Just editing things", "edits": [ { "clientPath": "dev/main/wat.txt", "resource": "stuff/wat2.txt" } ] } } </code></pre><h2>User JSON</h2><p>The first user should always be a super user. The user would look like this:</p> <pre><code>{ "rank": 1, "perforceUser": { "login": "super", "email": "super@example.com", "password": "superduper1A", "name": "Super Duper", "super": true } } </code></pre><p>Additional (normal) users should just not include the <code>super</code> property.</p> <pre><code>{ "rank": 2, "perforceUser": { "login": "dumbo", "email": "dumbo@example.com", "password": "dumbodumbo1A", "name": "Dumbo McFly" } } </code></pre><p>You can also create <code>admin</code> users, which will be given admin access in the protects table:</p> <pre><code>{ "rank": 3, "perforceUser": { "login": "boss", "email": "boss@example.com", "password": "bosswoman1A", "name": "Boss Woman", "admin": true } } </code></pre><p>Finally, you can create <code>guest</code> users, which will be given <code>list</code> access in protects:</p> <pre><code>{ "rank": 4, "perforceUser": { "login": "guest", "email": "guest@example.com", "password": "guestuser1A", "name": "Guest User", "guest": true } } </code></pre><h2>Client JSON</h2><p>Here's an example of creating a client that should hang around:</p> <pre><code>{ "rank": 10, "perforceClient": { "name": "dumbo-client", "root": "/an/existing/directory", "owner": "dumbo", "description": "Dumbo's awesome client" "host": "myhost", "view": [ [ "//depot/...", "//dumbo-client/..." ] ] } } </code></pre><p>This feature isn't used frequently, most client management is done via test frameworks.</p><h2>Depot JSON</h2><p>Creating a depot is one of the first things done when setting up an instance:</p> <pre><code>{ "rank": 10, "perforceDepot": { "name": "commons" } } </code></pre><h2>Trigger JSON</h2><p>Here's one of the trigger scripts:</p> <pre><code>{ "rank": 20, "perforceTrigger": { "bash": "templates/commons_protection_updater.sh", "batch": "templates/commons_protection_updater.bat", "triggerLines": [ { "name": "CommonsProtectionUpdater", "type": "form-save", "path": "group", "command": "{_{command}} %formname% %user%" } ] } } </code></pre><p>The <code>bash</code> and <code>batch</code> conventions are currently used for Unix vs Windows variations. If you don't run on windows, just don't include the <code>batch</code> variation.</p> </div> </div><!-- #wrap --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="js/jquery-1.11.1.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/run_prettify.js"></script> </body> </html>