- 
                Notifications
    You must be signed in to change notification settings 
- Fork 640
feat: add support for creating deployments by project name #8611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ving connections by project and plugin name
| There are no unit tests for this code and no documentation in this repository related to this. | 
…ved clarity and maintainability
| Testing this, we are able to push deployments and see these deployment data in the  Because we now use one single webhook, which is then added to multiple projects, the query for the  Looking into it, we can see that the  Looking at this part of the query: with _deployment_commit_rank as(
  SELECT
  	pm.project_name,
  	IF(cdc._raw_data_table != '', cdc._raw_data_table, cdc.cicd_scope_id) as _raw_data_table,
  	cdc.id,
    cdc.display_title,
    cdc.url,
  	cdc.cicd_deployment_id,
  	cdc.cicd_scope_id,
  	result,
  	environment,
    finished_date,
    row_number() over(partition by cdc.cicd_deployment_id order by finished_date desc) as _deployment_commit_rank
  FROM cicd_deployment_commits cdc
  left join project_mapping pm on cdc.cicd_scope_id = pm.row_id and pm.`table` = 'cicd_scopes'
  WHERE
    pm.project_name in ($project)
  	and result = 'SUCCESS'
  	and environment = 'PRODUCTION'
)I believe the issue to be around the line where the  I'm not a db dev, nor a dba, so I'm out of my depth to try and solve this issue. Any suggestions here, would be welcomed. | 
| Okay, based on the discussion. 
 | 
| postPipelineDeployTaskEndpoint: connection.postPipelineDeployTaskEndpoint, | ||
| postPullRequestsEndpoint: connection.postPullRequestsEndpoint, | ||
| apiKeyId: connection.apiKey.id, | ||
| apiKeyId: connection.apiKey?.id, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apiKey is optional for a webhook, so we won't always have an apiKey id.
| connection := &models.WebhookConnection{} | ||
| projectName := input.Params["projectName"] | ||
| webhookName := fmt.Sprintf("%s_deployments", projectName) | ||
| err := findByProjectName(connection, input.Params, pluginName) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to pass the webhookName to the findByProjectName function instead of redefining.
| } | ||
| // mount all api resources for all plugins | ||
| for pluginName, apiResources := range resources { | ||
| if pluginName == "webhook" { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the way to handle route conflict.
What was the conflict exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly a conflict, but more a duplicate route not wanted. The way routing is done, this route, because how it is defined on the plugin, would have resulted in the route /plugins/webhook/projects/:projectName/deployments instead of only /projects/:projectName/deployments. With this we now only have the latter as we remove the registration of the route on the webhook plugin route. Best way I could think of achieving this, unless the code is moved elsewhere and not in the plugin itself.
pr-type/bug-fix,pr-type/feature-development, etc.Summary
Add a new endpoint for posting to a webhook using the project name. This will allow for a generic webhook to be created and added to multiple projects, and the webhook retrieved using the project name.
Does this close any open issues?
No
Screenshots
Include any relevant screenshots here.
Other Information
relates to discussion: #6348