github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/backup/helpers/models.go (about) 1 // Copyright (c) 2022, 2023, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package helpers 5 6 import ( 7 "bytes" 8 "time" 9 ) 10 11 // RancherBackupData struct used for rancher backup templating 12 type RancherBackupData struct { 13 RancherBackupName string 14 RancherSecretData RancherObjectStoreData 15 } 16 17 // RancherRestoreData struct used for rancher restore templating 18 type RancherRestoreData struct { 19 RancherRestoreName string 20 BackupFileName string 21 RancherSecretData RancherObjectStoreData 22 } 23 24 // RancherObjectStoreData struct used for rancher secret templating 25 type RancherObjectStoreData struct { 26 RancherSecretName string 27 RancherSecretNamespaceName string 28 RancherObjectStoreBucketName string 29 RancherBackupRegion string 30 RancherObjectStorageNamespaceName string 31 } 32 33 // BashCommand struct used for running bash commands 34 type BashCommand struct { 35 CommandArgs []string `json:"cmdArgs"` 36 } 37 38 // RunnerResponse is structured response for bash commands 39 type RunnerResponse struct { 40 StandardOut bytes.Buffer `json:"stdout"` 41 StandardErr bytes.Buffer `json:"stderr"` 42 CommandError error `json:"error"` 43 } 44 45 // AccessData struct used for velero secrets templating 46 type AccessData struct { 47 AccessName string 48 ScrtName string 49 ObjectStoreAccessValue string 50 ObjectStoreScrt string 51 } 52 53 // VeleroBackupLocationObjectData holds data related to velero backup location 54 type VeleroBackupLocationObjectData struct { 55 VeleroBackupStorageName string 56 VeleroNamespaceName string 57 VeleroObjectStoreBucketName string 58 VeleroSecretName string 59 VeleroObjectStorageNamespaceName string 60 VeleroBackupRegion string 61 } 62 63 // VeleroBackupObject holds data related to velero backup 64 type VeleroBackupObject struct { 65 VeleroBackupName string 66 VeleroNamespaceName string 67 VeleroBackupStorageName string 68 VeleroOpensearchHookResourceName string 69 } 70 71 // VeleroRestoreObject holds data related to velero restore 72 type VeleroRestoreObject struct { 73 VeleroRestore string 74 VeleroNamespaceName string 75 VeleroBackupName string 76 VeleroOpensearchHookResourceName string 77 } 78 79 // EsQueryObject holds data related to opensearch index query 80 type EsQueryObject struct { 81 BackupIDBeforeBackup string 82 } 83 84 // RancherUser holds data related to rancher test user 85 type RancherUser struct { 86 FullName string 87 Password string 88 Username string 89 } 90 91 type VeleroMysqlBackupObject struct { 92 VeleroMysqlBackupName string 93 VeleroNamespaceName string 94 VeleroMysqlBackupStorageName string 95 VeleroMysqlHookResourceName string 96 } 97 98 type VeleroMysqlRestoreObject struct { 99 VeleroMysqlRestore string 100 VeleroNamespaceName string 101 VeleroMysqlBackupName string 102 VeleroMysqlHookResourceName string 103 } 104 105 type InnoDBSecret struct { 106 AccessName string 107 ScrtName string 108 Region string 109 } 110 111 type InnoDBBackupObject struct { 112 InnoDBBackupName string 113 InnoDBNamespaceName string 114 InnoDBClusterName string 115 InnoDBBackupProfileName string 116 InnoDBBackupObjectStoreBucketName string 117 InnoDBObjectStorageNamespaceName string 118 InnoDBBackupCredentialsName string 119 InnoDBBackupStorageName string 120 InnoDBBackupRegion string 121 } 122 123 // VeleroBackupModel defines the spec for backup 124 type VeleroBackupModel struct { 125 APIVersion string `json:"apiVersion"` 126 Kind string `json:"kind"` 127 Metadata struct { 128 Annotations struct { 129 KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"` 130 VeleroIoSourceClusterK8SGitversion string `json:"velero.io/source-cluster-k8s-gitversion"` 131 VeleroIoSourceClusterK8SMajorVersion string `json:"velero.io/source-cluster-k8s-major-version"` 132 VeleroIoSourceClusterK8SMinorVersion string `json:"velero.io/source-cluster-k8s-minor-version"` 133 } `json:"annotations"` 134 CreationTimestamp time.Time `json:"creationTimestamp"` 135 Generation int `json:"generation"` 136 Labels struct { 137 VeleroIoStorageLocation string `json:"velero.io/storage-location"` 138 } `json:"labels"` 139 Name string `json:"name"` 140 Namespace string `json:"namespace"` 141 ResourceVersion string `json:"resourceVersion"` 142 UID string `json:"uid"` 143 } `json:"metadata"` 144 Spec struct { 145 DefaultVolumesToRestic bool `json:"defaultVolumesToRestic"` 146 Hooks struct { 147 Resources []struct { 148 IncludedNamespaces []string `json:"includedNamespaces"` 149 LabelSelector struct { 150 MatchLabels struct { 151 App string `json:"app"` 152 } `json:"matchLabels"` 153 } `json:"labelSelector"` 154 Name string `json:"name"` 155 Post []struct { 156 Exec struct { 157 Command []string `json:"command"` 158 Container string `json:"container"` 159 OnError string `json:"onError"` 160 Timeout string `json:"timeout"` 161 } `json:"exec"` 162 } `json:"post"` 163 } `json:"resources"` 164 } `json:"hooks"` 165 IncludedNamespaces []string `json:"includedNamespaces"` 166 StorageLocation string `json:"storageLocation"` 167 TTL string `json:"ttl"` 168 } `json:"spec"` 169 Status struct { 170 CompletionTimestamp time.Time `json:"completionTimestamp"` 171 Expiration time.Time `json:"expiration"` 172 FormatVersion string `json:"formatVersion"` 173 Phase string `json:"phase"` 174 Progress struct { 175 ItemsBackedUp int `json:"itemsBackedUp"` 176 TotalItems int `json:"totalItems"` 177 } `json:"progress"` 178 StartTimestamp time.Time `json:"startTimestamp"` 179 Version int `json:"version"` 180 } `json:"status"` 181 } 182 183 type VeleroRestoreModel struct { 184 APIVersion string `json:"apiVersion"` 185 Kind string `json:"kind"` 186 Metadata struct { 187 Name string `json:"name"` 188 Namespace string `json:"namespace"` 189 } `json:"metadata"` 190 Spec struct { 191 BackupName string `json:"backupName"` 192 IncludedNamespaces []string `json:"includedNamespaces"` 193 ExcludedNamespaces []string `json:"excludedNamespaces"` 194 IncludedResources []string `json:"includedResources"` 195 ExcludedResources []string `json:"excludedResources"` 196 RestoreStatus struct { 197 IncludedResources []string `json:"includedResources"` 198 ExcludedResources []interface{} `json:"excludedResources"` 199 } `json:"restoreStatus"` 200 IncludeClusterResources interface{} `json:"includeClusterResources"` 201 LabelSelector struct { 202 MatchLabels struct { 203 App string `json:"app"` 204 Component string `json:"component"` 205 } `json:"matchLabels"` 206 } `json:"labelSelector"` 207 OrLabelSelectors []struct { 208 MatchLabels struct { 209 App string `json:"app"` 210 } `json:"matchLabels"` 211 } `json:"orLabelSelectors"` 212 NamespaceMapping struct { 213 NamespaceBackupFrom string `json:"namespace-backup-from"` 214 } `json:"namespaceMapping"` 215 RestorePVs bool `json:"restorePVs"` 216 ScheduleName string `json:"scheduleName"` 217 ExistingResourcePolicy string `json:"existingResourcePolicy"` 218 Hooks struct { 219 Resources []struct { 220 Name string `json:"name"` 221 IncludedNamespaces []string `json:"includedNamespaces"` 222 ExcludedNamespaces []string `json:"excludedNamespaces"` 223 IncludedResources []string `json:"includedResources"` 224 ExcludedResources []interface{} `json:"excludedResources"` 225 LabelSelector struct { 226 MatchLabels struct { 227 App string `json:"app"` 228 Component string `json:"component"` 229 } `json:"matchLabels"` 230 } `json:"labelSelector"` 231 PostHooks []struct { 232 Init struct { 233 InitContainers []struct { 234 Name string `json:"name"` 235 Image string `json:"image"` 236 VolumeMounts []struct { 237 MountPath string `json:"mountPath"` 238 Name string `json:"name"` 239 } `json:"volumeMounts"` 240 Command []string `json:"command"` 241 } `json:"initContainers"` 242 } `json:"init,omitempty"` 243 Exec struct { 244 Container string `json:"container"` 245 Command []string `json:"command"` 246 WaitTimeout string `json:"waitTimeout"` 247 ExecTimeout string `json:"execTimeout"` 248 OnError string `json:"onError"` 249 } `json:"exec,omitempty"` 250 } `json:"postHooks"` 251 } `json:"resources"` 252 } `json:"hooks"` 253 } `json:"spec"` 254 Status struct { 255 Phase string `json:"phase"` 256 ValidationErrors interface{} `json:"validationErrors"` 257 Warnings int `json:"warnings"` 258 Errors int `json:"errors"` 259 FailureReason interface{} `json:"failureReason"` 260 } `json:"status"` 261 } 262 263 type RancherBackupModel struct { 264 APIVersion string `json:"apiVersion"` 265 Kind string `json:"kind"` 266 Metadata struct { 267 Annotations struct { 268 KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"` 269 } `json:"annotations"` 270 CreationTimestamp time.Time `json:"creationTimestamp"` 271 Generation int `json:"generation"` 272 Name string `json:"name"` 273 ResourceVersion string `json:"resourceVersion"` 274 UID string `json:"uid"` 275 } `json:"metadata"` 276 Spec struct { 277 ResourceSetName string `json:"resourceSetName"` 278 StorageLocation struct { 279 S3 struct { 280 BucketName string `json:"bucketName"` 281 CredentialSecretName string `json:"credentialSecretName"` 282 CredentialSecretNamespace string `json:"credentialSecretNamespace"` 283 Endpoint string `json:"endpoint"` 284 Folder string `json:"folder"` 285 Region string `json:"region"` 286 } `json:"s3"` 287 } `json:"storageLocation"` 288 } `json:"spec"` 289 Status struct { 290 BackupType string `json:"backupType"` 291 Conditions []struct { 292 LastUpdateTime time.Time `json:"lastUpdateTime"` 293 Message string `json:"message,omitempty"` 294 Status string `json:"status"` 295 Type string `json:"type"` 296 } `json:"conditions"` 297 Filename string `json:"filename"` 298 LastSnapshotTs time.Time `json:"lastSnapshotTs"` 299 NextSnapshotAt string `json:"nextSnapshotAt"` 300 ObservedGeneration int `json:"observedGeneration"` 301 StorageLocation string `json:"storageLocation"` 302 Summary string `json:"summary"` 303 } `json:"status"` 304 } 305 306 type RancherRestoreModel struct { 307 APIVersion string `json:"apiVersion"` 308 Kind string `json:"kind"` 309 Metadata struct { 310 Annotations struct { 311 KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"` 312 } `json:"annotations"` 313 CreationTimestamp time.Time `json:"creationTimestamp"` 314 Generation int `json:"generation"` 315 Name string `json:"name"` 316 ResourceVersion string `json:"resourceVersion"` 317 UID string `json:"uid"` 318 } `json:"metadata"` 319 Spec struct { 320 BackupFilename string `json:"backupFilename"` 321 StorageLocation struct { 322 S3 struct { 323 BucketName string `json:"bucketName"` 324 CredentialSecretName string `json:"credentialSecretName"` 325 CredentialSecretNamespace string `json:"credentialSecretNamespace"` 326 Endpoint string `json:"endpoint"` 327 Folder string `json:"folder"` 328 Region string `json:"region"` 329 } `json:"s3"` 330 } `json:"storageLocation"` 331 } `json:"spec"` 332 Status struct { 333 BackupSource string `json:"backupSource"` 334 Conditions []struct { 335 LastUpdateTime time.Time `json:"lastUpdateTime"` 336 Message string `json:"message"` 337 Status string `json:"status"` 338 Type string `json:"type"` 339 } `json:"conditions"` 340 ObservedGeneration int `json:"observedGeneration"` 341 RestoreCompletionTs time.Time `json:"restoreCompletionTs"` 342 Summary string `json:"summary"` 343 } `json:"status"` 344 } 345 346 type VeleroPodVolumeBackups struct { 347 APIVersion string `json:"apiVersion"` 348 Kind string `json:"kind"` 349 Metadata struct { 350 CreationTimestamp time.Time `json:"creationTimestamp"` 351 GenerateName string `json:"generateName"` 352 Generation int `json:"generation"` 353 Labels struct { 354 VeleroIoBackupName string `json:"velero.io/backup-name"` 355 VeleroIoBackupUID string `json:"velero.io/backup-uid"` 356 } `json:"labels"` 357 Name string `json:"name"` 358 Namespace string `json:"namespace"` 359 OwnerReferences []struct { 360 APIVersion string `json:"apiVersion"` 361 Controller bool `json:"controller"` 362 Kind string `json:"kind"` 363 Name string `json:"name"` 364 UID string `json:"uid"` 365 } `json:"ownerReferences"` 366 ResourceVersion string `json:"resourceVersion"` 367 UID string `json:"uid"` 368 } `json:"metadata"` 369 Spec struct { 370 BackupStorageLocation string `json:"backupStorageLocation"` 371 Node string `json:"node"` 372 Pod struct { 373 Kind string `json:"kind"` 374 Name string `json:"name"` 375 Namespace string `json:"namespace"` 376 UID string `json:"uid"` 377 } `json:"pod"` 378 RepoIdentifier string `json:"repoIdentifier"` 379 Tags struct { 380 Backup string `json:"backup"` 381 BackupUID string `json:"backup-uid"` 382 Ns string `json:"ns"` 383 Pod string `json:"pod"` 384 PodUID string `json:"pod-uid"` 385 Volume string `json:"volume"` 386 } `json:"tags"` 387 Volume string `json:"volume"` 388 } `json:"spec"` 389 Status struct { 390 CompletionTimestamp time.Time `json:"completionTimestamp"` 391 Path string `json:"path"` 392 Phase string `json:"phase"` 393 Progress struct { 394 BytesDone int `json:"bytesDone"` 395 TotalBytes int `json:"totalBytes"` 396 } `json:"progress"` 397 SnapshotID string `json:"snapshotID"` 398 StartTimestamp time.Time `json:"startTimestamp"` 399 } `json:"status"` 400 } 401 402 type VeleroPodVolumeRestores struct { 403 APIVersion string `json:"apiVersion"` 404 Kind string `json:"kind"` 405 Metadata struct { 406 CreationTimestamp time.Time `json:"creationTimestamp"` 407 GenerateName string `json:"generateName"` 408 Generation int `json:"generation"` 409 Labels struct { 410 VeleroIoPodUID string `json:"velero.io/pod-uid"` 411 VeleroIoRestoreName string `json:"velero.io/restore-name"` 412 VeleroIoRestoreUID string `json:"velero.io/restore-uid"` 413 } `json:"labels"` 414 Name string `json:"name"` 415 Namespace string `json:"namespace"` 416 OwnerReferences []struct { 417 APIVersion string `json:"apiVersion"` 418 Controller bool `json:"controller"` 419 Kind string `json:"kind"` 420 Name string `json:"name"` 421 UID string `json:"uid"` 422 } `json:"ownerReferences"` 423 ResourceVersion string `json:"resourceVersion"` 424 UID string `json:"uid"` 425 } `json:"metadata"` 426 Spec struct { 427 BackupStorageLocation string `json:"backupStorageLocation"` 428 Pod struct { 429 Kind string `json:"kind"` 430 Name string `json:"name"` 431 Namespace string `json:"namespace"` 432 UID string `json:"uid"` 433 } `json:"pod"` 434 RepoIdentifier string `json:"repoIdentifier"` 435 SnapshotID string `json:"snapshotID"` 436 Volume string `json:"volume"` 437 } `json:"spec"` 438 Status struct { 439 CompletionTimestamp time.Time `json:"completionTimestamp"` 440 Phase string `json:"phase"` 441 Progress struct { 442 BytesDone int `json:"bytesDone"` 443 TotalBytes int `json:"totalBytes"` 444 } `json:"progress"` 445 StartTimestamp time.Time `json:"startTimestamp"` 446 } `json:"status"` 447 } 448 449 type MySQLBackupModel struct { 450 APIVersion string `json:"apiVersion"` 451 Kind string `json:"kind"` 452 Metadata struct { 453 Annotations struct { 454 KopfZalandoOrgLastHandledConfiguration string `json:"kopf.zalando.org/last-handled-configuration"` 455 KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"` 456 } `json:"annotations"` 457 CreationTimestamp time.Time `json:"creationTimestamp"` 458 Generation int `json:"generation"` 459 Name string `json:"name"` 460 Namespace string `json:"namespace"` 461 ResourceVersion string `json:"resourceVersion"` 462 UID string `json:"uid"` 463 } `json:"metadata"` 464 Spec struct { 465 AddTimestampToBackupDirectory bool `json:"addTimestampToBackupDirectory"` 466 BackupProfile struct { 467 DumpInstance struct { 468 Storage struct { 469 S3 struct { 470 BucketName string `json:"bucketName"` 471 Config string `json:"config"` 472 Endpoint string `json:"endpoint"` 473 Prefix string `json:"prefix"` 474 Profile string `json:"profile"` 475 } `json:"s3"` 476 } `json:"storage"` 477 } `json:"dumpInstance"` 478 Name string `json:"name"` 479 } `json:"backupProfile"` 480 ClusterName string `json:"clusterName"` 481 DeleteBackupData bool `json:"deleteBackupData"` 482 } `json:"spec"` 483 Status struct { 484 Bucket string `json:"bucket"` 485 CompletionTime time.Time `json:"completionTime"` 486 ElapsedTime string `json:"elapsedTime"` 487 Method string `json:"method"` 488 Output string `json:"output"` 489 Source string `json:"source"` 490 StartTime time.Time `json:"startTime"` 491 Status string `json:"status"` 492 } `json:"status"` 493 } 494 495 type InnoDBIcsModel struct { 496 APIVersion string `json:"apiVersion"` 497 Kind string `json:"kind"` 498 Metadata struct { 499 Annotations struct { 500 KopfZalandoOrgLastHandledConfiguration string `json:"kopf.zalando.org/last-handled-configuration"` 501 MetaHelmShReleaseName string `json:"meta.helm.sh/release-name"` 502 MetaHelmShReleaseNamespace string `json:"meta.helm.sh/release-namespace"` 503 MysqlOracleComClusterInfo string `json:"mysql.oracle.com/cluster-info"` 504 MysqlOracleComMysqlOperatorVersion string `json:"mysql.oracle.com/mysql-operator-version"` 505 } `json:"annotations"` 506 CreationTimestamp time.Time `json:"creationTimestamp"` 507 Finalizers []string `json:"finalizers"` 508 Generation int `json:"generation"` 509 Labels struct { 510 AppKubernetesIoManagedBy string `json:"app.kubernetes.io/managed-by"` 511 } `json:"labels"` 512 Name string `json:"name"` 513 Namespace string `json:"namespace"` 514 ResourceVersion string `json:"resourceVersion"` 515 UID string `json:"uid"` 516 } `json:"metadata"` 517 Spec struct { 518 BaseServerID int `json:"baseServerId"` 519 ImagePullPolicy string `json:"imagePullPolicy"` 520 ImageRepository string `json:"imageRepository"` 521 Instances int `json:"instances"` 522 PodSpec struct { 523 Affinity struct { 524 PodAntiAffinity struct { 525 PreferredDuringSchedulingIgnoredDuringExecution []struct { 526 PodAffinityTerm struct { 527 LabelSelector struct { 528 MatchLabels struct { 529 AppKubernetesIoInstance string `json:"app.kubernetes.io/instance"` 530 AppKubernetesIoName string `json:"app.kubernetes.io/name"` 531 } `json:"matchLabels"` 532 } `json:"labelSelector"` 533 TopologyKey string `json:"topologyKey"` 534 } `json:"podAffinityTerm"` 535 Weight int `json:"weight"` 536 } `json:"preferredDuringSchedulingIgnoredDuringExecution"` 537 } `json:"podAntiAffinity"` 538 } `json:"affinity"` 539 Containers []struct { 540 Name string `json:"name"` 541 VolumeMounts []struct { 542 MountPath string `json:"mountPath"` 543 Name string `json:"name"` 544 SubPath string `json:"subPath"` 545 } `json:"volumeMounts"` 546 } `json:"containers"` 547 InitContainers []struct { 548 Name string `json:"name"` 549 VolumeMounts []struct { 550 MountPath string `json:"mountPath"` 551 Name string `json:"name"` 552 SubPath string `json:"subPath"` 553 } `json:"volumeMounts"` 554 } `json:"initContainers"` 555 Volumes []struct { 556 ConfigMap struct { 557 DefaultMode int `json:"defaultMode"` 558 Items []struct { 559 Key string `json:"key"` 560 Path string `json:"path"` 561 } `json:"items"` 562 Name string `json:"name"` 563 } `json:"configMap"` 564 Name string `json:"name"` 565 } `json:"volumes"` 566 } `json:"podSpec"` 567 Router struct { 568 Instances int `json:"instances"` 569 PodSpec struct { 570 Affinity struct { 571 PodAntiAffinity struct { 572 PreferredDuringSchedulingIgnoredDuringExecution []struct { 573 PodAffinityTerm struct { 574 LabelSelector struct { 575 MatchLabels struct { 576 AppKubernetesIoInstance string `json:"app.kubernetes.io/instance"` 577 AppKubernetesIoName string `json:"app.kubernetes.io/name"` 578 } `json:"matchLabels"` 579 } `json:"labelSelector"` 580 TopologyKey string `json:"topologyKey"` 581 } `json:"podAffinityTerm"` 582 Weight int `json:"weight"` 583 } `json:"preferredDuringSchedulingIgnoredDuringExecution"` 584 } `json:"podAntiAffinity"` 585 } `json:"affinity"` 586 } `json:"podSpec"` 587 } `json:"router"` 588 SecretName string `json:"secretName"` 589 ServiceAccountName string `json:"serviceAccountName"` 590 TLSUseSelfSigned bool `json:"tlsUseSelfSigned"` 591 Version string `json:"version"` 592 } `json:"spec"` 593 Status struct { 594 Cluster struct { 595 LastProbeTime time.Time `json:"lastProbeTime"` 596 OnlineInstances int `json:"onlineInstances"` 597 Status string `json:"status"` 598 } `json:"cluster"` 599 CreateTime time.Time `json:"createTime"` 600 Kopf struct { 601 Progress struct { 602 } `json:"progress"` 603 } `json:"kopf"` 604 } `json:"status"` 605 } 606 607 // Variables used across backup components 608 var ( 609 VeleroNameSpace string 610 VeleroOpenSearchSecretName string 611 VeleroMySQLSecretName string 612 RancherSecretName string 613 OciBucketID string 614 OciBucketName string 615 OciOsAccessKey string 616 OciOsAccessSecretKey string 617 OciCompartmentID string 618 OciNamespaceName string 619 BackupResourceName string 620 BackupOpensearchName string 621 BackupRancherName string 622 BackupMySQLName string 623 RestoreOpensearchName string 624 RestoreRancherName string 625 RestoreMySQLName string 626 BackupRegion string 627 BackupOpensearchStorageName string 628 BackupMySQLStorageName string 629 BackupID string 630 RancherURL string 631 RancherBackupFileName string 632 RancherUserIDList []string 633 RancherUserNameList []string 634 KeyCloakUserIDList []string 635 MySQLBackupHelmFileName string 636 OciCliTenancy string 637 OciCliUser string 638 OciCliFingerprint string 639 OciCliKeyFile string 640 KeyCloakReplicaCount int32 641 MySQLBackupMode string 642 )