def __init__(self, resources_info: Dict) -> None: super().__init__(resources_info.get('lambda', {})) self.resources_info = resources_info self.function = resources_info.get('lambda', {}) self.supervisor_version = resources_info.get('lambda').get('supervisor').get('version') if (self.function.get('runtime') == "image" and StrUtils.compare_versions(self.supervisor_version, "1.5.0b3") < 0): # In case of using image runtime # it must be 1.5.0-beta3 version or higher raise Exception("Supervisor version must be 1.5.0 or higher for image runtime.")
def check_faas_supervisor_layer(self): """Checks if the supervisor layer exists, if not, creates the layer. If the layer exists and it's not updated, updates the layer.""" # Get the layer information layer_info = self.layer.get_latest_layer_info( self._SUPERVISOR_LAYER_NAME) # Compare supervisor versions if layer_info and 'Description' in layer_info: # If the supervisor layer version is lower than the passed version, # we must update the layer if StrUtils.compare_versions(layer_info.get('Description', ''), self.supervisor_version) < 0: self._update_supervisor_layer() else: logger.info("Using existent 'faas-supervisor' layer") else: # Layer not found, we have to create it self._create_supervisor_layer()
def _is_config_file_updated(self): if 'config_version' not in self.cfg_data['scar']: return False return StrUtils.compare_versions( self.cfg_data.get('scar', {}).get("config_version", ""), _DEFAULT_CFG['scar']["config_version"]) >= 0