Closed 4integration closed 2 years ago
Frontend: v0.1.11 Backend: v0.1.0
For the image in harbor myproject/myteam/myimage
when testing with debug logging I can see the request:
GET /api/harbor/artifacts?project=myproject&repository=myteam
i.e. missing the /myimage
so no hit
According to Harbor API spec it says:
So as workaround I tested with myproject/myteam%252Fmyimage
but that resulted in another error
[1] 2021-10-11T08:34:36.378Z backstage error response.map is not a function type=errorHandler stack=TypeError: response.map is not a function
[1] at getArtifacts (/home/myuserid/projects/devexp/playbook-backstage/mysite/node_modules/@bestsellerit/backstage-plugin-harbor-backend/dist/index.cjs.js:26:30)
[1] at processTicksAndRejections (internal/process/task_queues.js:95:5)
[1] at async /home/myuserid/projects/devexp/playbook-backstage/mysite/node_modules/@bestsellerit/backstage-plugin-harbor-backend/dist/index.cjs.js:68:23
When testing with "one level" image like mirrors/python
it works as expected
I've created a new release which will support goharbor.io/repository-slug: myproject/myteam%252Fmyimage https://github.com/BESTSELLER/backstage-plugin-harbor-backend/tree/0.1.1
Thanks @wrighbr I can confirm that myproject/myteam%252Fmyimage
works
It would be nice to have the "encoder" in the plugin to be able to use myproject/myteam/myimage
But to me it looks like the code should do that?!
https://github.com/BESTSELLER/backstage-plugin-harbor-backend/blob/master/src/service/artifact.ts#L15
Would be good to replace all slashes if multiple
repo = repository.replace(/\//g, "%252F");
The problem is in the https://github.com/BESTSELLER/backstage-plugin-harbor project in the HarborWidget and the HarborDashboardPage where the repository slug is splitted like this const info = repositorySlug.split("/");
If the repository slug contains more than one /
, i.e myproject/myteam/myimage
the resulting info array contains three items. The project
is set correctly but the repository
will just contain the first part (myteam) and the last part (myimage) will be lost.
The info array is used in the HarborRepository component (see the repository getting only the partial repository below)
<HarborRepository project={info[0]} repository={info[1]} widget />
This can be fixed by something like
const project = info.shift() as "string";
const repository = info.join("/");
I'll prepare and submit a PR to https://github.com/BESTSELLER/backstage-plugin-harbor
We typlically have multi level repos like
<project>/<team>/<image>
and in this case we get an error in Backstage. It works when having single level repos