Page MenuHomeDevCentral

D595.id1444.diff
No OneTemporary

D595.id1444.diff

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;
+
+/**
+ * Trigger for a 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,19 @@
+<?php
+
+namespace Keruald\DockerHub\Tests\Build;
+
+use Keruald\DockerHub\DockerHubImage;
+use Keruald\DockerHub\Build\TriggerBuild;
+
+class TriggerBuildTest extends \PHPUnit_Framework_TestCase {
+
+ public function testGetTriggerUrl () {
+ $image = new DockerHubImage("acme", "foo");
+ $trigger = new TriggerBuild($image, "0000");
+ $this->assertSame(
+ "https://registry.hub.docker.com/u/acme/foo/trigger/0000/",
+ $trigger->getTriggerUrl()
+ );
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 7, 01:37 (22 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2232480
Default Alt Text
D595.id1444.diff (1 KB)

Event Timeline