1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Generate expected schemata for Harbormaster

Summary:
Ref T1191. Nothing too notable here:

  - Allow a Lisk object to specify that there's no expectation that a table exists. We have one Harbormaster object and one Token object like this.
  - Removed BuildPlanTransactionComment because it's currently unused.

Test Plan:
  - Saw ~200 fewer warnings; just ~800 left.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1191

Differential Revision: https://secure.phabricator.com/D10583
This commit is contained in:
epriestley 2014-10-01 07:40:36 -07:00
parent 152a62db7a
commit e7b590a1cf
19 changed files with 192 additions and 19 deletions

View file

@ -710,7 +710,6 @@ phutil_register_library_map(array(
'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php',
'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php',
'HarbormasterBuildPlanTransaction' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransaction.php',
'HarbormasterBuildPlanTransactionComment' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransactionComment.php',
'HarbormasterBuildPlanTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanTransactionQuery.php',
'HarbormasterBuildQuery' => 'applications/harbormaster/query/HarbormasterBuildQuery.php',
'HarbormasterBuildStep' => 'applications/harbormaster/storage/configuration/HarbormasterBuildStep.php',
@ -762,6 +761,7 @@ phutil_register_library_map(array(
'HarbormasterQueryBuildablesConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterQueryBuildablesConduitAPIMethod.php',
'HarbormasterQueryBuildsConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php',
'HarbormasterRemarkupRule' => 'applications/harbormaster/remarkup/HarbormasterRemarkupRule.php',
'HarbormasterSchemaSpec' => 'applications/harbormaster/storage/HarbormasterSchemaSpec.php',
'HarbormasterScratchTable' => 'applications/harbormaster/storage/HarbormasterScratchTable.php',
'HarbormasterSendMessageConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterSendMessageConduitAPIMethod.php',
'HarbormasterSleepBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterSleepBuildStepImplementation.php',
@ -3585,7 +3585,6 @@ phutil_register_library_map(array(
'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine',
'HarbormasterBuildPlanTransaction' => 'PhabricatorApplicationTransaction',
'HarbormasterBuildPlanTransactionComment' => 'PhabricatorApplicationTransactionComment',
'HarbormasterBuildPlanTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'HarbormasterBuildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'HarbormasterBuildStep' => array(
@ -3649,6 +3648,7 @@ phutil_register_library_map(array(
'HarbormasterQueryBuildablesConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
'HarbormasterQueryBuildsConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
'HarbormasterRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'HarbormasterSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'HarbormasterScratchTable' => 'HarbormasterDAO',
'HarbormasterSendMessageConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
'HarbormasterSleepBuildStepImplementation' => 'HarbormasterBuildStepImplementation',

View file

@ -42,6 +42,9 @@ abstract class PhabricatorConfigSchemaSpec extends Phobject {
->loadObjects();
foreach ($objects as $object) {
if ($object->getConfigOption(LiskDAO::CONFIG_NO_TABLE)) {
continue;
}
$this->buildLiskObjectSchema($object);
}
}

View file

@ -10,4 +10,17 @@ final class HarbormasterBuildCommand extends HarbormasterDAO {
protected $targetPHID;
protected $command;
public function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'command' => 'text128',
),
self::CONFIG_KEY_SCHEMA => array(
'key_target' => array(
'columns' => array('targetPHID'),
),
),
) + parent::getConfiguration();
}
}

View file

@ -22,6 +22,20 @@ final class HarbormasterBuildMessage extends HarbormasterDAO
->setIsConsumed(0);
}
public function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'type' => 'text16',
'isConsumed' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
'key_buildtarget' => array(
'columns' => array('buildTargetPHID'),
),
),
) + parent::getConfiguration();
}
public function getBuildTarget() {
return $this->assertAttached($this->buildTarget);
}

View file

@ -155,6 +155,22 @@ final class HarbormasterBuildable extends HarbormasterDAO
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'containerPHID' => 'phid?',
'buildableStatus' => 'text32',
'isManualBuildable' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
'key_buildable' => array(
'columns' => array('buildablePHID'),
),
'key_container' => array(
'columns' => array('containerPHID'),
),
'key_manual' => array(
'columns' => array('isManualBuildable'),
),
),
) + parent::getConfiguration();
}

View file

@ -2,12 +2,14 @@
final class HarbormasterObject extends HarbormasterDAO {
protected $phid;
protected $name;
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
),
) + parent::getConfiguration();
}

View file

@ -0,0 +1,45 @@
<?php
final class HarbormasterSchemaSpec extends PhabricatorConfigSchemaSpec {
public function buildSchemata() {
$this->buildLiskSchemata('HarbormasterDAO');
$this->buildEdgeSchemata(new HarbormasterBuildable());
$this->buildCounterSchema(new HarbormasterBuildable());
$this->buildTransactionSchema(
new HarbormasterBuildableTransaction());
$this->buildTransactionSchema(
new HarbormasterBuildTransaction());
$this->buildTransactionSchema(
new HarbormasterBuildPlanTransaction());
$this->buildTransactionSchema(
new HarbormasterBuildStepTransaction());
$this->buildRawSchema(
id(new HarbormasterBuildable())->getApplicationName(),
'harbormaster_buildlogchunk',
array(
'id' => 'id',
'logID' => 'id',
'encoding' => 'text32',
'size' => 'uint32',
'chunk' => 'bytes',
),
array(
'PRIMARY' => array(
'columns' => array('id'),
'unique' => true,
),
'key_log' => array(
'columns' => array('logID'),
),
));
}
}

View file

@ -11,4 +11,18 @@ final class HarbormasterScratchTable extends HarbormasterDAO {
protected $data;
protected $bigData;
public function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'data' => 'text64',
'bigData' => 'text?',
),
self::CONFIG_KEY_SCHEMA => array(
'data' => array(
'columns' => array('data'),
),
),
) + parent::getConfiguration();
}
}

View file

@ -143,6 +143,21 @@ final class HarbormasterBuild extends HarbormasterDAO
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'buildStatus' => 'text32',
'buildGeneration' => 'uint32',
),
self::CONFIG_KEY_SCHEMA => array(
'key_buildable' => array(
'columns' => array('buildablePHID'),
),
'key_plan' => array(
'columns' => array('buildPlanPHID'),
),
'key_status' => array(
'columns' => array('buildStatus'),
),
),
) + parent::getConfiguration();
}

View file

@ -26,6 +26,20 @@ final class HarbormasterBuildArtifact extends HarbormasterDAO
self::CONFIG_SERIALIZATION => array(
'artifactData' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'artifactType' => 'text32',
'artifactIndex' => 'bytes12',
'artifactKey' => 'text255',
),
self::CONFIG_KEY_SCHEMA => array(
'key_artifact' => array(
'columns' => array('artifactType', 'artifactIndex'),
'unique' => true,
),
'key_garbagecollect' => array(
'columns' => array('artifactType', 'dateCreated'),
),
),
) + parent::getConfiguration();
}

View file

@ -7,6 +7,7 @@ final class HarbormasterBuildItem extends HarbormasterDAO {
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_NO_TABLE => true,
) + parent::getConfiguration();
}

View file

@ -30,6 +30,17 @@ final class HarbormasterBuildLog extends HarbormasterDAO
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'logSource' => 'text255',
'logType' => 'text255',
'duration' => 'uint32',
'live' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
'key_buildtarget' => array(
'columns' => array('buildTargetPHID'),
),
),
) + parent::getConfiguration();
}

View file

@ -99,7 +99,20 @@ final class HarbormasterBuildTarget extends HarbormasterDAO
self::CONFIG_SERIALIZATION => array(
'details' => self::SERIALIZATION_JSON,
'variables' => self::SERIALIZATION_JSON,
)
),
self::CONFIG_COLUMN_SCHEMA => array(
'className' => 'text255',
'targetStatus' => 'text64',
'name' => 'text255',
'dateStarted' => 'epoch?',
'dateCompleted' => 'epoch?',
'buildGeneration' => 'uint32',
),
self::CONFIG_KEY_SCHEMA => array(
'key_build' => array(
'columns' => array('buildPHID', 'buildStepPHID'),
),
),
) + parent::getConfiguration();
}

View file

@ -21,6 +21,15 @@ final class HarbormasterBuildPlan extends HarbormasterDAO
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'planStatus' => 'text32',
),
self::CONFIG_KEY_SCHEMA => array(
'key_status' => array(
'columns' => array('planStatus'),
),
),
) + parent::getConfiguration();
}

View file

@ -14,10 +14,6 @@ final class HarbormasterBuildPlanTransaction
return HarbormasterBuildPlanPHIDType::TYPECONST;
}
public function getApplicationTransactionCommentObject() {
return new HarbormasterBuildPlanTransactionComment();
}
public function getIcon() {
$old = $this->getOldValue();
$new = $this->getNewValue();

View file

@ -1,10 +0,0 @@
<?php
final class HarbormasterBuildPlanTransactionComment
extends PhabricatorApplicationTransactionComment {
public function getApplicationTransactionObject() {
return new HarbormasterBuildPlan();
}
}

View file

@ -25,7 +25,18 @@ final class HarbormasterBuildStep extends HarbormasterDAO
self::CONFIG_AUX_PHID => true,
self::CONFIG_SERIALIZATION => array(
'details' => self::SERIALIZATION_JSON,
)
),
self::CONFIG_COLUMN_SCHEMA => array(
'className' => 'text255',
'sequence' => 'uint32',
'name' => 'text255',
'description' => 'text',
),
self::CONFIG_KEY_SCHEMA => array(
'key_plan' => array(
'columns' => array('buildPlanPHID'),
),
),
) + parent::getConfiguration();
}

View file

@ -10,6 +10,7 @@ final class PhabricatorToken extends PhabricatorTokenDAO
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_NO_TABLE => true,
) + parent::getConfiguration();
}

View file

@ -171,6 +171,7 @@ abstract class LiskDAO {
const CONFIG_BINARY = 'binary';
const CONFIG_COLUMN_SCHEMA = 'col-schema';
const CONFIG_KEY_SCHEMA = 'key-schema';
const CONFIG_NO_TABLE = 'no-table';
const SERIALIZATION_NONE = 'id';
const SERIALIZATION_JSON = 'json';
@ -351,6 +352,10 @@ abstract class LiskDAO {
* CONFIG_KEY_SCHEMA
* Provide a map of key names to key specifications.
*
* CONFIG_NO_TABLE
* Allows you to specify that this object does not actually have a table in
* the database.
*
* @return dictionary Map of configuration options to values.
*
* @task config