Skip to content

Commit

Permalink
add image_tag to containers definition
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L <szaimen@e.mail.de>
  • Loading branch information
szaimen committed Aug 17, 2023
1 parent 2cf6c74 commit c69a5d2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions php/containers-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
"pattern": "^[A-Z_]+$"
}
},
"image_tag": {
"type": "string",
"pattern": "^[a-z0-9.-]+$"
},
"devices": {
"type": "array",
"items": {
Expand Down
7 changes: 7 additions & 0 deletions php/src/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Container {
private bool $readOnlyRootFs;
private array $tmpfs;
private bool $init;
private string $imageTag;
private DockerActionManager $dockerActionManager;

public function __construct(
Expand All @@ -56,6 +57,7 @@ public function __construct(
bool $readOnlyRootFs,
array $tmpfs,
bool $init,
string $imageTag,
DockerActionManager $dockerActionManager
) {
$this->identifier = $identifier;
Expand All @@ -78,6 +80,7 @@ public function __construct(
$this->readOnlyRootFs = $readOnlyRootFs;
$this->tmpfs = $tmpfs;
$this->init = $init;
$this->imageTag = $imageTag;
$this->dockerActionManager = $dockerActionManager;
}

Expand All @@ -97,6 +100,10 @@ public function GetRestartPolicy() : string {
return $this->restartPolicy;
}

public function GetImageTag() : string {
return $this->imageTag;
}

public function GetReadOnlySetting() : bool {
return $this->readOnlyRootFs;
}
Expand Down
6 changes: 6 additions & 0 deletions php/src/ContainerDefinitionFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ private function GetDefinition(bool $latest): array
$init = $entry['init'];
}

$imageTag = '';
if (isset($entry['image_tag'])) {
$imageTag = $entry['image_tag'];
}

$containers[] = new Container(
$entry['container_name'],
$displayName,
Expand All @@ -298,6 +303,7 @@ private function GetDefinition(bool $latest): array
$readOnlyRootFs,
$tmpfs,
$init,
$imageTag,
$this->container->get(DockerActionManager::class)
);
}
Expand Down
11 changes: 9 additions & 2 deletions php/src/Docker/DockerActionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ private function BuildApiUrl(string $url) : string {
}

private function BuildImageName(Container $container) : string {
return $container->GetContainerName() . ':' . $this->GetCurrentChannel();
$tag = $container->GetImageTag();
if ($tag === '') {
$tag = $this->GetCurrentChannel();
}
return $container->GetContainerName() . ':' . $tag;
}

public function GetContainerRunningState(Container $container) : IContainerState
Expand Down Expand Up @@ -95,7 +99,10 @@ public function GetContainerRestartingState(Container $container) : IContainerSt

public function GetContainerUpdateState(Container $container) : IContainerState
{
$tag = $this->GetCurrentChannel();
$tag = $container->GetImageTag();
if ($tag === '') {
$tag = $this->GetCurrentChannel();
}

$runningDigests = $this->GetRepoDigestsOfContainer($container->GetIdentifier());
if ($runningDigests === null) {
Expand Down

0 comments on commit c69a5d2

Please sign in to comment.