Page MenuHomeDevCentral

D2965.id7559.diff
No OneTemporary

D2965.id7559.diff

diff --git a/app/Listeners/DockerHubListener.php b/app/Listeners/DockerHubListener.php
--- a/app/Listeners/DockerHubListener.php
+++ b/app/Listeners/DockerHubListener.php
@@ -28,15 +28,15 @@
/**
* Determines if the event should be notified to Docker Hub.
- * We're interested by push events, for repos with Docker images
- * we've a token to trigger a build.
+ * We're interested in push events, for repos with Docker images
+ * we've information to trigger a build.
*
* @param GitHubPayloadEvent $event The GitHub payload event
* @return bool
*/
public function shouldNotify (GitHubPayloadEvent $event) : bool {
return $event->event === 'push'
- && DockerHub::hasToken($this->getRepository($event));
+ && DockerHub::contains($this->getRepository($event));
}
/**
diff --git a/app/Providers/DockerHubServiceProvider.php b/app/Providers/DockerHubServiceProvider.php
--- a/app/Providers/DockerHubServiceProvider.php
+++ b/app/Providers/DockerHubServiceProvider.php
@@ -17,13 +17,13 @@
}
/**
- * Gets the tokens to trigger build for the Docker Hub images.
+ * Gets the UUIDs to trigger build for the Docker Hub images.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return array
*/
- public static function getTokens (Application $app) : array {
- $file = $app->make('config')->get('services.dockerhub.tokens');
+ public static function getTriggers (Application $app) : array {
+ $file = $app->make('config')->get('services.dockerhub.triggers');
$fs = $app->make('filesystem')->disk('local');
if ($fs->exists($file)) {
@@ -39,8 +39,8 @@
*/
public function register() : void {
$this->app->singleton('dockerhub', function (Application $app) {
- $tokens = DockerHubServiceProvider::getTokens($app);
- return new TriggerBuildFactory(new Client, $tokens);
+ $triggers = DockerHubServiceProvider::getTriggers($app);
+ return new TriggerBuildFactory(new Client, $triggers);
});
}
}
diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
"php": ">=8.1.0",
"laravel/framework": "^9.30.0",
"guzzlehttp/guzzle": "7.5.0",
- "keruald/dockerhub": "^0.1.0",
+ "keruald/dockerhub": "^1.0.0",
"keruald/github": "^0.2.1",
"keruald/broker": "^0.5.0",
"keruald/mailgun": "^0.1.0",
diff --git a/config/services.php b/config/services.php
--- a/config/services.php
+++ b/config/services.php
@@ -36,7 +36,7 @@
],
'dockerhub' => [
- 'tokens' => env('DOCKERHUB_TOKENS', 'DockerHubTokens.json')
+ 'triggers' => env('DOCKERHUB_TRIGGERS', 'DockerHubTriggers.json')
],
'github' => [
diff --git a/tests/Providers/DockerHubServiceProviderTest.php b/tests/Providers/DockerHubServiceProviderTest.php
--- a/tests/Providers/DockerHubServiceProviderTest.php
+++ b/tests/Providers/DockerHubServiceProviderTest.php
@@ -15,20 +15,25 @@
);
}
- public function testGetTokens () {
+ public function testGetTriggers () {
$this->assertSame(
- ['acme/foo' => '0000'],
- DockerHubServiceProvider::getTokens($this->app),
- "The service provider should deserialize DockerHubTokens.json."
+ [
+ 'acme/foo' => [
+ 'source' => '0000',
+ 'trigger' => '1234',
+ ],
+ ],
+ DockerHubServiceProvider::getTriggers($this->app),
+ "The service provider should deserialize DockerHubTriggers.json."
);
}
public function testGetTokensWhenFileDoesNotExist () {
- Config::set('services.dockerhub.tokens', 'notexisting.json');
+ Config::set('services.dockerhub.triggers', 'notexisting.json');
$this->assertSame(
[],
- DockerHubServiceProvider::getTokens($this->app),
+ DockerHubServiceProvider::getTriggers($this->app),
"When no tokens file exists, an empty array is used instead."
);
}
diff --git a/tests/data/DockerHubTokens.json b/tests/data/DockerHubTokens.json
deleted file mode 100644
--- a/tests/data/DockerHubTokens.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "acme/foo": "0000"
-}
diff --git a/tests/data/DockerHubTriggers.json b/tests/data/DockerHubTriggers.json
new file mode 100644
--- /dev/null
+++ b/tests/data/DockerHubTriggers.json
@@ -0,0 +1,6 @@
+{
+ "acme/foo": {
+ "source": "0000",
+ "trigger": "1234"
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 04:55 (1 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2258760
Default Alt Text
D2965.id7559.diff (4 KB)

Event Timeline