Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix autogen cmd #444

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/aaz_dev/command/api/_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions src/aaz_dev/command/controller/workspace_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
39 changes: 38 additions & 1 deletion src/aaz_dev/swagger/model/specs/_resource_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clean up the un used code

tags = {}
if not self._readme_paths:
return tags
Expand Down Expand Up @@ -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:
Expand Down