Skip to content

Commit 7a74fd6

Browse files
rushk014xingzhang-suse
authored andcommitted
Update Registry details to use ScanJob & Registry CR data
1 parent f29bd58 commit 7a74fd6

File tree

2 files changed

+54
-63
lines changed

2 files changed

+54
-63
lines changed

pkg/sbombastic-image-vulnerability-scanner/components/RegistryDetails.vue

Lines changed: 52 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<RouterLink to="../">{{ t('imageScanner.registries.title') }}:</RouterLink>
99
{{ $route.params.id }}
1010
</span>
11-
<RegisterStatusBadge status="failed" />
11+
<RegisterStatusBadge :status="registryStatus" />
1212
</div>
1313
<span class="resource-header-description">
1414
Registry configuration description
@@ -25,7 +25,7 @@
2525
</button>
2626
</div>
2727
</div>
28-
<RancherMeta :properties="registryMetaProperties" />
28+
<RancherMeta :properties="registryMetadata" />
2929
</div>
3030
Recent scans
3131
<ResourceTable
@@ -57,70 +57,61 @@
5757
},
5858
data() {
5959
return {
60-
scanHistory: [
61-
{
62-
status: 'completed',
63-
timestamp: '2023-10-01T12:00:00Z',
64-
progress: '100',
65-
imagesScanned: 50,
66-
imagesFound: 45,
67-
errors: [],
68-
},
69-
{
70-
status: 'failed',
71-
timestamp: '2023-10-02T12:00:00Z',
72-
progress: '35',
73-
imagesScanned: 1339,
74-
imagesFound: 3826,
75-
errors: [
76-
{
77-
message: "Not enough resources to complete the scan. Could not connect to proxyu",
78-
}
79-
],
80-
},
81-
],
60+
registryStatus: null,
61+
registryMetadata: [],
62+
scanHistory: [],
8263
headers: REGISTRY_SCAN_HISTORY_TABLE
8364
}
8465
},
8566
async fetch() {
86-
await this.$store.dispatch('cluster/find', { type: RESOURCE.REGISTRY, id: `${this.$route.params.ns}/${this.$route.params.id}` });
67+
await this.$store.dispatch('cluster/find', { type: RESOURCE.SCAN_JOB, id: `${this.$route.params.ns}/${this.$route.params.id}` });
68+
let scanJob = this.$store.getters['cluster/byId'](RESOURCE.SCAN_JOB, `${this.$route.params.ns}/${this.$route.params.id}`);
69+
70+
await this.$store.dispatch('cluster/find', { type: RESOURCE.REGISTRY, id: `${this.$route.params.ns}/${scanJob.spec.registry}` });
71+
let registry = this.$store.getters['cluster/byId'](RESOURCE.REGISTRY, `${this.$route.params.ns}/${scanJob.spec.registry}`);
72+
73+
this.registryStatus = (registry.status.conditions[0].type.toLowerCase() === "discovering" ? "InProgress" : registry.status.conditions[0].type).toLowerCase();
74+
this.registryMetadata = [
75+
{
76+
type: 'text',
77+
label: this.t('imageScanner.registries.configuration.meta.registry'),
78+
value: registry.spec.uri
79+
},
80+
{
81+
type: 'text',
82+
label: this.t('imageScanner.registries.configuration.meta.repositories'),
83+
value: registry.spec.repositories.length
84+
},
85+
{
86+
type: 'text',
87+
label: this.t('imageScanner.registries.configuration.meta.schedule')
88+
},
89+
{
90+
type: 'text',
91+
label: this.t('imageScanner.registries.configuration.meta.namespace'),
92+
value: registry.metadata.namespace
93+
},
94+
{
95+
type: 'tags',
96+
tags: registry.spec.repositories || []
97+
},
98+
{
99+
type: 'text',
100+
value: registry.metadata.schedule || '',
101+
}
102+
];
103+
104+
this.scanHistory = scanJob.status.conditions.map((rec) => {
105+
return {
106+
status: rec.type.toLowerCase(),
107+
timestamp: rec.lastUpdateTime,
108+
progress: rec.progress || 0,
109+
imagesScanned: rec.imagesScanned || 0,
110+
imagesFound: rec.imagesFound || 0,
111+
errors: rec.errors || []
112+
};
113+
});
87114
},
88-
computed: {
89-
registry() {
90-
return this.$store.getters['cluster/byId'](RESOURCE.REGISTRY, `${this.$route.params.ns}/${this.$route.params.id}`);
91-
},
92-
registryMetaProperties() {
93-
return [
94-
{
95-
type: 'text',
96-
label: this.t('imageScanner.registries.configuration.meta.registry'),
97-
value: this.registry.spec.uri
98-
},
99-
{
100-
type: 'text',
101-
label: this.t('imageScanner.registries.configuration.meta.repositories'),
102-
value: this.registry.spec.repositories.length
103-
},
104-
{
105-
type: 'text',
106-
label: this.t('imageScanner.registries.configuration.meta.schedule')
107-
},
108-
{
109-
type: 'text',
110-
label: this.t('imageScanner.registries.configuration.meta.namespace'),
111-
value: this.registry.metadata.namespace
112-
},
113-
{
114-
type: 'tags',
115-
tags: this.registry.spec.repositories || []
116-
},
117-
{
118-
type: 'text',
119-
value: this.registry.metadata.schedule || '',
120-
}
121-
];
122-
}
123-
}
124115
}
125116
</script>
126117

pkg/sbombastic-image-vulnerability-scanner/config/table-headers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const REGISTRY_SCAN_HISTORY_TABLE = [
6262
name: "status",
6363
labelKey: "imageScanner.registries.configuration.scanTable.header.status",
6464
value: "status",
65-
formatter: "RegisterStatusCellBadge",
65+
formatter: "RegistryStatusCellBadge",
6666
sort: "status",
6767
},
6868
{
@@ -77,7 +77,7 @@ export const REGISTRY_SCAN_HISTORY_TABLE = [
7777
labelKey: "imageScanner.registries.configuration.scanTable.header.progress",
7878
value: "progress",
7979
getValue: (row: any) => row.progress.toString(),
80-
formatter: "Percentage",
80+
formatter: "ProgressCell",
8181
sort: "progress",
8282
},
8383
{

0 commit comments

Comments
 (0)