Feature Proposal - Badge Overwriting via the API
Problem to solve
When creating a new badge users must use a POST request to create a new badge and a PUT request to update an existing badge if they know the badge id number. If not they must look up the id number first before issuing a PUT request.
DevOps Engineers and Developers
Current use case we are encountering:
In our GitLab Pipeline we are deploying a program to a specified server in specific environments. When deployed we are given information about the deployment like the environment, server, and port the service has been assigned to. We would like to put all this handy info in a badge retroactively. However, we are finding that if we were to redeploy the service it will simply add another badge with the updated port number - rather than replacing the already existing one. For example:
Steve deploys his service
pizza-maker to environment
lower on server
dev1 and we assign that service a port of
12345. Say Steve also wants to deploy his service to environment
dev on server
dev2. The current badges on Steves project are:
Say he now wants to redeploy to the lower environment and is assigned to a new port. This means his old instance is gone and we need to update the port number on the old badge. However the current implementation requires a user to first find the badge, and then edit it. This takes 2 curl requests as well as a search to accomplish. In our use case it is also very clunky to perform in a CI job.
It would be far easier to specify an optional
id in the POST request and either insert it there or overwrite the existing badge. Another option could be the PUT request does the same functionality. It might also be helpful to give badges their own unique IDs and simply query them with their unique IDs.
Permissions and Security
Standard API Read/Write permissions.
Documentation (here)[https://docs.gitlab.com/ee/api/project_badges.html] would have to be changed to reflect this update.
Risks could involve querying IDs that do not exist or inputting an overwrite ID like
509 thereby making it so that the first badge is inserted with ID 529. This could be fixed if IDs are given their on unique IDs not dependent on the order they were added.
What does success look like, and how can we measure that?
Being able to CURL the Gitlab API and PUT/POST a Badge down that adds/overwrites a badge given an ID.