Skip to content

Commit

Permalink
Merge pull request #423 from keboola/odin-remove-private-registry
Browse files Browse the repository at this point in the history
remove support for private registries
  • Loading branch information
odinuv authored May 9, 2019
2 parents ac1c9ba + d5e6f7e commit 3f241bf
Showing 13 changed files with 54 additions and 733 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -10,4 +10,5 @@ config.php
/parameters.yml
/error.log
/parameters_shared.yml

/.env
/docker-tests/.env
8 changes: 4 additions & 4 deletions Tests/Docker/ComponentTest.php
Original file line number Diff line number Diff line change
@@ -208,18 +208,18 @@ public function testInvalidRepository()
'data' => [
'definition' => [
'type' => 'builder',
'uri' => 'keboolaprivatetest/docker-demo-docker',
'uri' => '147946154733.dkr.ecr.us-east-1.amazonaws.com/developer-portal-v2/docker-demo',
'build_options' => [
'parent_type' => 'dockerhub-private',
'parent_type' => 'aws-ecr',
'repository' => [
'uri' => 'https://github.com/keboola/docker-demo-app',
'type' => 'fooBar',
],
'commands' => [
'composer install'
'composer install',
],
'entry_point' => 'php /home/run.php --data=/data',
]
],
],
],
]);
84 changes: 0 additions & 84 deletions Tests/Docker/Image/DockerHubPrivateRepositoryTest.php

This file was deleted.

140 changes: 0 additions & 140 deletions Tests/Docker/Image/ImageBuilderTest.php
Original file line number Diff line number Diff line change
@@ -101,146 +101,6 @@ public function testCreatePublicRepo()
self::assertEquals($oldCount + 1, trim($process->getOutput()));
}


public function testCreatePublicRepoWithTag()
{
$process = new Process('sudo docker images | grep builder- | wc -l');
$process->run();
$oldCount = intval(trim($process->getOutput()));

$process = new Process('sudo docker images quay.io/keboola/docker-custom-php:1.1.0 | grep docker-custom-php | wc -l');
$process->run();
if (trim($process->getOutput() != 0)) {
(new Process('sudo docker rmi quay.io/keboola/docker-custom-php:1.1.0'))->mustRun();
}

$imageConfig = new Component([
'data' => [
'definition' => [
'type' => 'builder',
'uri' => 'keboola/docker-custom-php',
'tag' => '1.1.0',
'build_options' => [
'parent_type' => 'quayio',
'repository' => [
'uri' => 'https://github.com/keboola/docker-demo-app',
'type' => 'git',
],
'commands' => [
'git clone --depth 1 {{repository}} /home/' .
' || (echo \'KBC::USER_ERR:Cannot access the repository.KBC::USER_ERR\' && exit 1)',
'cd /home/',
'composer install',
],
'entry_point' => 'php /home/run.php --data=/data',
],
],
],
]);

$image = ImageFactory::getImage($this->getEncryptor(), new NullLogger(), $imageConfig, new Temp(), true);
$image->prepare([]);
self::assertContains('builder-', $image->getFullImageId());

$process = new Process('sudo docker images | grep builder- | wc -l');
$process->run();
self::assertEquals($oldCount + 1, trim($process->getOutput()));

$process = new Process('sudo docker images quay.io/keboola/docker-custom-php:1.1.0 | grep docker-custom-php | wc -l');
$process->run();
self::assertEquals(1, trim($process->getOutput()));
}

public function testCreatePrivateRepoPrivateHub()
{
$process = new Process('sudo docker images | grep builder- | wc -l');
$process->run();
$oldCount = intval(trim($process->getOutput()));

$imageConfig = new Component([
'data' => [
'definition' => [
'type' => 'builder',
'uri' => 'keboolaprivatetest/docker-demo-docker',
'repository' => [
'#password' => $this->getEncryptor()->encrypt(DOCKERHUB_PRIVATE_PASSWORD),
'username' => DOCKERHUB_PRIVATE_USERNAME,
'server' => DOCKERHUB_PRIVATE_SERVER,
],
'build_options' => [
'parent_type' => 'dockerhub-private',
'repository' => [
'uri' => 'https://github.com/keboola/docker-demo-app',
'type' => 'git',
'#password' => $this->getEncryptor()->encrypt(GIT_PRIVATE_PASSWORD),
'username' => GIT_PRIVATE_USERNAME,
],
'commands' => [
// use other directory than home, that is already used by docker-demo-docker
'git clone --depth 1 {{repository}} /home/src2/' .
' || (echo \'KBC::USER_ERR:Cannot access the repository.KBC::USER_ERR\' && exit 1)',
'cd /home/src2/ && composer install',
],
'entry_point' => 'php /home/src2/run.php --data=/data',
],
],
],
]);

$image = ImageFactory::getImage($this->getEncryptor(), new NullLogger(), $imageConfig, new Temp(), true);
$image->prepare([]);
self::assertContains('builder-', $image->getFullImageId());

$process = new Process('sudo docker images | grep builder- | wc -l');
$process->run();
self::assertEquals($oldCount + 1, trim($process->getOutput()));
}

public function testCreatePrivateRepoPrivateHubMissingCredentials()
{
// remove image from cache
$process = new Process('sudo docker rmi -f keboolaprivatetest/docker-demo-docker');
$process->run();

$imageConfig = new Component([
'data' => [
'definition' => [
'type' => 'builder',
'uri' => 'keboolaprivatetest/docker-demo-docker',
'repository' => [
'server' => DOCKERHUB_PRIVATE_SERVER,
],
'build_options' => [
'parent_type' => 'dockerhub-private',
'repository' => [
'uri' => 'https://github.com/keboola/docker-demo-app',
'type' => 'git',
'#password' => $this->getEncryptor()->encrypt(GIT_PRIVATE_PASSWORD),
'username' => GIT_PRIVATE_USERNAME,
],
'commands' => [
// use other directory than home, that is already used by docker-demo-docker
'git clone --depth 1 {{repository}} /home/src2/' .
' || (echo \'KBC::USER_ERR:Cannot access the repository.KBC::USER_ERR\' && exit 1)',
'cd /home/src2/',
'composer install',
],
'entry_point' => 'php /home/src2/run.php --data=/data',
],
],
],
]);

$image = ImageFactory::getImage($this->getEncryptor(), new NullLogger(), $imageConfig, new Temp(), true);
$image->setRetryLimits(100, 100, 1);
try {
$image->prepare([]);
$this->fail('Building from private image without login should fail');
} catch (BuildException $e) {
self::assertContains('Failed to pull parent image', $e->getMessage());
}
}

public function testCreatePrivateRepoMissingPassword()
{
$imageConfig = new Component([
Loading

0 comments on commit 3f241bf

Please sign in to comment.