Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3782320
D595.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D595.diff
View Options
diff --git a/src/Build/TriggerBuild.php b/src/Build/TriggerBuild.php
new file mode 100644
--- /dev/null
+++ b/src/Build/TriggerBuild.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Keruald\DockerHub\Build;
+
+use Keruald\DockerHub\DockerHubImage as Image;
+
+/**
+ * this classe represents a trigger for a new build on the Docker Hub registry.
+ */
+class TriggerBuild {
+
+ ///
+ /// Private members
+ ///
+
+ /**
+ * The image to build
+ *
+ * @var Keruald\DockerHub\DockerHubImage
+ */
+ protected $image;
+
+ /**
+ * Trigger token used to authentify requests
+ *
+ * @var string
+ */
+ protected $token;
+
+ ///
+ /// Constructor
+ ///
+
+ /**
+ * Initializes a new instance of the TriggerBuild class.
+ *
+ * @param Keruald\DockerHub\DockerHubImage $image The image to build
+ * @param string $token The token to authentify the build request
+ */
+ public function __construct (Image $image, $token) {
+ $this->image = $image;
+ $this->token = $token;
+ }
+
+ ///
+ /// Helper methods
+ ///
+
+ /**
+ * Gets build trigger URL.
+ *
+ * @return string
+ */
+ public function getTriggerUrl () {
+ return $this->image->getRegistryUrl()
+ . '/trigger/' . $this->token . '/';
+ }
+
+}
diff --git a/tests/Build/TriggerBuildTest.php b/tests/Build/TriggerBuildTest.php
new file mode 100644
--- /dev/null
+++ b/tests/Build/TriggerBuildTest.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Keruald\DockerHub\Tests\Build;
+
+use Keruald\DockerHub\DockerHubImage;
+use Keruald\DockerHub\Build\TriggerBuild;
+
+class TriggerBuildTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var Keruald\DockerHub\Build\TriggerBuild
+ */
+ protected $trigger;
+
+ public function setUp () {
+ $image = new DockerHubImage("acme", "foo");
+ $this->trigger = new TriggerBuild($image, "0000");
+ }
+
+ public function testGetTriggerUrl () {
+ $this->assertSame(
+ "https://registry.hub.docker.com/u/acme/foo/trigger/0000/",
+ $this->trigger->getTriggerUrl()
+ );
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 00:03 (21 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2265292
Default Alt Text
D595.diff (2 KB)
Attached To
Mode
D595: Get build trigger URL
Attached
Detach File
Event Timeline
Log In to Comment