index.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import { ProviderTypes } from "@src/@types/Providers";
  15. import DefaultConnectionSchemaPlugin from "./default/ConnectionSchemaPlugin";
  16. import AzureConnectionSchemaPlugin from "./azure/ConnectionSchemaPlugin";
  17. import OpenstackConnectionSchemaPlugin from "./openstack/ConnectionSchemaPlugin";
  18. import VHIConnectionSchemaPlugin from "./vhi/ConnectionSchemaPlugin";
  19. import OciConnectionSchemaPlugin from "./oci/ConnectionSchemaPlugin";
  20. import OpcaConnectionSchemaPlugin from "./opca/ConnectionSchemaPlugin";
  21. import O3cConnectionSchemaPlugin from "./o3c/ConnectionSchemaPlugin";
  22. import KubevirtConnectionSchemaPlugin from "./kubevirt/ConnectionSchemaPlugin";
  23. import HarvesterConnectionSchemaPlugin from "./harvester/ConnectionSchemaPlugin";
  24. import LibvirtConnectionSchemaPlugin from "./libvirt/ConnectionSchemaPlugin";
  25. import NutanixConnectionSchemaPlugin from "./nutanix/ConnectionSchemaPlugin";
  26. import DefaultContentPlugin from "./default/ContentPlugin";
  27. import AzureContentPlugin from "./azure/ContentPlugin";
  28. import OpenstackContentPlugin from "./openstack/ContentPlugin";
  29. import VHIContentPlugin from "./vhi/ContentPlugin";
  30. import MetalContentPlugin from "./metal/ContentPlugin";
  31. import DefaultOptionsSchemaPlugin from "./default/OptionsSchemaPlugin";
  32. import AwsOptionsSchemaPlugin from "./aws/OptionsSchemaPlugin";
  33. import OvmOptionsSchemaPlugin from "./ovm/OptionsSchemaPlugin";
  34. import VmwareOptionsSchemaPlugin from "./vmware_vsphere/OptionsSchemaPlugin";
  35. import OpenstackOptionsSchemaPlugin from "./openstack/OptionsSchemaPlugin";
  36. import VHIOptionsSchemaPlugin from "./vhi/OptionsSchemaPlugin";
  37. import OlvmOptionsSchemaPlugin from "./olvm/OptionsSchemaPlugin";
  38. import RhevOptionsSchemaPlugin from "./rhev/OptionsSchemaPlugin";
  39. import AzureOptionsSchemaPlugin from "./azure/OptionsSchemaPlugin";
  40. import DefaultInstanceInfoPlugin from "./default/InstanceInfoPlugin";
  41. import OciInstanceInfoPlugin from "./oci/InstanceInfoPlugin";
  42. import DefaultMinionPoolSchemaPlugin from "./default/MinionPoolSchemaPlugin";
  43. import OpenstackMinionPoolSchemaPlugin from "./openstack/MinionPoolSchemaPlugin";
  44. import VHIMinionPoolSchemaPlugin from "./vhi/MinionPoolSchemaPlugin";
  45. const hasKey = <O extends object>(obj: O, key: keyof any): key is keyof O =>
  46. key in obj;
  47. export const ConnectionSchemaPlugin = {
  48. for: (provider: ProviderTypes) => {
  49. const map = {
  50. default: new DefaultConnectionSchemaPlugin(),
  51. azure: new AzureConnectionSchemaPlugin(),
  52. openstack: new OpenstackConnectionSchemaPlugin(),
  53. vhi: new VHIConnectionSchemaPlugin(),
  54. oci: new OciConnectionSchemaPlugin(),
  55. opca: new OpcaConnectionSchemaPlugin(),
  56. o3c: new O3cConnectionSchemaPlugin(),
  57. kubevirt: new KubevirtConnectionSchemaPlugin(),
  58. harvester: new HarvesterConnectionSchemaPlugin(),
  59. libvirt: new LibvirtConnectionSchemaPlugin(),
  60. sap_libvirt: new LibvirtConnectionSchemaPlugin(),
  61. nutanix: new NutanixConnectionSchemaPlugin(),
  62. };
  63. if (hasKey(map, provider)) {
  64. return map[provider];
  65. }
  66. return map.default;
  67. },
  68. };
  69. export const OptionsSchemaPlugin = {
  70. for: (provider: ProviderTypes) => {
  71. const map = {
  72. default: new DefaultOptionsSchemaPlugin(),
  73. aws: new AwsOptionsSchemaPlugin(),
  74. oracle_vm: new OvmOptionsSchemaPlugin(),
  75. openstack: new OpenstackOptionsSchemaPlugin(),
  76. vhi: new VHIOptionsSchemaPlugin(),
  77. vmware_vsphere: new VmwareOptionsSchemaPlugin(),
  78. olvm: new OlvmOptionsSchemaPlugin(),
  79. rhev: new RhevOptionsSchemaPlugin(),
  80. azure: new AzureOptionsSchemaPlugin(),
  81. };
  82. if (hasKey(map, provider)) {
  83. return map[provider];
  84. }
  85. return map.default;
  86. },
  87. };
  88. export const ContentPlugin = {
  89. for: (provider: ProviderTypes) => {
  90. const map = {
  91. default: DefaultContentPlugin,
  92. azure: AzureContentPlugin,
  93. openstack: OpenstackContentPlugin,
  94. vhi: VHIContentPlugin,
  95. metal: MetalContentPlugin,
  96. };
  97. if (hasKey(map, provider)) {
  98. return map[provider];
  99. }
  100. return map.default;
  101. },
  102. };
  103. export const InstanceInfoPlugin = {
  104. for: (provider: ProviderTypes) => {
  105. const map = {
  106. default: new DefaultInstanceInfoPlugin(),
  107. oci: new OciInstanceInfoPlugin(),
  108. };
  109. if (hasKey(map, provider)) {
  110. return map[provider];
  111. }
  112. return map.default;
  113. },
  114. };
  115. export const MinionPoolSchemaPlugin = {
  116. for: (provider: ProviderTypes) => {
  117. const map = {
  118. default: new DefaultMinionPoolSchemaPlugin(),
  119. openstack: new OpenstackMinionPoolSchemaPlugin(),
  120. vhi: new VHIMinionPoolSchemaPlugin(),
  121. };
  122. if (hasKey(map, provider)) {
  123. return map[provider];
  124. }
  125. return map.default;
  126. },
  127. };