Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@olblak
Copy link
Member

@olblak olblak commented May 8, 2025

The purpose of this pull request is to allow retrieving pipeline reports based on source/condition/target configuration across git repositories

While working on this.
I also took the opportunity to improve the following topics

  • fix: filter pipeline based on id instead of name
  • feat: filter resources endpoint should return the full report
  • rename kind endpoint to kinds
  • feat: filter resources endpoint should return the full report
  • feat: use bob to build sql queries
  • feat: document the API using swagger
  • fix: remove null constraint on target_db_scm column
  • feat: allow querying config using post queries
  • feat: support pipeline configuration queries

Description

Test

To test this pull request, you can run the following commands:

make db.start
make server.start

Additional Information

Tradeoff

Potential improvement

* Requires Updatecli v0.99.0
@olblak olblak added the enhancement New feature or request label May 8, 2025
@olblak olblak requested a review from Copilot May 8, 2025 20:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces support for pipeline configuration queries by extending report insertion logic, adding new endpoints for retrieving configuration resources, and updating the database schema and model definitions.

  • Extended report creation to include configuration IDs for sources, conditions, and targets.
  • Added new REST endpoints to fetch configuration resources.
  • Created database migration files to support hstore columns for configuration IDs.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/server/reportDBQuery.go Extended report insertion logic with configuration queries.
pkg/server/main.go Registered new endpoints for config source/condition/target.
pkg/server/configDBQuery.go Added functions to insert, delete, and query config resources.
pkg/server/configDBHandler.go Provided HTTP handlers for configuration resource endpoints.
pkg/model/pipelinereport.go Updated the report model with new configuration ID mappings.
pkg/model/configResource.go Defined models for config source, condition, and target.
pkg/database/migrations/000005_create_resourceConfig.up.sql Added SQL migration to create config resource tables and columns.
pkg/database/migrations/000005_create_resourceConfig.down.sql Added SQL migration rollback for config resource tables.
go.mod Updated dependency versions to support new functionality.
Comments suppressed due to low confidence (2)

pkg/server/configDBQuery.go:84

  • Building SQL queries through string concatenation with unsanitized input can expose the application to SQL injection vulnerabilities. Consider using parameterized queries to safely construct the SQL statement.
query := "SELECT * FROM " + table + " WHERE ("

pkg/server/configDBHandler.go:102

  • [nitpick] The function name 'DeleteTargetTarget' is inconsistent with the naming convention used for other configuration deletion functions. Renaming it to 'DeleteConfigTarget' would improve clarity and consistency.
func DeleteTargetTarget(c *gin.Context) {

@olblak olblak requested a review from Copilot May 30, 2025 07:05

This comment was marked as outdated.

@olblak olblak enabled auto-merge (squash) May 30, 2025 07:18
@olblak olblak disabled auto-merge May 30, 2025 07:21
@olblak olblak requested a review from Copilot June 7, 2025 06:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for pipeline configuration queries and expands the API endpoints to manage source, condition, and target configurations. Key changes include new swagger documentation and endpoint handlers for configuration resources, updates to database query functions and migrations for configuration data, and adjustments to the server routing and response models.

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
updatecli/updatecli.d/swagger.yaml Added new pipeline configuration report documentation.
updatecli-compose.yaml Updated policies configuration to include new SCM values.
pkg/server/var.go Reduced default monitoring duration from 30 to 7 days.
pkg/server/scmDBQuery.go Replaced raw SQL with bob dialect–based dynamic query building.
pkg/server/scmDBHandler.go Renamed and restructured SCM endpoint from FindSCM to ListSCMs with improved swagger annotations.
pkg/server/reportHandler.go Refactored pipeline report endpoints with enhanced swagger documentation and response models.
pkg/server/main.go Added swagger routing and updated API endpoint registrations for configuration queries.
pkg/server/configDBQuery.go & configDBHandler.go Introduced new query functions and handlers for config sources, conditions, and targets.
pkg/model/pipelinereport.go & configResource.go Extended models to handle configuration identifiers and resource configurations.
Migration and Makefile files Added new migration files for configuration resources and updated Makefile targets.
README.adoc Extended documentation and roadmap information.
.github/workflows/updatecli.yaml Enhanced workflow with Swagger installation step.
Comments suppressed due to low confidence (2)

pkg/server/reportHandler.go:205

  • GET endpoints typically return a 200 OK status rather than a 201 Created. Consider updating the Status code for GetPipelineReportByID to 200.
c.JSON(http.StatusCreated, GetPipelineReportByIDResponse{

README.adoc:152

  • Consider adding a space or punctuation between 'Support pagination' and the URL for improved readability.
- [ ] Support paginationhttps://meet.google.com/vnj-momt-brs?authuser=0

@olblak
Copy link
Member Author

olblak commented Jun 7, 2025

Until merged, the new Updatecli configuration can't work

@olblak olblak merged commit f7dbef0 into updatecli:main Jun 7, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant