diff --git a/src/aaz_dev/command/api/_cmds.py b/src/aaz_dev/command/api/_cmds.py index c3c239f4..a8fbe86a 100644 --- a/src/aaz_dev/command/api/_cmds.py +++ b/src/aaz_dev/command/api/_cmds.py @@ -112,7 +112,7 @@ def generate_command_models_from_swagger(swagger_tag, workspace_path=None): "id": resource_id }) - mod_names = Config.DEFAULT_SWAGGER_MODULE.split('/') + mod_names = Config.DEFAULT_SWAGGER_MODULE ws = WorkspaceManager.new( name=Config.DEFAULT_SWAGGER_MODULE, plane=Config.DEFAULT_PLANE, diff --git a/src/aaz_dev/command/controller/workspace_manager.py b/src/aaz_dev/command/controller/workspace_manager.py index fd5f955f..3fef00fe 100644 --- a/src/aaz_dev/command/controller/workspace_manager.py +++ b/src/aaz_dev/command/controller/workspace_manager.py @@ -1055,10 +1055,12 @@ def generate_to_aaz(self): # Merge the commands of subresources which exported in aaz but not exist in current workspace self._merge_sub_resources_in_aaz() - # update client config - editor = self.load_client_cfg_editor() - if editor: - self.aaz_specs.update_client_cfg(editor.cfg) + # in memory worspace folder does not support client cfg + if not self.is_in_memory: + # update client config + editor = self.load_client_cfg_editor() + if editor: + self.aaz_specs.update_client_cfg(editor.cfg) # update configurations for ws_leaf in self.iter_command_tree_leaves(): diff --git a/src/aaz_dev/swagger/model/specs/_resource_provider.py b/src/aaz_dev/swagger/model/specs/_resource_provider.py index ce925954..144b6a30 100644 --- a/src/aaz_dev/swagger/model/specs/_resource_provider.py +++ b/src/aaz_dev/swagger/model/specs/_resource_provider.py @@ -86,7 +86,7 @@ def tags(self): self._tags = self._parse_readme_input_file_tags() return self._tags - def _parse_readme_input_file_tags(self): + def _parse_readme_input_file_tags_v0(self): tags = {} if not self._readme_paths: return tags @@ -133,6 +133,43 @@ def _parse_readme_input_file_tags(self): tags = OrderedDict(tags) return tags + def _parse_readme_input_file_tags(self): + tags = {} + if not self._readme_paths: + return tags + + for readme_path in self._readme_paths: + with open(readme_path, 'r', encoding='utf-8') as f: + readme = f.read() + + pattern = re.compile(r'```\s*yaml\s*\$\(\s*tag\s*\)\s*==\s*\'([^\']+)\'\s*input-file:\s*((?:\s*- [^\n]+\s*)+)\s*```', + flags=re.DOTALL) + for piece in pattern.finditer(readme): + tag = piece[1].strip() + input_files = piece[2].splitlines() + files = [] + for i_file in input_files: + file_path = i_file.strip().lstrip('-').strip() + file_path = file_path.replace('$(this-folder)/', '') + file_path = os.path.join(os.path.dirname(readme_path), *file_path.split('/')) + if not os.path.isfile(file_path): + logger.warning(f'FileNotExist: {self} : {file_path}') + continue + files.append(file_path) + + if len(files): + if tag is None: + tag = '' + tag = OpenAPIResourceProviderTag(tag.strip(), self) + if tag not in tags: + tags[tag] = set() + tags[tag] = tags[tag].union(files) + + tags = [*tags.items()] + tags.sort(key=lambda item: item[0].date, reverse=True) + tags = OrderedDict(tags) + return tags + def _fetch_latest_tag(self, file_path): for tag, file_set in self.tags.items(): if file_path in file_set: