+
{{ variable.name }}
-
-
+
+
diff --git a/pkg/capi/components/CCVariables/index.vue b/pkg/capi/components/CCVariables/index.vue
index 5a5e7ee..511baf8 100644
--- a/pkg/capi/components/CCVariables/index.vue
+++ b/pkg/capi/components/CCVariables/index.vue
@@ -1,18 +1,14 @@
-
-
+
updateVariables(e, variableDef)"
@validation-passed="updateErrors"
/>
-
+
diff --git a/pkg/capi/components/CardGrid.vue b/pkg/capi/components/CardGrid.vue
index 5a8eae0..04c1099 100644
--- a/pkg/capi/components/CardGrid.vue
+++ b/pkg/capi/components/CardGrid.vue
@@ -1,24 +1,16 @@
-
diff --git a/pkg/capi/components/ClusterClassCard/index.vue b/pkg/capi/components/ClusterClassCard/index.vue
index b51a4d4..00be9b3 100644
--- a/pkg/capi/components/ClusterClassCard/index.vue
+++ b/pkg/capi/components/ClusterClassCard/index.vue
@@ -1,10 +1,8 @@
-
diff --git a/pkg/capi/components/ClusterListBanner.vue b/pkg/capi/components/ClusterListBanner.vue
index a0d1692..a91d281 100644
--- a/pkg/capi/components/ClusterListBanner.vue
+++ b/pkg/capi/components/ClusterListBanner.vue
@@ -31,4 +31,10 @@ export default {
};
-
+
+
+
diff --git a/pkg/capi/components/ExperimentalBanner.vue b/pkg/capi/components/ExperimentalBanner.vue
index 0610459..85f44ed 100644
--- a/pkg/capi/components/ExperimentalBanner.vue
+++ b/pkg/capi/components/ExperimentalBanner.vue
@@ -1,4 +1,4 @@
-
-
+
+
+
diff --git a/pkg/capi/edit/cluster.x-k8s.io.cluster/ClusterConfig.vue b/pkg/capi/edit/cluster.x-k8s.io.cluster/ClusterConfig.vue
index 152d1dc..334bec6 100644
--- a/pkg/capi/edit/cluster.x-k8s.io.cluster/ClusterConfig.vue
+++ b/pkg/capi/edit/cluster.x-k8s.io.cluster/ClusterConfig.vue
@@ -1,41 +1,34 @@
-
-
Date: Mon, 9 Dec 2024 08:53:54 -0800
Subject: [PATCH 2/4] fix capiprovider edit and prevent duplicate provider ids
---
.../ProviderConfig.vue | 6 ++--
.../index.vue | 36 +++++++++++++++----
pkg/capi/l10n/en-us.yaml | 3 +-
pkg/capi/util/validators.ts | 4 +--
4 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/pkg/capi/edit/turtles-capi.cattle.io.capiprovider/ProviderConfig.vue b/pkg/capi/edit/turtles-capi.cattle.io.capiprovider/ProviderConfig.vue
index 89cdc91..7ab0aca 100644
--- a/pkg/capi/edit/turtles-capi.cattle.io.capiprovider/ProviderConfig.vue
+++ b/pkg/capi/edit/turtles-capi.cattle.io.capiprovider/ProviderConfig.vue
@@ -105,7 +105,7 @@ export default {
fvExtraRules() {
return {
name: providerNameValidator(this.$store.getters['i18n/t']),
- version: providerVersionValidator(this.$store.getters['i18n/t'], this.isCustom),
+ version: providerVersionValidator(this.$store.getters['i18n/t']),
url: urlValidator(this.$store.getters['i18n/t'])
};
},
@@ -288,8 +288,8 @@ export default {
:mode="mode"
label-key="capi.provider.version.label"
placeholder-key="capi.provider.version.placeholder"
+ :tooltip="t('capi.provider.version.tooltip')"
:rules="fvGetAndReportPathRules('spec.version')"
- required
@update:value="$emit('update:value', {k: 'spec.version', val: $event})"
/>
@@ -325,7 +325,7 @@ export default {
id === name)) {
+ this.selectType('custom');
+ } else {
+ this.selectType(name);
}
},
@@ -45,7 +53,7 @@ export default {
const route = this.$route;
const subType = route?.query[SUB_TYPE] || null;
- return { subType };
+ return { subType, capiProviders: [] };
},
computed: {
@@ -54,7 +62,9 @@ export default {
const getters = this.$store.getters;
PROVIDER_TYPES?.forEach((provider) => {
- addType(provider.id, provider.disabled);
+ const disabled = provider.disabled || this.enabledProviderTypes.includes(provider.id);
+
+ addType(provider.id, disabled);
});
return out;
@@ -84,6 +94,18 @@ export default {
out.push(providerType);
}
+ },
+
+ enabledProviderTypes() {
+ return this.capiProviders.reduce((types, p) => {
+ const { name } = p?.spec || {};
+
+ if (!types.includes(name)) {
+ types.push(name);
+ }
+
+ return types;
+ }, []);
}
},
@@ -137,6 +159,8 @@ export default {
embedded-cluster-api feature flag must be disabled before installing the CAPI Turtles extension. Follow instructions in the documentation here to do so.
- turtlesNeeded: Either the user doesn't have permission to run the Turtles extension or the Turtles operator isn't installed. To learn how to install the Rancher Turtles extension, read the documentation.
+ turtlesNeeded: Either the user doesn't have permission to run the Turtles extension or the Turtles operator isn't installed. To learn how to install the Rancher Turtles extension, read the documentation.
autoImport:
label: CAPI Auto-Import
checkbox:
@@ -111,6 +111,7 @@ capi:
version:
label: Version
placeholder: eg. v1.0.0
+ tooltip: If unspecified, the latest version will be used.
fetchConfigURL:
label: URL
placeholder: https://github.com/example/releases/latest/client.yaml
diff --git a/pkg/capi/util/validators.ts b/pkg/capi/util/validators.ts
index 6b441b5..8ecdb87 100644
--- a/pkg/capi/util/validators.ts
+++ b/pkg/capi/util/validators.ts
@@ -159,8 +159,8 @@ export const urlValidator = function(t: Translation): Validator {
return (val: string) => val && !val.match(/^https?:\/\/(.*)$/) ? t('validation.url') : undefined;
};
-export const providerVersionValidator = function(t: Translation, required: boolean): Validator {
- return (val: string) => (required && !val) || (val && !val.match(/^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/)) ? t('validation.version') : undefined;
+export const providerVersionValidator = function(t: Translation): Validator {
+ return (val: string) => (val && !val.match(/^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/)) ? t('validation.version') : undefined;
};
export const providerNameValidator = function(t: Translation): Validator {
From 5a29863f716e2958ebe4f5114939be948cb9fc6e Mon Sep 17 00:00:00 2001
From: Nancy Butler <42977925+mantis-toboggan-md@users.noreply.github.com>
Date: Mon, 9 Dec 2024 15:01:14 -0800
Subject: [PATCH 3/4] fix creating a capi provider with no version
---
.../turtles-capi.cattle.io.capiprovider/ProviderConfig.vue | 6 ++++--
pkg/capi/edit/turtles-capi.cattle.io.capiprovider/index.vue | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/pkg/capi/edit/turtles-capi.cattle.io.capiprovider/ProviderConfig.vue b/pkg/capi/edit/turtles-capi.cattle.io.capiprovider/ProviderConfig.vue
index 7ab0aca..2389a50 100644
--- a/pkg/capi/edit/turtles-capi.cattle.io.capiprovider/ProviderConfig.vue
+++ b/pkg/capi/edit/turtles-capi.cattle.io.capiprovider/ProviderConfig.vue
@@ -38,7 +38,6 @@ const customProviderSpec = {
configSecret: { name: '' },
credentials: { rancherCloudCredentialNamespaceName: '' },
fetchConfig: { url: '' },
- version: ''
};
const providerTypes = ['infrastructure', 'bootstrap', 'controlPlane', 'addon', 'ipam', 'runtimeextension', 'core'];
@@ -203,6 +202,9 @@ export default {
if ( !this.credentialComponent && !this.value.spec?.credentials?.rancherCloudCredentialNamespaceName ) {
this.value.spec.credentials = null;
}
+ if (this.value?.spec?.version === '') {
+ delete this.value.spec.version;
+ }
try {
await this.save(btnCb, null);
} catch (err) {
@@ -325,7 +327,7 @@ export default {
{
const { name } = p?.spec || {};
- if (!types.includes(name)) {
+ if (!types.includes(name) && name !== 'custom') {
types.push(name);
}
From c6fd7068868e9f44ef945497f4298e9b9dff1132 Mon Sep 17 00:00:00 2001
From: Nancy Butler <42977925+mantis-toboggan-md@users.noreply.github.com>
Date: Mon, 9 Dec 2024 15:06:55 -0800
Subject: [PATCH 4/4] remove unused type files
---
.eslintrc.js | 1 -
.../models/cluster.x-k8s.io.clusterclass.js | 1 +
pkg/capi/types/capi.ts | 52 +------------------
pkg/capi/types/cluster.x-k8s.io.cluster.ts | 13 -----
pkg/capi/types/clusterClass.ts | 39 --------------
5 files changed, 2 insertions(+), 104 deletions(-)
delete mode 100644 pkg/capi/types/cluster.x-k8s.io.cluster.ts
delete mode 100644 pkg/capi/types/clusterClass.ts
diff --git a/.eslintrc.js b/.eslintrc.js
index 027d7c1..9407c14 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -8,7 +8,6 @@ module.exports = {
extends: [
'standard',
'eslint:recommended',
- // '@nuxtjs/eslint-config-typescript',
'plugin:cypress/recommended',
'plugin:vue/vue3-recommended',
],
diff --git a/pkg/capi/models/cluster.x-k8s.io.clusterclass.js b/pkg/capi/models/cluster.x-k8s.io.clusterclass.js
index 77ed8f3..3a293a1 100644
--- a/pkg/capi/models/cluster.x-k8s.io.clusterclass.js
+++ b/pkg/capi/models/cluster.x-k8s.io.clusterclass.js
@@ -33,6 +33,7 @@ export default class ClusterClass extends SteveModel {
saveYaml(yaml) {
const localCluster = this.$rootGetters['management/byId'](MANAGEMENT.CLUSTER, LOCAL_CLUSTER);
+
return localCluster.doAction('apply', { yaml });
}
}
diff --git a/pkg/capi/types/capi.ts b/pkg/capi/types/capi.ts
index 5dd7155..076c238 100644
--- a/pkg/capi/types/capi.ts
+++ b/pkg/capi/types/capi.ts
@@ -21,58 +21,8 @@ export const CP_VERSIONS = {
export const CREDENTIALS_UPDATE_REQUIRED = ['aks'];
export const CREDENTIALS_NOT_REQUIRED = ['docker'];
-export interface Worker {
- name: String,
- class: String
-}
-export interface CAPIClusterTopology {
- version: String,
- class: String,
- workers: {
- machineDeployments: Worker[],
- machinePools: Worker[]
- }
-}
-export interface CAPIClusterCPEndpoint {
- host: String,
- port: Number
-}
-
-export interface CAPIClusterNetwork {
- apiServerPort?: Number,
- pods?: {
- cidrBlocks: String[]
- },
- serviceDomain?: String,
- services?: {
- cidrBlocks: String[]
- },
-}
-
-export interface ClusterClass {
- id: string,
- metadata: {
- name: string,
- namespace: string,
- annotations?: {[key: string]: string}
- },
- spec: {
- infrastructure: Object,
- workers: {
- machinePools: [],
- machineDeployments: []
- },
- controlPlane: {ref: {name: string}}
- }
-}
-export interface Provider {
- id: string,
- disabled: boolean,
- credential?: string
-}
-
-export const PROVIDER_TYPES: Provider[] = [
+export const PROVIDER_TYPES = [
{
id: 'aws', disabled: false, credential: 'aws'
},
diff --git a/pkg/capi/types/cluster.x-k8s.io.cluster.ts b/pkg/capi/types/cluster.x-k8s.io.cluster.ts
deleted file mode 100644
index 9f857d5..0000000
--- a/pkg/capi/types/cluster.x-k8s.io.cluster.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-
-export interface CapiClusterVariable {
- name: string,
- value?: any
-}
-
-export interface CapiCluster {
- spec?: {
- topology?: {
- variables?: Array
- }
- }
-}
diff --git a/pkg/capi/types/clusterClass.ts b/pkg/capi/types/clusterClass.ts
deleted file mode 100644
index 0612cb7..0000000
--- a/pkg/capi/types/clusterClass.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-
-export interface ClusterClassVariable {
- name: string,
- required: boolean,
- schema: {
- openAPIV3Schema: {
- additionalProperties?: Map
- default?: any
- description?: string,
- enum?: Array,
- example?: any,
- exclusiveMaximum?: boolean,
- exclusiveMinimum?: boolean,
- format?: string,
- items?: Array,
- maxItems?: number,
- maxLength?: number,
- maximum?: number,
- minItems?: number,
- minLength?: number
- minimum?: number,
- pattern?: string,
- properties?: Map,
- required?: Array,
- type: string,
- uniqueItems?: boolean,
- ['x-kubernetes-preserve-unknown-fields']?: boolean
- }
- }
-}
-
-export interface ClusterClassSpec {
- variables: Array
-}
-
-export interface ClusterClass {
-name: string,
-spec: ClusterClassSpec
-}