Skip to content

Commit

Permalink
Merge pull request #518 from jordojordo/2.8-install
Browse files Browse the repository at this point in the history
Fix fetching of controllerChart from rancher store
  • Loading branch information
jordojordo authored Oct 20, 2023
2 parents eafc9b1 + 18f8363 commit 4709887
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 14 deletions.
18 changes: 17 additions & 1 deletion pkg/kubewarden/chart/kubewarden/policy-server/General.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script>
import { mapGetters } from 'vuex';
import isEmpty from 'lodash/isEmpty';
import ResourceFetch from '@shell/mixins/resource-fetch';
import { CATALOG } from '@shell/config/types';
import { _CREATE } from '@shell/config/query-params';
Expand Down Expand Up @@ -72,12 +74,26 @@ export default {
},
computed: {
...mapGetters({ charts: 'catalog/charts' }),
isCreate() {
return this.mode === _CREATE;
},
defaultsChart() {
return this.$store.getters['catalog/chart']({ chartName: KUBEWARDEN_CHARTS.DEFAULTS });
if ( this.kubewardenRepo ) {
return this.$store.getters['catalog/chart']({
repoName: this.kubewardenRepo.repoName,
repoType: this.kubewardenRepo.repoType,
chartName: KUBEWARDEN_CHARTS.DEFAULTS
});
}
return null;
},
kubewardenRepo() {
return this.charts?.find(chart => chart.chartName === KUBEWARDEN_CHARTS.DEFAULTS);
},
showVersionBanner() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubewarden/components/Dashboard/DashboardView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
});
}
return true;
return false;
},
/** Counts the current policy server pods - returns the status and total count */
Expand Down
18 changes: 11 additions & 7 deletions pkg/kubewarden/components/Dashboard/InstallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default {
computed: {
...mapGetters(['currentCluster', 'currentProduct']),
...mapGetters({ allRepos: 'catalog/repos', t: 'i18n/t' }),
...mapGetters({ charts: 'catalog/charts', t: 'i18n/t' }),
isAirgap() {
return this.$store.getters['kubewarden/airGapped'];
Expand All @@ -120,15 +120,19 @@ export default {
},
controllerChart() {
return this.$store.getters['catalog/chart']({ chartName: KUBEWARDEN_CHARTS.CONTROLLER });
if ( this.kubewardenRepo ) {
return this.$store.getters['catalog/chart']({
repoName: this.kubewardenRepo.repoName,
repoType: this.kubewardenRepo.repoType,
chartName: KUBEWARDEN_CHARTS.CONTROLLER
});
}
return null;
},
kubewardenRepo() {
if ( !this.isAirgap ) {
return this.allRepos?.find(r => r.spec.url === KUBEWARDEN_REPO);
}
return this.controllerChart;
return this.charts?.find(chart => chart.chartName === KUBEWARDEN_CHARTS.CONTROLLER);
},
shellEnabled() {
Expand Down
15 changes: 14 additions & 1 deletion pkg/kubewarden/components/DefaultsBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,22 @@ export default {
computed: {
...mapGetters(['currentCluster']),
...mapGetters({ charts: 'catalog/charts', t: 'i18n/t' }),
defaultsChart() {
return this.$store.getters['catalog/chart']({ chartName: KUBEWARDEN_CHARTS.DEFAULTS });
if ( this.kubewardenRepo ) {
return this.$store.getters['catalog/chart']({
repoName: this.kubewardenRepo.repoName,
repoType: this.kubewardenRepo.repoType,
chartName: KUBEWARDEN_CHARTS.DEFAULTS
});
}
return null;
},
kubewardenRepo() {
return this.charts?.find(chart => chart.chartName === KUBEWARDEN_CHARTS.DEFAULTS);
},
},
Expand Down
15 changes: 14 additions & 1 deletion pkg/kubewarden/components/MetricsBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,23 @@ export default {
computed: {
...mapGetters(['currentProduct']),
...mapGetters({ charts: 'catalog/charts' }),
...monitoringStatus(),
monitoringChart() {
return this.$store.getters['catalog/chart']({ chartName: 'rancher-monitoring' });
if ( this.rancherRepo ) {
return this.$store.getters['catalog/chart']({
repoName: this.kubewardenRepo.repoName,
repoType: this.kubewardenRepo.repoType,
chartName: 'rancher-monitoring'
});
}
return null;
},
rancherRepo() {
return this.charts?.find(chart => chart.chartName === 'rancher-monitoring');
}
},
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/detail/PolicyServer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ describe('component: PolicyServer', () => {
currentCluster: () => 'current_cluster',
currentProduct: () => 'current_product',
'current_product/all': jest.fn(),
'i18n/t': jest.fn()
'i18n/t': jest.fn(),
'kubewarden/policyTraces': () => TraceTestData
},
}
},
Expand Down Expand Up @@ -111,7 +112,8 @@ describe('component: PolicyServer', () => {
currentCluster: () => 'current_cluster',
currentProduct: () => 'current_product',
'current_product/all': jest.fn(),
'i18n/t': jest.fn()
'i18n/t': jest.fn(),
'kubewarden/policyTraces': () => TraceTestData
},
}
},
Expand Down Expand Up @@ -152,7 +154,8 @@ describe('component: PolicyServer', () => {
currentCluster: () => 'current_cluster',
currentProduct: () => 'current_product',
'current_product/all': jest.fn(),
'i18n/t': jest.fn()
'i18n/t': jest.fn(),
'kubewarden/policyTraces': () => TraceTestData
},
}
},
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/templates/policyTraces.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default [
{
policyName: 'disallow-np',
cluster: 'current_cluster',
traces: [
{
id: '8bb0ad38f130c28f544491ea03a10b40',
Expand Down Expand Up @@ -32,6 +33,7 @@ export default [
},
{
policyName: 'do-not-run-as-root',
cluster: 'current_cluster',
traces: [
{
id: '0de3e0c42e65bee1589d712288c50ffc',
Expand Down Expand Up @@ -73,6 +75,7 @@ export default [
},
{
policyName: 'do-not-share-host-paths',
cluster: 'current_cluster',
traces: [
{
id: '6737aab871b84c88e0d72fe9ccd1c0ad',
Expand All @@ -90,6 +93,7 @@ export default [
},
{
policyName: 'drop-capabilities',
cluster: 'current_cluster',
traces: [
{
id: '6b45b47c049c232930506009ea6e3208',
Expand All @@ -107,6 +111,7 @@ export default [
},
{
policyName: 'no-host-namespace-sharing',
cluster: 'current_cluster',
traces: [
{
id: '1032644de83d5e3d19e292f870084dec',
Expand All @@ -124,6 +129,7 @@ export default [
},
{
policyName: 'no-privilege-escalation',
cluster: 'current_cluster',
traces: [
{
id: 'd300801925447ca66a605e242c78902e',
Expand Down Expand Up @@ -165,6 +171,7 @@ export default [
},
{
policyName: 'no-privileged-pod',
cluster: 'current_cluster',
traces: [
{
id: '3c9375e05d413606bac9e21d17f1326b',
Expand Down

0 comments on commit 4709887

Please sign in to comment.