Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vsphere provider, add IPAM provider type #88

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const customProviderSpec = {
version: ''
};

const providerTypes = ['infrastructure', 'bootstrap', 'controlPlane', 'addon' ];
const providerTypes = ['infrastructure', 'bootstrap', 'controlPlane', 'addon', 'ipam', 'runtimeextension', 'core'];

interface Secret {
metadata: {
Expand Down Expand Up @@ -95,9 +95,7 @@ export default defineComponent({
});
},
data() {
const providerDetails: Provider = PROVIDER_TYPES.find(p => p.id === this.provider) || {
needCredentials: false, disabled: false, id: '0'
};
const providerDetails: Provider = PROVIDER_TYPES.find(p => p.id === this.provider) || { disabled: false, id: '0' };

return {
loading: true,
Expand All @@ -108,8 +106,8 @@ export default defineComponent({
{ path: 'spec.fetchConfig.url', rules: ['url'] },
],
allNamespaces: [],
needCredential: providerDetails?.needCredentials || false,
credentialComponent: providerDetails?.credential,

};
},
computed: {
Expand All @@ -122,10 +120,12 @@ export default defineComponent({
};
},
typeOptions() {
return providerTypes.map((type)=>{return {label: this.t(`capi.provider.type.${type}.label`), value: type}});
},
return providerTypes.map((type) => {
return { label: this.t(`capi.provider.type.${ type }.label`), value: type };
});
},
showForm() {
return !!this.value.spec.credentials.rancherCloudCredentialNamespaceName || !this.needCredential;
return !!this.value.spec.credentials.rancherCloudCredentialNamespaceName || !this.credentialComponent;
},
isCreate() {
return this.mode === _CREATE;
Expand All @@ -146,7 +146,7 @@ export default defineComponent({
return this.isEdit && (this.hasFeatures || this.hasVariables);
},
waitingForCredential() {
return this.needCredential && !this.value.spec.credentials.rancherCloudCredentialNamespaceName;
return this.credentialComponent && !this.value.spec.credentials.rancherCloudCredentialNamespaceName;
}
},
methods: {
Expand Down Expand Up @@ -212,7 +212,7 @@ export default defineComponent({
if ( this.errors ) {
clear(this.errors);
}
if ( !this.needCredential && !this.value.spec?.credentials?.rancherCloudCredentialNamespaceName ) {
if ( !this.credentialComponent && !this.value.spec?.credentials?.rancherCloudCredentialNamespaceName ) {
this.value.spec.credentials = null;
}
try {
Expand Down Expand Up @@ -316,18 +316,18 @@ export default defineComponent({
</div>
</div>
</div>
<div v-if="needCredential" class="mb-40" />
<div v-if="credentialComponent" class="mb-40" />
<h2 v-if="hasFeatures || hasVariables" class="mb-20">
<t k="capi.provider.secret.title" />
</h2>
<div v-if="needCredential">
<div v-if="credentialComponent">
<h3 class="mb-20">
<t k="capi.provider.cloudCredential.title" />
</h3>
<SelectCredential
v-model="value.spec.credentials.rancherCloudCredentialNamespaceName"
:mode="mode"
:provider="provider"
:provider="credentialComponent"
:cancel="cancelCredential"
:showing-form="showForm"
class="mb-40"
Expand Down
6 changes: 6 additions & 0 deletions pkg/capi/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ capi:
label: Control Plane
addon:
label: Add-On
ipam:
label: IPAM
runtimeextension:
label: Runtime Extension
core:
label: Core
version:
label: Version
placeholder: eg. v1.0.0
Expand Down
20 changes: 8 additions & 12 deletions pkg/capi/types/capi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,25 @@ export interface ClusterClass {
export interface Provider {
id: string,
disabled: boolean,
needCredentials: boolean
credential?: string
}

export const PROVIDER_TYPES: Provider[] = [
{
id: 'aws', disabled: false, needCredentials: true
id: 'aws', disabled: false, credential: 'aws'
},
{
id: 'azure', disabled: false, needCredentials: true
id: 'azure', disabled: false, credential: 'azure'
},
{
id: 'digitalocean', disabled: false, needCredentials: true
id: 'digitalocean', disabled: false, credential: 'digitalocean'
},
{ id: 'docker', disabled: false },
{
id: 'docker', disabled: false, needCredentials: false
id: 'gcp', disabled: false, credential: 'gcp'
},
{
id: 'gcp', disabled: false, needCredentials: true
},
{
id: 'vsphere', disabled: false, needCredentials: true
},
{
id: 'custom', disabled: false, needCredentials: false
id: 'vsphere', disabled: false, credential: 'vmwarevsphere'
},
{ id: 'custom', disabled: false },
];