Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed Dec 3, 2024
1 parent de7c83d commit 29ac1be
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 63 deletions.
35 changes: 19 additions & 16 deletions pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ export default {
const resource = CAPI.RANCHER_CLUSTER;
return {
isAdmin: isAdminUser(this.$store.getters),
navigating: false,
hciDashboard: HCI.DASHBOARD,
isAdmin: isAdminUser(this.$store.getters),
navigating: false,
hciDashboard: HCI.DASHBOARD,
resource,
hResource: HCI.CLUSTER,
realSchema: this.$store.getters['management/schemaFor'](CAPI.RANCHER_CLUSTER),
hciClusters: [],
mgmtClusters: [],
harvesterRepository: null,
harvesterLatestVersion: null,
harvesterRepositoryError: false,
hResource: HCI.CLUSTER,
realSchema: this.$store.getters['management/schemaFor'](CAPI.RANCHER_CLUSTER),
hciClusters: [],
mgmtClusters: [],
harvesterRepository: null,
harvesterLatestVersion: null,
harvesterRepositoryError: false,
harvesterExtensionInstallError: false,
harvesterExtensionUpdateError: false,
clusterRepoLink: {
harvesterExtensionUpdateError: false,
clusterRepoLink: {
name: 'c-cluster-product-resource',
params: {
cluster: 'local',
Expand Down Expand Up @@ -118,7 +118,7 @@ export default {
const missingRepository = !!extension && !this.harvesterRepository;
const isLatestVersionAvailable = !!this.harvesterLatestVersion;
const action = async (btnCb) => {
const action = async(btnCb) => {
const action = `${ !extension ? 'install' : 'update' }HarvesterExtension`;
await this[action](btnCb);
Expand Down Expand Up @@ -147,7 +147,7 @@ export default {
let key = `harvesterManager.extension.${ action }.${ label }`;
if (label === 'prompt' && !this.isAdmin) {
key = 'harvesterManager.extension.admin'
key = 'harvesterManager.extension.admin';
}
return {
Expand All @@ -161,7 +161,7 @@ export default {
missingRepository,
isLatestVersionAvailable,
toInstall: !extension,
toUpdate: missingRepository || isLatestVersionAvailable,
toUpdate: missingRepository || isLatestVersionAvailable,
action,
panelLabel,
hasErrors,
Expand Down Expand Up @@ -391,7 +391,10 @@ export default {
</div>
</template>
<template v-if="harvester.hasErrors || harvester.toInstall || harvester.toUpdate">
<div v-if="harvester.hasErrors || harvester.toInstall || !rows || !rows.length" class="tagline">
<div
v-if="harvester.hasErrors || harvester.toInstall || !rows || !rows.length"
class="tagline"
>
<div class="extensions-separator" />
</div>
<div class="tagline extension-warning-panel">
Expand Down
32 changes: 14 additions & 18 deletions pkg/harvester-manager/types.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
import { UI_PLUGINS_REPOS } from '@shell/config/uiplugins';

export const HARVESTER_CHART = {
name: 'harvester',
version: '',
repoType: 'cluster',
repoName: 'harvester',
name: 'harvester',
version: '',
repoType: 'cluster',
repoName: 'harvester',
};

export const HARVESTER_COMMUNITY_REPO = {
type: 'catalog.cattle.io.clusterrepo',
metadata: {
name: 'harvester',
},
spec: {
type: 'catalog.cattle.io.clusterrepo',
metadata: { name: 'harvester' },
spec: {
clientSecret: null,
gitRepo: 'https://github.com/harvester/harvester-ui-extension',
gitBranch: 'gh-pages'
gitRepo: 'https://github.com/harvester/harvester-ui-extension',
gitBranch: 'gh-pages'
}
};

export const HARVESTER_RANCHER_REPO = {
type: 'catalog.cattle.io.clusterrepo',
metadata: {
name: 'harvester',
},
spec: {
type: 'catalog.cattle.io.clusterrepo',
metadata: { name: 'harvester' },
spec: {
clientSecret: null,
gitRepo: UI_PLUGINS_REPOS.OFFICIAL.URL,
gitBranch: UI_PLUGINS_REPOS.OFFICIAL.BRANCH,
gitRepo: UI_PLUGINS_REPOS.OFFICIAL.URL,
gitBranch: UI_PLUGINS_REPOS.OFFICIAL.BRANCH,
}
};
60 changes: 31 additions & 29 deletions shell/utils/ui-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type HelmChart = any;

/**
* Wait for a given UI Extension to be available
*
*
* @param store Vue store
* @param name Name of the extension
* @returns the extension object when available, null if timed out waiting for it to be available
Expand Down Expand Up @@ -43,13 +43,13 @@ export async function waitForUIExtension(store: any, name: string): Promise<any>
return null;
}

await new Promise(r => setTimeout(r, RETRY_WAIT));
await new Promise((resolve) => setTimeout(resolve, RETRY_WAIT));
}
}

/**
* Wait for a given UI Extension package to be available
*
*
* @param store Vue store
* @param extension Extension object
* @returns true when available, false if timed out waiting for it to be available
Expand Down Expand Up @@ -78,13 +78,13 @@ export async function waitForUIPackage(store: any, extension: any): Promise<bool
return false;
}

await new Promise(r => setTimeout(r, RETRY_WAIT));
await new Promise((resolve) => setTimeout(resolve, RETRY_WAIT));
}
}

/**
* Install Helm Chart
*
*
* Note: This should really be provided via the shell rather than copied here
*/
export async function installHelmChart(repo: any, chart: any, values: any = {}, namespace = 'default', action: Action = 'install') {
Expand Down Expand Up @@ -112,14 +112,14 @@ export async function installHelmChart(repo: any, chart: any, values: any = {},
upgrade operation.
*/
const installRequest = {
charts: [chartInstall],
noHooks: false,
timeout: '600s',
wait: true,
charts: [chartInstall],
noHooks: false,
timeout: '600s',
wait: true,
namespace,
projectId: '',
projectId: '',
disableOpenAPIValidation: false,
skipCRDs: false,
skipCRDs: false,
};

// Install the Chart
Expand All @@ -130,20 +130,24 @@ export async function installHelmChart(repo: any, chart: any, values: any = {},

/**
* Get the Helm repository object
*
*
* @param store Vue store
* @param url The url of the Helm repostitory
* @param branch The branch of the Helm repostitory
* @returns HelmRepository
*/
export async function getHelmRepository(store: any, url: string, branch?: string): Promise<HelmRepository> {
if (store.getters['management/schemaFor'](CATALOG.CLUSTER_REPO)) {
const repos = await store.dispatch('management/findAll', { type: CATALOG.CLUSTER_REPO, opt: { force: true, watch:false } });
const repos = await store.dispatch('management/findAll', { type: CATALOG.CLUSTER_REPO, opt: { force: true, watch: false } });

if (branch) {
return repos.find((r: any) => { return r.spec?.gitRepo === url });
return repos.find((r: any) => {
return r.spec?.gitRepo === url;
});
} else {
return repos.find((r: any) => { return r.spec?.url === url });
return repos.find((r: any) => {
return r.spec?.url === url;
});
}
} else {
throw new Error('No permissions');
Expand All @@ -153,26 +157,26 @@ export async function getHelmRepository(store: any, url: string, branch?: string
/**
* Refresh the Helm repository
* Ensures that we find the latest extension versions
*
*
* @param repository The Helm repository
*/
export async function refreshHelmRepository(repository: any): Promise<void> {
const now = (new Date()).toISOString().replace(/\.\d+Z$/, 'Z');

repository.spec.forceUpdate = now;

await repository.save();

await repository.waitForState('active', 10000, 1000);

await new Promise(r => setTimeout(r, 2000));
await new Promise((resolve) => setTimeout(resolve, 2000));
}

/**
* Ensure the required Helm Repository exits, if it does not, add it with the specified name
*
*
* Wait until the newly added repository has been downloaded
*
*
* @param store Vue store
* @param url The url of the Helm repostitory
* @param name The name of the cluster repository
Expand All @@ -185,11 +189,9 @@ export async function ensureHelmRepository(store: any, url: string, name: string
// Add the Helm repository, if it is not there
if (!helmRepo) {
const data = {
type: CATALOG.CLUSTER_REPO,
metadata: {
name
},
spec: {} as any
type: CATALOG.CLUSTER_REPO,
metadata: { name },
spec: {} as any
};

if (branch) {
Expand Down Expand Up @@ -233,7 +235,7 @@ export async function ensureHelmRepository(store: any, url: string, name: string
throw new Error('Failed to add Helm Chart Repository');
}

await new Promise(r => setTimeout(r, RETRY_WAIT));
await new Promise((resolve) => setTimeout(resolve, RETRY_WAIT));
}

fetched = true;
Expand All @@ -245,7 +247,7 @@ export async function ensureHelmRepository(store: any, url: string, name: string

/**
* Get the given Helm Chart from the specified Helm Repository
*
*
* @param store Vue store
* @param repository Helm Repository
* @param chartName Helm Chart name
Expand All @@ -254,8 +256,8 @@ export async function ensureHelmRepository(store: any, url: string, name: string
export async function getHelmChart(store: any, repository: any, chartName: string): Promise<HelmChart> {
const versionInfo = await store.dispatch('management/request', {
method: 'GET',
url: `${repository?.links?.info}&chartName=${ chartName }`,
url: `${ repository?.links?.info }&chartName=${ chartName }`,
});

return versionInfo.chart;
}
}

0 comments on commit 29ac1be

Please sign in to comment.