next updates

This commit is contained in:
Artem Goncharov 2022-08-23 09:29:16 +02:00
parent 2ff9eeca27
commit 5f3eaf843e
3 changed files with 109 additions and 7 deletions

View File

@ -137,7 +137,7 @@ documents:
- html_location: docs/gaussdb_nosql/umn
pdf_name: gauss_nosql
rst_location: umn/source
service_type: gauss_nosql
service_type: gaussdb_nosql
title: User Guide
- html_location: docs/opengauss/umn
pdf_name: opengauss-umn
@ -652,7 +652,10 @@ services:
service_category: compute
service_title: Dedicated Host
service_type: deh
- repositories:
- assignees:
- environment: internal
names: ["docs-compute-ro"]
repositories:
- repo: docs/elastic-cloud-server
type: gitea
environment: internal
@ -749,7 +752,7 @@ services:
type: gitea
service_category: md
service_title: Cloud Trace Service
service_type: ces
service_type: cts
- repositories:
- environment: internal
repo: docs/identity-access-management
@ -819,7 +822,7 @@ services:
type: gitea
service_category: network
service_title: NAT Gateway
service_type: nat
service_type: natgw
- repositories:
- environment: internal
repo: docs/private-link-access-service
@ -890,7 +893,7 @@ services:
type: gitea
service_category: security
service_title: Dedicated Web Application Firewall
service_type: waf
service_type: wafd
- repositories:
- environment: internal
repo: docs/cloud-backup-recovery

View File

@ -75,7 +75,7 @@ class Services(object):
res.append(copy.deepcopy(srv))
return res
def docs_by_service_category(self, category, env=None):
def docs_by_service_category(self, category, environment=None):
"""List services matching category
:param str category: Category name
@ -91,11 +91,31 @@ class Services(object):
res_doc.update(**service)
if env:
for srv_env in service["repositories"]:
if srv_env.get("env") == env:
if srv_env.get("environment") == environment:
res_doc["repository"] = srv_env["repo"]
res.append(res_doc)
return res
def all_docs_full(self, environment):
"""Return list or documents with full service data
"""
services = self.service_dict
for doc in self.all_docs:
if not doc["service_type"] in services:
print(f"No service type {doc['service_type']}")
continue
service = services[doc["service_type"]]
res_doc = copy.deepcopy(doc)
res_doc.update(**service)
if environment:
for srv_env in service["repositories"]:
if srv_env.get("environment") == environment:
res_doc["repository"] = srv_env["repo"]
for srv_assignees in service.get("assignees", []):
if srv_assignees.get("environment") == environment:
res_doc["assignees"] = srv_assignees["names"]
yield res_doc
def docs_html_by_category(self, environment):
"""Generate structure for doc-exports repository

79
tools/open_doc_issue.py Normal file
View File

@ -0,0 +1,79 @@
#!/usr/bin/env python
import argparse
import re
import requests
import sys
import otc_metadata.services
api_session = requests.Session()
def open_issue(args, repository, issue_data):
#if issue_data['repository'] not in ['docs/elastic-cloud-server']:
# return
req = dict(
title=issue_data["title"],
body=issue_data["body"].replace("\\n", "\n")
)
if "assignees" in issue_data:
req["assignees"] = issue_data["assignees"]
if "labels" in issue_data:
req["labels"] = issue_data["labels"]
print(req)
rsp = api_session.post(
f"{args.api_url}/repos/{repository}/issues",
json=req
)
if rsp.status_code != 201:
print(rsp.text)
print(f"Going to open issue with title {issue_data['title']} in {repository}")
def main():
parser = argparse.ArgumentParser(description='Open Issue for every document.')
parser.add_argument(
'token', metavar='token', help='API token')
parser.add_argument(
'--api-url', help='API base url of the Git hoster'
)
parser.add_argument(
'--environment', help='Environment for the repository'
)
parser.add_argument(
'--title', required=True, help='Issue title'
)
parser.add_argument(
'--body', required=True, help='Issue body'
)
parser.add_argument(
'--repo', help='Repository to report issue in (instead of doc repository).'
)
parser.add_argument(
'--assignee', help='Issue assignee to use instead of document service assignees.'
)
parser.add_argument(
'--labels', help='Issue labels to use (comma separated list of label IDs).'
)
args = parser.parse_args()
data = otc_metadata.services.Services()
api_session.headers.update({'Authorization': f"token {args.token}"})
for doc in data.all_docs_full(environment=args.environment):
issue_data=dict(
title=args.title.format(**doc),
body=args.body.format(**doc),
repository=doc["repository"]
)
if "assignees" in doc:
issue_data["assignees"] = doc["assignees"]
if args.assignee:
issue_data["assignees"] = [args.assignee]
if args.labels:
issue_data["labels"] = [int(x) for x in args.labels.split(',')]
open_issue(args, args.repo or doc["repository"], issue_data)
if __name__ == '__main__':
main()