mirror of
https://github.com/goharbor/harbor
synced 2025-04-22 17:26:15 +00:00

Move admin_client to testutil.py as global parameter. Change create_repository function name to push_image_to_project to make it reasonable. Signed-off-by: danfengliu <danfengl@vmware.com>
29 lines
895 B
Python
29 lines
895 B
Python
import time
|
|
import os
|
|
import sys
|
|
|
|
sys.path.append(os.environ["SWAGGER_CLIENT_PATH"])
|
|
from swagger_client.rest import ApiException
|
|
import swagger_client.models
|
|
from pprint import pprint
|
|
|
|
admin_user = "admin"
|
|
admin_pwd = "Harbor12345"
|
|
|
|
harbor_server = os.environ["HARBOR_HOST"]
|
|
#CLIENT=dict(endpoint="https://"+harbor_server+"/api")
|
|
ADMIN_CLIENT=dict(endpoint = "https://"+harbor_server+"/api", username = admin_user, password = admin_pwd)
|
|
USER_ROLE=dict(admin=0,normal=1)
|
|
TEARDOWN = True
|
|
|
|
def GetProductApi(username, password, harbor_server= os.environ["HARBOR_HOST"]):
|
|
|
|
cfg = swagger_client.Configuration()
|
|
cfg.host = "https://"+harbor_server+"/api"
|
|
cfg.username = username
|
|
cfg.password = password
|
|
cfg.verify_ssl = False
|
|
cfg.debug = True
|
|
api_client = swagger_client.ApiClient(cfg)
|
|
api_instance = swagger_client.ProductsApi(api_client)
|
|
return api_instance |