Skip to content

Commit c243bb7

Browse files
authored
Merge pull request #17726 from a110605/issue_17601
refactor: rename communityRepoRegexes to harvesterRepoRegexes and update related logic
2 parents 0f9542e + 238fe32 commit c243bb7

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ import { NAME as APP_PRODUCT } from '@shell/config/product/apps';
1515
import { BLANK_CLUSTER } from '@shell/store/store-types.js';
1616
import { UI_PLUGIN_NAMESPACE } from '@shell/config/uiplugins';
1717
import {
18-
HARVESTER_CHART, HARVESTER_COMMUNITY_REPO, HARVESTER_RANCHER_REPO, communityRepoRegexes, HARVESTER_CATALOG_IMAGES
18+
HARVESTER_CHART, HARVESTER_COMMUNITY_REPO, HARVESTER_RANCHER_REPO, harvesterRepoRegexes, HARVESTER_CATALOG_IMAGES
1919
} from '../types';
2020
import {
2121
getLatestExtensionVersion,
22-
getHelmRepositoryExact,
2322
getHelmRepositoryMatch,
2423
createHelmRepository,
2524
refreshHelmRepository,
@@ -67,7 +66,6 @@ export default {
6766
this.mgmtClusters = hash.mgmtClusters;
6867
6968
this.harvesterRepository = await this.getHarvesterRepository();
70-
7169
this.kubeVersion = this.$store.getters['management/byId'](MANAGEMENT.CLUSTER, 'local')?.kubernetesVersionBase || '';
7270
},
7371
@@ -107,6 +105,7 @@ export default {
107105
},
108106
109107
watch: {
108+
// watch harvester repository, if it changes to a valid one, then we will check if there is an update for harvester extension, which will trigger the extension update message in the UI
110109
async harvesterRepository(neu) {
111110
if (neu) {
112111
await refreshHelmRepository(this.$store, neu.spec.gitRepo || neu.spec.url);
@@ -243,11 +242,7 @@ export default {
243242
methods: {
244243
async getHarvesterRepository() {
245244
try {
246-
if (isRancherPrime()) {
247-
return await getHelmRepositoryExact(this.$store, HARVESTER_REPO.gitRepo);
248-
} else {
249-
return await getHelmRepositoryMatch(this.$store, communityRepoRegexes, HARVESTER_CATALOG_IMAGES);
250-
}
245+
return await getHelmRepositoryMatch(this.$store, harvesterRepoRegexes, HARVESTER_CATALOG_IMAGES);
251246
} catch (error) {
252247
this.harvesterRepositoryError = true;
253248
}

pkg/harvester-manager/types.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { UI_PLUGINS_REPOS } from '@shell/config/uiplugins';
22

33
export const HARVESTER_CATALOG_IMAGES = ['ui-plugin-catalog', 'ui-extension-harvester-ui-extension'];
44

5-
export const communityRepoRegexes = [
6-
/^https:\/\/github\.com\/.*\/harvester-ui-extension+/g,
7-
/^https:\/\/.*\.github\.io\/harvester-ui-extension+/g,
5+
export const harvesterRepoRegexes = [
6+
/^https:\/\/github\.com\/.*\/harvester-ui-extension+/g, // e.g. https://github.com/harvester/harvester-ui-extension
7+
/^https:\/\/.*\.github\.io\/harvester-ui-extension+/g, // e.g. https://github.io/harvester/harvester-ui-extension
8+
UI_PLUGINS_REPOS.OFFICIAL.URL, // rancher/ui-plugin-charts
89
];
910

1011
export const HARVESTER_CHART = {

shell/utils/uiplugins.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,19 @@ export async function getHelmRepositoryExact(store: any, url: string): Promise<H
180180
/**
181181
*
182182
* @param store Vue store
183-
* @param urlRegexes Regex to match a community repository
183+
* @param urlRegexes Regex to match against the repository's urls
184184
* @param catalogImages Catalog images to match against the repository's labels
185185
* @returns HelmRepository
186186
*/
187187
export async function getHelmRepositoryMatch(store: any, urlRegexes: string[], catalogImages: string[]): Promise<HelmRepository> {
188188
return await getHelmRepository(store, (repository: any) => {
189-
// if installed from rancher/ui-plugin-catalog or rancher/ui-extension-harvester-ui-extension
190189
const catalog = repository?.metadata?.labels?.[UI_PLUGIN_LABELS.CATALOG_IMAGE] || '';
191190

192-
if (catalogImages.includes(catalog)) {
191+
// if installed from rancher/ui-plugin-catalog or rancher/ui-extension-harvester-ui-extension
192+
if (catalog && catalogImages.includes(catalog)) {
193193
return true;
194194
}
195+
195196
const target = repository.spec?.gitBranch ? repository.spec?.gitRepo : repository.spec?.url;
196197

197198
return matchesSomeRegex(target, urlRegexes);

0 commit comments

Comments
 (0)