-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathcommon.py
94 lines (81 loc) · 2.87 KB
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# (C) Datadog, Inc. 2019-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os
from datadog_checks.dev import get_docker_hostname
VERSION_2_2 = [2, 2, 0]
HARBOR_COMPONENTS = ['chartmuseum', 'registry', 'redis', 'jobservice', 'registryctl', 'portal', 'core', 'database']
HARBOR_VERSION = [int(i) for i in os.environ['HARBOR_VERSION'].split('.')]
USERS_PATH = '/api/users/' if HARBOR_VERSION < VERSION_2_2 else '/api/v2.0/users/'
HARBOR_METRICS = [
# Metric_name, requires admin privileges
('harbor.projects.count', False),
('harbor.disk.free', True),
('harbor.disk.total', True),
('harbor.registry.read_only', False),
]
HERE = os.path.dirname(os.path.abspath(__file__))
URL = 'http://{}'.format(get_docker_hostname())
INSTANCE = {'url': URL, 'username': 'NotAnAdmin', 'password': 'Str0ngPassw0rd', 'tags': ['environment:test']}
ADMIN_INSTANCE = {'url': URL, 'username': 'admin', 'password': 'Harbor12345', 'tags': ['environment:test']}
HEALTH_FIXTURE = {
"status": "healthy",
"components": [
{"name": "registryctl", "status": "healthy"},
{"name": "database", "status": "healthy"},
{"name": "redis", "status": "healthy"},
{"name": "chartmuseum", "status": "healthy"},
{"name": "jobservice", "status": "healthy"},
{"name": "portal", "status": "healthy"},
{"name": "core", "status": "healthy"},
{"name": "registry", "status": "healthy"},
],
}
CHARTREPO_HEALTH_FIXTURE = {"healthy": True}
PROJECTS_FIXTURE = [
{
"project_id": 1,
"owner_id": 1,
"name": "library",
"creation_time": "2019-05-28T20:26:57.968839Z",
"update_time": "2019-05-28T20:26:57.968839Z",
"deleted": False,
"owner_name": "User1",
"togglable": True,
"current_user_role_id": 1,
"repo_count": 0,
"chart_count": 0,
"metadata": {"public": "true"},
},
{
"project_id": 2,
"owner_id": 1,
"name": "private_repo",
"creation_time": "2019-05-28T20:26:57.968839Z",
"update_time": "2019-05-28T20:26:57.968839Z",
"deleted": False,
"owner_name": "User2",
"togglable": True,
"current_user_role_id": 1,
"repo_count": 0,
"chart_count": 0,
"metadata": {"public": "false"},
},
]
REGISTRIES_FIXTURE = [
{
"id": 1,
"name": "Demo",
"type": "harbor",
"status": "healthy",
"url": "https://demo.goharbor.io/",
"credential": {"type": "basic", "access_key": "*****", "access_secret": "*****"},
}
]
VOLUME_INFO_PRE_2_2_FIXTURE = {"storage": {"total": 1e6, "free": 5e5}}
VOLUME_INFO_FIXTURE = {"storage": [{"total": 1e6, "free": 5e5}]}
SYSTEM_INFO_FIXTURE = {
"harbor_version": "v{}-25bb24ca".format(os.environ['HARBOR_VERSION']),
"read_only": False,
"with_chartmuseum": True,
}