Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/step/HarbormasterUploadArtifactBuildStepImplementation.php
12256 views
1
<?php
2
3
final class HarbormasterUploadArtifactBuildStepImplementation
4
extends HarbormasterBuildStepImplementation {
5
6
public function getName() {
7
return pht('Upload File');
8
}
9
10
public function getGenericDescription() {
11
return pht('Upload a file.');
12
}
13
14
public function getBuildStepGroupKey() {
15
return HarbormasterPrototypeBuildStepGroup::GROUPKEY;
16
}
17
18
public function getDescription() {
19
return pht(
20
'Upload %s from %s.',
21
$this->formatSettingForDescription('path'),
22
$this->formatSettingForDescription('hostartifact'));
23
}
24
25
public function execute(
26
HarbormasterBuild $build,
27
HarbormasterBuildTarget $build_target) {
28
$viewer = PhabricatorUser::getOmnipotentUser();
29
30
$settings = $this->getSettings();
31
$variables = $build_target->getVariables();
32
33
$path = $this->mergeVariables(
34
'vsprintf',
35
$settings['path'],
36
$variables);
37
38
$artifact = $build_target->loadArtifact($settings['hostartifact']);
39
$impl = $artifact->getArtifactImplementation();
40
$lease = $impl->loadArtifactLease($viewer);
41
42
$interface = $lease->getInterface('filesystem');
43
44
// TODO: Handle exceptions.
45
$file = $interface->saveFile($path, $settings['name']);
46
47
// Insert the artifact record.
48
$artifact = $build_target->createArtifact(
49
$viewer,
50
$settings['name'],
51
HarbormasterFileArtifact::ARTIFACTCONST,
52
array(
53
'filePHID' => $file->getPHID(),
54
));
55
}
56
57
public function getArtifactInputs() {
58
return array(
59
array(
60
'name' => pht('Upload From Host'),
61
'key' => $this->getSetting('hostartifact'),
62
'type' => HarbormasterHostArtifact::ARTIFACTCONST,
63
),
64
);
65
}
66
67
public function getArtifactOutputs() {
68
return array(
69
array(
70
'name' => pht('Uploaded File'),
71
'key' => $this->getSetting('name'),
72
'type' => HarbormasterHostArtifact::ARTIFACTCONST,
73
),
74
);
75
}
76
77
public function getFieldSpecifications() {
78
return array(
79
'path' => array(
80
'name' => pht('Path'),
81
'type' => 'text',
82
'required' => true,
83
),
84
'name' => array(
85
'name' => pht('Local Name'),
86
'type' => 'text',
87
'required' => true,
88
),
89
'hostartifact' => array(
90
'name' => pht('Host Artifact'),
91
'type' => 'text',
92
'required' => true,
93
),
94
);
95
}
96
97
}
98
99