Coverage for ocp_resources/maria_db.py: 0%

173 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-30 10:48 +0200

1# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md 

2 

3from typing import Any, Dict, List, Optional 

4from ocp_resources.resource import NamespacedResource 

5 

6 

7class MariaDB(NamespacedResource): 

8 """ 

9 MariaDB is the Schema for the mariadbs API. It is used to define MariaDB clusters. 

10 """ 

11 

12 api_group: str = NamespacedResource.ApiGroup.K8S_MARIADB_COM 

13 

14 def __init__( 

15 self, 

16 affinity: Optional[Dict[str, Any]] = None, 

17 args: Optional[List[Any]] = None, 

18 bootstrap_from: Optional[Dict[str, Any]] = None, 

19 command: Optional[List[Any]] = None, 

20 connection: Optional[Dict[str, Any]] = None, 

21 database: Optional[str] = "", 

22 env: Optional[List[Any]] = None, 

23 env_from: Optional[List[Any]] = None, 

24 galera: Optional[Dict[str, Any]] = None, 

25 image: Optional[str] = "", 

26 image_pull_policy: Optional[str] = "", 

27 image_pull_secrets: Optional[List[Any]] = None, 

28 inherit_metadata: Optional[Dict[str, Any]] = None, 

29 init_containers: Optional[List[Any]] = None, 

30 liveness_probe: Optional[Dict[str, Any]] = None, 

31 max_scale: Optional[Dict[str, Any]] = None, 

32 max_scale_ref: Optional[Dict[str, Any]] = None, 

33 metrics: Optional[Dict[str, Any]] = None, 

34 my_cnf: Optional[str] = "", 

35 my_cnf_config_map_key_ref: Optional[Dict[str, Any]] = None, 

36 node_selector: Optional[Dict[str, Any]] = None, 

37 password_hash_secret_key_ref: Optional[Dict[str, Any]] = None, 

38 password_plugin: Optional[Dict[str, Any]] = None, 

39 password_secret_key_ref: Optional[Dict[str, Any]] = None, 

40 pod_disruption_budget: Optional[Dict[str, Any]] = None, 

41 pod_metadata: Optional[Dict[str, Any]] = None, 

42 pod_security_context: Optional[Dict[str, Any]] = None, 

43 port: Optional[int] = None, 

44 primary_connection: Optional[Dict[str, Any]] = None, 

45 primary_service: Optional[Dict[str, Any]] = None, 

46 priority_class_name: Optional[str] = "", 

47 readiness_probe: Optional[Dict[str, Any]] = None, 

48 replicas: Optional[int] = None, 

49 replicas_allow_even_number: Optional[bool] = None, 

50 replication: Optional[Dict[str, Any]] = None, 

51 resources: Optional[Dict[str, Any]] = None, 

52 root_empty_password: Optional[bool] = None, 

53 root_password_secret_key_ref: Optional[Dict[str, Any]] = None, 

54 secondary_connection: Optional[Dict[str, Any]] = None, 

55 secondary_service: Optional[Dict[str, Any]] = None, 

56 security_context: Optional[Dict[str, Any]] = None, 

57 service: Optional[Dict[str, Any]] = None, 

58 service_account_name: Optional[str] = "", 

59 service_ports: Optional[List[Any]] = None, 

60 sidecar_containers: Optional[List[Any]] = None, 

61 storage: Optional[Dict[str, Any]] = None, 

62 suspend: Optional[bool] = None, 

63 time_zone: Optional[str] = "", 

64 tolerations: Optional[List[Any]] = None, 

65 topology_spread_constraints: Optional[List[Any]] = None, 

66 update_strategy: Optional[Dict[str, Any]] = None, 

67 username: Optional[str] = "", 

68 volume_mounts: Optional[List[Any]] = None, 

69 volumes: Optional[List[Any]] = None, 

70 **kwargs: Any, 

71 ) -> None: 

72 """ 

73 Args: 

74 affinity (Dict[str, Any]): Affinity to be used in the Pod. 

75 

76 args (List[Any]): Args to be used in the Container. 

77 

78 bootstrap_from (Dict[str, Any]): BootstrapFrom defines a source to bootstrap from. 

79 

80 command (List[Any]): Command to be used in the Container. 

81 

82 connection (Dict[str, Any]): Connection defines a template to configure the general Connection 

83 object. This Connection provides the initial User access to the 

84 initial Database. It will make use of the Service to route network 

85 traffic to all Pods. 

86 

87 database (str): Database is the name of the initial Database. 

88 

89 env (List[Any]): Env represents the environment variables to be injected in a 

90 container. 

91 

92 env_from (List[Any]): EnvFrom represents the references (via ConfigMap and Secrets) to 

93 environment variables to be injected in the container. 

94 

95 galera (Dict[str, Any]): Replication configures high availability via Galera. 

96 

97 image (str): Image name to be used by the MariaDB instances. The supported format 

98 is `<image>:<tag>`. Only MariaDB official images are supported. 

99 

100 image_pull_policy (str): ImagePullPolicy is the image pull policy. One of `Always`, `Never` or 

101 `IfNotPresent`. If not defined, it defaults to `IfNotPresent`. 

102 

103 image_pull_secrets (List[Any]): ImagePullSecrets is the list of pull Secrets to be used to pull the 

104 image. 

105 

106 inherit_metadata (Dict[str, Any]): InheritMetadata defines the metadata to be inherited by children 

107 resources. 

108 

109 init_containers (List[Any]): InitContainers to be used in the Pod. 

110 

111 liveness_probe (Dict[str, Any]): LivenessProbe to be used in the Container. 

112 

113 max_scale (Dict[str, Any]): MaxScale is the MaxScale specification that defines the MaxScale 

114 resource to be used with the current MariaDB. When enabling this 

115 field, MaxScaleRef is automatically set. 

116 

117 max_scale_ref (Dict[str, Any]): MaxScaleRef is a reference to a MaxScale resource to be used with the 

118 current MariaDB. Providing this field implies delegating high 

119 availability tasks such as primary failover to MaxScale. 

120 

121 metrics (Dict[str, Any]): Metrics configures metrics and how to scrape them. 

122 

123 my_cnf (str): MyCnf allows to specify the my.cnf file mounted by Mariadb. Updating 

124 this field will trigger an update to the Mariadb resource. 

125 

126 my_cnf_config_map_key_ref (Dict[str, Any]): MyCnfConfigMapKeyRef is a reference to the my.cnf config file provided 

127 via a ConfigMap. If not provided, it will be defaulted with a 

128 reference to a ConfigMap containing the MyCnf field. If the 

129 referred ConfigMap is labeled with "k8s.mariadb.com/watch", an 

130 update to the Mariadb resource will be triggered when the 

131 ConfigMap is updated. 

132 

133 node_selector (Dict[str, Any]): NodeSelector to be used in the Pod. 

134 

135 password_hash_secret_key_ref (Dict[str, Any]): PasswordHashSecretKeyRef is a reference to the password hash to be 

136 used by the initial User. If the referred Secret is labeled with 

137 "k8s.mariadb.com/watch", updates may be performed to the Secret in 

138 order to update the password hash. 

139 

140 password_plugin (Dict[str, Any]): PasswordPlugin is a reference to the password plugin and arguments to 

141 be used by the initial User. 

142 

143 password_secret_key_ref (Dict[str, Any]): PasswordSecretKeyRef is a reference to a Secret that contains the 

144 password to be used by the initial User. If the referred Secret is 

145 labeled with "k8s.mariadb.com/watch", updates may be performed to 

146 the Secret in order to update the password. 

147 

148 pod_disruption_budget (Dict[str, Any]): PodDisruptionBudget defines the budget for replica availability. 

149 

150 pod_metadata (Dict[str, Any]): PodMetadata defines extra metadata for the Pod. 

151 

152 pod_security_context (Dict[str, Any]): SecurityContext holds pod-level security attributes and common 

153 container settings. 

154 

155 port (int): Port where the instances will be listening for connections. 

156 

157 primary_connection (Dict[str, Any]): PrimaryConnection defines a template to configure the primary 

158 Connection object. This Connection provides the initial User 

159 access to the initial Database. It will make use of the 

160 PrimaryService to route network traffic to the primary Pod. 

161 

162 primary_service (Dict[str, Any]): PrimaryService defines a template to configure the primary Service 

163 object. The network traffic of this Service will be routed to the 

164 primary Pod. 

165 

166 priority_class_name (str): PriorityClassName to be used in the Pod. 

167 

168 readiness_probe (Dict[str, Any]): ReadinessProbe to be used in the Container. 

169 

170 replicas (int): Replicas indicates the number of desired instances. 

171 

172 replicas_allow_even_number (bool): disables the validation check for an odd number of replicas. 

173 

174 replication (Dict[str, Any]): Replication configures high availability via replication. This feature 

175 is still in alpha, use Galera if you are looking for a more 

176 production-ready HA. 

177 

178 resources (Dict[str, Any]): Resouces describes the compute resource requirements. 

179 

180 root_empty_password (bool): RootEmptyPassword indicates if the root password should be empty. 

181 Don't use this feature in production, it is only intended for 

182 development and test environments. 

183 

184 root_password_secret_key_ref (Dict[str, Any]): RootPasswordSecretKeyRef is a reference to a Secret key containing the 

185 root password. 

186 

187 secondary_connection (Dict[str, Any]): SecondaryConnection defines a template to configure the secondary 

188 Connection object. This Connection provides the initial User 

189 access to the initial Database. It will make use of the 

190 SecondaryService to route network traffic to the secondary Pods. 

191 

192 secondary_service (Dict[str, Any]): SecondaryService defines a template to configure the secondary Service 

193 object. The network traffic of this Service will be routed to the 

194 secondary Pods. 

195 

196 security_context (Dict[str, Any]): SecurityContext holds security configuration that will be applied to a 

197 container. 

198 

199 service (Dict[str, Any]): Service defines a template to configure the general Service object. 

200 The network traffic of this Service will be routed to all Pods. 

201 

202 service_account_name (str): ServiceAccountName is the name of the ServiceAccount to be used by the 

203 Pods. 

204 

205 service_ports (List[Any]): ServicePorts is the list of additional named ports to be added to the 

206 Services created by the operator. 

207 

208 sidecar_containers (List[Any]): SidecarContainers to be used in the Pod. 

209 

210 storage (Dict[str, Any]): Storage defines the storage options to be used for provisioning the 

211 PVCs mounted by MariaDB. 

212 

213 suspend (bool): Suspend indicates whether the current resource should be suspended or 

214 not. This can be useful for maintenance, as disabling the 

215 reconciliation prevents the operator from interfering with user 

216 operations during maintenance activities. 

217 

218 time_zone (str): TimeZone sets the default timezone. If not provided, it defaults to 

219 SYSTEM and the timezone data is not loaded. 

220 

221 tolerations (List[Any]): Tolerations to be used in the Pod. 

222 

223 topology_spread_constraints (List[Any]): TopologySpreadConstraints to be used in the Pod. 

224 

225 update_strategy (Dict[str, Any]): UpdateStrategy defines how a MariaDB resource is updated. 

226 

227 username (str): Username is the initial username to be created by the operator once 

228 MariaDB is ready. It has all privileges on the initial database. 

229 The initial User will have ALL PRIVILEGES in the initial Database. 

230 

231 volume_mounts (List[Any]): VolumeMounts to be used in the Container. 

232 

233 volumes (List[Any]): Volumes to be used in the Pod. 

234 

235 """ 

236 super().__init__(**kwargs) 

237 

238 self.affinity = affinity 

239 self.args = args 

240 self.bootstrap_from = bootstrap_from 

241 self.command = command 

242 self.connection = connection 

243 self.database = database 

244 self.env = env 

245 self.env_from = env_from 

246 self.galera = galera 

247 self.image = image 

248 self.image_pull_policy = image_pull_policy 

249 self.image_pull_secrets = image_pull_secrets 

250 self.inherit_metadata = inherit_metadata 

251 self.init_containers = init_containers 

252 self.liveness_probe = liveness_probe 

253 self.max_scale = max_scale 

254 self.max_scale_ref = max_scale_ref 

255 self.metrics = metrics 

256 self.my_cnf = my_cnf 

257 self.my_cnf_config_map_key_ref = my_cnf_config_map_key_ref 

258 self.node_selector = node_selector 

259 self.password_hash_secret_key_ref = password_hash_secret_key_ref 

260 self.password_plugin = password_plugin 

261 self.password_secret_key_ref = password_secret_key_ref 

262 self.pod_disruption_budget = pod_disruption_budget 

263 self.pod_metadata = pod_metadata 

264 self.pod_security_context = pod_security_context 

265 self.port = port 

266 self.primary_connection = primary_connection 

267 self.primary_service = primary_service 

268 self.priority_class_name = priority_class_name 

269 self.readiness_probe = readiness_probe 

270 self.replicas = replicas 

271 self.replicas_allow_even_number = replicas_allow_even_number 

272 self.replication = replication 

273 self.resources = resources 

274 self.root_empty_password = root_empty_password 

275 self.root_password_secret_key_ref = root_password_secret_key_ref 

276 self.secondary_connection = secondary_connection 

277 self.secondary_service = secondary_service 

278 self.security_context = security_context 

279 self.service = service 

280 self.service_account_name = service_account_name 

281 self.service_ports = service_ports 

282 self.sidecar_containers = sidecar_containers 

283 self.storage = storage 

284 self.suspend = suspend 

285 self.time_zone = time_zone 

286 self.tolerations = tolerations 

287 self.topology_spread_constraints = topology_spread_constraints 

288 self.update_strategy = update_strategy 

289 self.username = username 

290 self.volume_mounts = volume_mounts 

291 self.volumes = volumes 

292 

293 def to_dict(self) -> None: 

294 super().to_dict() 

295 

296 if not self.kind_dict and not self.yaml_file: 

297 self.res["spec"] = {} 

298 _spec = self.res["spec"] 

299 

300 if self.affinity: 

301 _spec["affinity"] = self.affinity 

302 

303 if self.args: 

304 _spec["args"] = self.args 

305 

306 if self.bootstrap_from: 

307 _spec["bootstrapFrom"] = self.bootstrap_from 

308 

309 if self.command: 

310 _spec["command"] = self.command 

311 

312 if self.connection: 

313 _spec["connection"] = self.connection 

314 

315 if self.database: 

316 _spec["database"] = self.database 

317 

318 if self.env: 

319 _spec["env"] = self.env 

320 

321 if self.env_from: 

322 _spec["envFrom"] = self.env_from 

323 

324 if self.galera: 

325 _spec["galera"] = self.galera 

326 

327 if self.image: 

328 _spec["image"] = self.image 

329 

330 if self.image_pull_policy: 

331 _spec["imagePullPolicy"] = self.image_pull_policy 

332 

333 if self.image_pull_secrets: 

334 _spec["imagePullSecrets"] = self.image_pull_secrets 

335 

336 if self.inherit_metadata: 

337 _spec["inheritMetadata"] = self.inherit_metadata 

338 

339 if self.init_containers: 

340 _spec["initContainers"] = self.init_containers 

341 

342 if self.liveness_probe: 

343 _spec["livenessProbe"] = self.liveness_probe 

344 

345 if self.max_scale: 

346 _spec["maxScale"] = self.max_scale 

347 

348 if self.max_scale_ref: 

349 _spec["maxScaleRef"] = self.max_scale_ref 

350 

351 if self.metrics: 

352 _spec["metrics"] = self.metrics 

353 

354 if self.my_cnf: 

355 _spec["myCnf"] = self.my_cnf 

356 

357 if self.my_cnf_config_map_key_ref: 

358 _spec["myCnfConfigMapKeyRef"] = self.my_cnf_config_map_key_ref 

359 

360 if self.node_selector: 

361 _spec["nodeSelector"] = self.node_selector 

362 

363 if self.password_hash_secret_key_ref: 

364 _spec["passwordHashSecretKeyRef"] = self.password_hash_secret_key_ref 

365 

366 if self.password_plugin: 

367 _spec["passwordPlugin"] = self.password_plugin 

368 

369 if self.password_secret_key_ref: 

370 _spec["passwordSecretKeyRef"] = self.password_secret_key_ref 

371 

372 if self.pod_disruption_budget: 

373 _spec["podDisruptionBudget"] = self.pod_disruption_budget 

374 

375 if self.pod_metadata: 

376 _spec["podMetadata"] = self.pod_metadata 

377 

378 if self.pod_security_context: 

379 _spec["podSecurityContext"] = self.pod_security_context 

380 

381 if self.port: 

382 _spec["port"] = self.port 

383 

384 if self.primary_connection: 

385 _spec["primaryConnection"] = self.primary_connection 

386 

387 if self.primary_service: 

388 _spec["primaryService"] = self.primary_service 

389 

390 if self.priority_class_name: 

391 _spec["priorityClassName"] = self.priority_class_name 

392 

393 if self.readiness_probe: 

394 _spec["readinessProbe"] = self.readiness_probe 

395 

396 if self.replicas: 

397 _spec["replicas"] = self.replicas 

398 

399 if self.replicas_allow_even_number is not None: 

400 _spec["replicasAllowEvenNumber"] = self.replicas_allow_even_number 

401 

402 if self.replication: 

403 _spec["replication"] = self.replication 

404 

405 if self.resources: 

406 _spec["resources"] = self.resources 

407 

408 if self.root_empty_password is not None: 

409 _spec["rootEmptyPassword"] = self.root_empty_password 

410 

411 if self.root_password_secret_key_ref: 

412 _spec["rootPasswordSecretKeyRef"] = self.root_password_secret_key_ref 

413 

414 if self.secondary_connection: 

415 _spec["secondaryConnection"] = self.secondary_connection 

416 

417 if self.secondary_service: 

418 _spec["secondaryService"] = self.secondary_service 

419 

420 if self.security_context: 

421 _spec["securityContext"] = self.security_context 

422 

423 if self.service: 

424 _spec["service"] = self.service 

425 

426 if self.service_account_name: 

427 _spec["serviceAccountName"] = self.service_account_name 

428 

429 if self.service_ports: 

430 _spec["servicePorts"] = self.service_ports 

431 

432 if self.sidecar_containers: 

433 _spec["sidecarContainers"] = self.sidecar_containers 

434 

435 if self.storage: 

436 _spec["storage"] = self.storage 

437 

438 if self.suspend is not None: 

439 _spec["suspend"] = self.suspend 

440 

441 if self.time_zone: 

442 _spec["timeZone"] = self.time_zone 

443 

444 if self.tolerations: 

445 _spec["tolerations"] = self.tolerations 

446 

447 if self.topology_spread_constraints: 

448 _spec["topologySpreadConstraints"] = self.topology_spread_constraints 

449 

450 if self.update_strategy: 

451 _spec["updateStrategy"] = self.update_strategy 

452 

453 if self.username: 

454 _spec["username"] = self.username 

455 

456 if self.volume_mounts: 

457 _spec["volumeMounts"] = self.volume_mounts 

458 

459 if self.volumes: 

460 _spec["volumes"] = self.volumes 

461 

462 # End of generated code