예제 #1
0
파일: views.py 프로젝트: penglongli/bk-bcs
 def list_images(self,
                 access_token: str,
                 project_name: str,
                 repo_name: str,
                 page: PageData,
                 name: Optional[str] = None) -> Dict:
     client = BkRepoClient(access_token)
     return client.list_images(project_name, repo_name, page, name)
예제 #2
0
def get_incremental_charts_and_hash_value(project_code, username, password, start_time):
    """获取chart,并且计算chart对应的hash值"""
    client = BkRepoClient(username=username, password=password)
    charts_info = client.list_charts(project_code, project_code, start_time=start_time)
    if not charts_info:
        return None, None

    return charts_info, _md5(str(charts_info))
예제 #3
0
def get_chart_version_list(chart_data: ChartData,
                           repo_auth: RepoAuth) -> List[str]:
    """获取 chart 对应的版本列表"""
    client = BkRepoClient(repo_auth.username, password=repo_auth.password)
    chart_versions = client.get_chart_versions(**asdict(chart_data))
    # 如果不为列表,则返回为空
    if isinstance(chart_versions, list):
        return [info["version"] for info in chart_versions]
    return []
예제 #4
0
파일: views.py 프로젝트: penglongli/bk-bcs
 def list_image_tags(self, access_token: str, image_path: str) -> Dict:
     page = PageData()
     # 前端传递的路径格式为/项目名/仓库名/镜像,需要转换为 镜像
     repo_list = image_path.split("/", 3)
     project_name = repo_list[1]
     repo_name = repo_list[2]
     image_name = repo_list[3]
     client = BkRepoClient(access_token)
     return client.list_image_tags(project_name, repo_name, image_name,
                                   page)
예제 #5
0
def batch_delete_chart_versions(chart_data: ChartData, repo_auth: RepoAuth,
                                versions: List[str]):
    """批量删除chart版本"""
    # 组装并发任务
    client = BkRepoClient(repo_auth.username, password=repo_auth.password)
    delete_version = functools.partial(delete_chart_version, chart_data,
                                       client)
    tasks = [
        functools.partial(delete_version, version) for version in versions
    ]
    async_run(tasks)
예제 #6
0
def delete_chart_version(chart_data: ChartData, client: BkRepoClient,
                         version: str):
    """删除版本"""
    req_data = asdict(chart_data)
    req_data["version"] = version
    client.delete_chart_version(**req_data)