podmanImageManager/image.php

93 lines
3.0 KiB
PHP
Raw Normal View History

2020-10-06 02:11:36 -04:00
<?php
namespace podmanImageManager;
use \objectStructs\objectStructs;
class image extends objectStructs
{
/** @var imageAnnotations */
public $annotations;
/** @var imageConfig */
public $config;
2020-12-07 16:50:41 -05:00
/** @var string name of hte image*/
public $imageName;
/** @var string name of image after the registry domain -- /image:latest */
public $shortName;
2020-10-06 02:11:36 -04:00
public function __construct($vars)
{
2020-12-17 22:31:41 -05:00
$this->Log(__FUNCTION__ . " load image object with: ".print_r($vars,true));
2020-12-01 21:31:19 -05:00
if (is_array($vars))
{
$this->imageName = (isset($vars['image']) ? $vars['image'] :
(isset($vars['name']) ? $vars['name'] :
(isset($vars['imageName']) ? $vars['imageName'] : "" ) ) ) ;
2020-12-07 16:50:41 -05:00
if (empty($this->imageName))
throw new \Exception(__FUNCTION__ . " Image name is empty");
list($RegistryDomain, $ImageShortName) = explode('/',$this->imageName,2);
if (!$ImageShortName)
throw new \Exception(__FUNCTION__ . " Image short name not valid");
else
$this->shortName = $ImageShortName;
2020-12-01 21:31:19 -05:00
if (isset( $vars['imageBasic']->annotations) )
$annotations = $vars['imageBasic']->annotations;
elseif (isset($vars['annotations']))
$annotations = $vars['annotations'];
2020-12-17 22:36:23 -05:00
else
$annotations = array();
2020-10-06 02:11:36 -04:00
$this->annotations = new imageAnnotations($annotations);
2020-12-01 21:31:19 -05:00
if (isset($vars['imageConfig']))
$this->config = new imageConfig($vars['imageConfig']);
}
elseif (is_object($vars))
{
$this->imageName = (isset($vars->image ) ? $vars->image :
(isset($vars->name) ? $vars->name :
(isset($vars->imageName) ? $vars->imageName : "" ) ) ) ;
if (isset( $vars->imageBasic->annotations) )
2020-12-02 21:38:24 -05:00
$this->annotations = new imageAnnotations($vars->imageBasic->annotations) ;
2020-12-02 21:41:13 -05:00
elseif (isset($vars->annotations))
$this->annotations = new imageAnnotations($vars->annotations) ;
2020-12-02 21:45:53 -05:00
if (isset($vars->imageConfig))
$this->config = new imageConfig($vars->imageConfig);
2020-12-01 21:31:19 -05:00
}
2020-10-06 02:11:36 -04:00
}
2020-11-29 16:04:45 -05:00
2020-11-29 16:05:10 -05:00
public function getHostControllerName()
2020-11-29 16:04:45 -05:00
{
if (isset($this->annotations->hostController))
return $this->annotations->hostController;
else
return false;
}
2020-11-29 16:05:10 -05:00
public function getClientControllerName()
2020-11-29 16:04:45 -05:00
{
if (isset($this->annotations->clientController))
return $this->annotations->clientController;
else
return false;
}
2020-12-04 21:13:35 -05:00
public function hasRole( string $Role)
{
2020-12-10 22:32:29 -05:00
$this->Log(__FUNCTION__ . "Checking Role: $Role");
if (isset($this->annotations->roles[$Role]) OR isset($this->annotations->roles[ucfirst($Role) ] ) )
{
$this->Log(__FUNCTION__ . "--Image has role: $Role");
2020-12-04 21:13:35 -05:00
return true;
2020-12-10 22:32:29 -05:00
}
2020-12-04 21:13:35 -05:00
else
return false;
}
2020-10-06 02:11:36 -04:00
}