mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-23 00:57:44 +01:00
modify codacy errors in target
Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
parent
a6151175e3
commit
9265754936
@ -60,4 +60,8 @@ class Repository(base.Base):
|
||||
_, status_code, _ = client.repositories_repo_name_tags_tag_labels_post_with_http_info(repo_name, tag, label)
|
||||
base._assert_status_code(expect_status_code, status_code)
|
||||
|
||||
|
||||
def get_repo_signatures(self, repo_name, expect_status_code = 200, **kwargs):
|
||||
client = self._get_client(**kwargs)
|
||||
data, status_code, _ = client.repositories_repo_name_signatures_get_with_http_info(repo_name)
|
||||
base._assert_status_code(expect_status_code, status_code)
|
||||
|
@ -1,29 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import base
|
||||
import swagger_client
|
||||
|
||||
class Target(base.Base):
|
||||
def create_target(self,
|
||||
endpoint_target = r"https://{}.{}.{}.{}".format(random.randint(1, 254), random.randint(1, 254), random.randint(1, 254), random.randint(1, 254)),
|
||||
def create_target(self,
|
||||
endpoint_target = None,
|
||||
username_target = "target_user", password_target = "Aa123456", name_target=base._random_name("target"),
|
||||
type=0, insecure_target=True, expect_status_code = 201,
|
||||
target_type=0, insecure_target=True, expect_status_code = 201,
|
||||
**kwargs):
|
||||
if endpoint_target is None:
|
||||
endpoint_target = r"https://{}.{}.{}.{}".format(int(round(time.time() * 1000)) % 100,
|
||||
int(round(time.time() * 1000)) % 200,
|
||||
int(round(time.time() * 1000)) % 100,
|
||||
int(round(time.time() * 1000)) % 254)
|
||||
client = self._get_client(**kwargs)
|
||||
policy = swagger_client.RepTarget(name=name_target, endpoint=endpoint_target,
|
||||
username=username_target, password=password_target, type=type,
|
||||
policy = swagger_client.RepTarget(name=name_target, endpoint=endpoint_target,
|
||||
username=username_target, password=password_target, type=target_type,
|
||||
insecure=insecure_target)
|
||||
|
||||
_, status_code, header = client.targets_post_with_http_info(policy)
|
||||
base._assert_status_code(expect_status_code, status_code)
|
||||
return base._get_id_from_header(header), name_target
|
||||
|
||||
def get_target(self, expect_status_code = 200, params = {}, **kwargs):
|
||||
def get_target(self, expect_status_code = 200, params = None, **kwargs):
|
||||
client = self._get_client(**kwargs)
|
||||
data = []
|
||||
if params is None:
|
||||
params = {}
|
||||
data, status_code, _ = client.targets_get_with_http_info(**params)
|
||||
base._assert_status_code(expect_status_code, status_code)
|
||||
return data
|
||||
|
Loading…
Reference in New Issue
Block a user