{pattern}
.'
uniqueItems: '"{key}" may not contain duplicate elements.'
+ version: Version format must match format for this provisioner.
diff --git a/pkg/capi/types/capi.ts b/pkg/capi/types/capi.ts
index f75f6fe..7ea379c 100644
--- a/pkg/capi/types/capi.ts
+++ b/pkg/capi/types/capi.ts
@@ -8,3 +8,60 @@ export const CAPI = {
CLUSTER_CLASS: 'cluster.x-k8s.io.clusterclass',
PROVIDER: 'operator.cluster.x-k8s.io.infrastructureprovider',
};
+
+// Includes bootrstap providers, control plane providers, and add-on providers:
+// BOOTSTRAP_PROVIDERS = ['kubeadm', 'talos', 'microk8s', 'ocne', 'kubekey-k3s', 'rke2'];
+// CP_PROVIDERS = ['kubeadm', 'talos', 'microk8s', 'nested', 'ocne', 'kubekey-k3s', 'kamaji', 'rke2'];
+// ADD_ON_PROVIDERS = ['helm'];
+export const NON_INFRASTRUCTURE_PROVIDERS = ['kubeadm', 'talos', 'microk8s', 'nested', 'ocne', 'kubekey-k3s', 'kamaji', 'rke2', 'helm'];
+
+export const CP_VERSIONS = {
+ 'kubekey-k3s': ['k3s1', 'k3s2'],
+ rke2: ['rke2r1', 'rke2r2']
+};
+
+export const CREDENTIALS_UPDATE_REQUIRED = ['aks'];
+export const CREDENTIALS_NOT_REQUIRED = ['docker'];
+interface Worker {
+ name: String,
+ class: String
+}
+
+export interface CAPIClusterTopology {
+ version: String,
+ class: String,
+ workers: {
+ machineDeployments: Worker[],
+ machinePools: Worker[]
+ }
+}
+
+export interface CAPIClusterNetwork {
+ apiServerPort?: Number,
+ pods?: {
+ cidrBlocks: String[]
+ },
+ serviceDomain?: String,
+ services?: {
+ cidrBlocks: String[]
+ },
+}
+
+export interface ClusterClass {
+ metadata: {
+ name: String,
+ annotations: Object
+ },
+ spec: {
+ infrastructure: Object,
+ workers: Object,
+ controlPlane: Object
+ }
+}
+
+export interface InfrastructureProvider {
+ metadata: {
+ name: String,
+ annotations: Object
+ }
+}
diff --git a/pkg/capi/util/validators.ts b/pkg/capi/util/validators.ts
index b932b8b..bb79b32 100644
--- a/pkg/capi/util/validators.ts
+++ b/pkg/capi/util/validators.ts
@@ -1,6 +1,7 @@
import { Validator, ValidationOptions } from '@shell/utils/validators/formRules';
import { Translation } from '@shell/types/t';
import isEmpty from 'lodash/isEmpty';
+import { CP_VERSIONS } from '@pkg/capi/types/capi';
// const stringFormats = {
// // this is a mongodb id - requires library to validate?
@@ -120,3 +121,21 @@ export const openAPIV3SchemaValidators = function(t: Translation, { key = 'Value
};
export const isDefined = (val: any) => (val || val === false) && !isEmpty(val);
+export const versionTest = function(t: Translation, type: String): RegExp {
+ let ending = '';
+
+ if (CP_VERSIONS[type]) {
+ ending = `\\+(${ CP_VERSIONS[type].join('|') })`;
+ }
+
+ return new RegExp(`^v(\\d+.){2}\\d+${ ending }$`);
+};
+
+export const versionValidator = function(t: Translation, type: String): Validator[] {
+ const out = [] as any[];
+ const test = versionTest(t, type);
+
+ out.push((val: String) => val && !val.match(test) ? t('validation.version') : undefined);
+
+ return out;
+};