Skip to content

feat(deployment-checks): add CRUD commands for deployment checks#10

Open
facundofarias wants to merge 2 commits into
mainfrom
feat/deployment-checks
Open

feat(deployment-checks): add CRUD commands for deployment checks#10
facundofarias wants to merge 2 commits into
mainfrom
feat/deployment-checks

Conversation

@facundofarias
Copy link
Copy Markdown
Contributor

@facundofarias facundofarias commented May 21, 2026

Summary

  • Wires the /projects/{id}/deployment_checks API into the SDK and CLI: ssh, http, and vulnerability_scan checks gating pre_build or post_deploy stages
  • dhq deployment-checks {list,show,create,update,delete} with flags for each check type; update only sends flags the user actually passed (via cmd.Flags().Changed()) so partial updates don't clobber existing values
  • Agent metadata registered for all five subcommands; delete is marked destructive + requires confirmation
  • README, both SKILL guides, and the configuration skill reference updated with usage examples

Test plan

  • go test ./... — all tests pass (5 new SDK tests for List/Get/Create/Update/Delete)
  • go vet ./... and golangci-lint run — clean
  • dhq deployment-checks --help shows the command tree
  • dhq commands --json exposes correct agent metadata for each subcommand
  • Smoke test against staging once merged (create / update / delete each check type)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added dhq deployment-checks command group with list, show, create, update, and delete subcommands.
    • Support for multiple deployment check types: SSH commands, HTTP health checks, and vulnerability scanner checks.
  • Documentation

    • Updated command reference and decision trees with deployment-checks guidance.
    • Added comprehensive documentation including required/optional flags and example invocations for each check type.
  • Tests

    • Added test coverage for deployment-checks API operations.

Review Change Stack

facundofarias and others added 2 commits May 21, 2026 11:33
Wire the /projects/{id}/deployment_checks API into the SDK and CLI:
ssh, http, and vulnerability_scan checks gating pre_build or post_deploy
stages. Update sends only flags the user set (cmd.Flags().Changed) so
partial updates don't clobber existing values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…guides

Add the command to the README command list, the project-config decision
trees in both SKILL guides, and a full Deployment Checks section in the
configuration skill reference with examples for ssh, http, and
vulnerability_scan checks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Walkthrough

This PR adds complete deployment checks management to the deployhq CLI, enabling users to create and manage deployment gates (SSH, HTTP, vulnerability scanner) via new dhq deployment-checks commands with full CRUD support, SDK client methods, validation, and comprehensive documentation.

Changes

Deployment Checks Management

Layer / File(s) Summary
SDK data models and client methods
pkg/sdk/deployment_checks.go
DeploymentCheck struct defines check fields with JSON serialization; DeploymentCheckCreateRequest uses pointer fields for optional PATCH-style updates; Client methods (List, Get, Create, Update, Delete) call REST endpoints /projects/{projectID}/deployment_checks and handle JSON marshalling/unmarshalling.
SDK client tests
pkg/sdk/deployment_checks_test.go
Five test functions validate SDK methods using httptest server with assertions on request paths/methods, JSON payload decoding for create/update, and response unmarshalling; covers list, get, create, update, and delete with proper status codes.
CLI command structure and wiring
internal/commands/deployment_checks.go, internal/commands/root.go
Defines newDeploymentChecksCmd() with list/show/create/update/delete subcommands; introduces checkFlags struct and flag registration for common fields (name, description, stage, check-type, enabled, timeout) plus per-type options (SSH command/servers, HTTP method/URL/body match/status, scanner/target/severity threshold/SARIF); registers command in root.
CLI create/update validation and request building
internal/commands/deployment_checks.go
Create subcommand validates required fields and type-specific requirements, builds DeploymentCheckCreateRequest via toRequest(), calls SDK create API. Update captures changed flags and populates only those pointer fields to avoid overwriting omitted values; both print success messages and enabledLabel renders yes/no status.
Command metadata registration
internal/commands/agent_metadata.go
Metadata table entries for five deployment-checks subcommands set Idempotent, SupportsJSON, SafeForAutomation defaults; mark delete as Destructive and RequiresConfirmation; tag all with deployment_check resource type.
Documentation and guides
README.md, docs/SKILL.md, skills/deployhq/SKILL.md, skills/deployhq/references/configuration.md
README adds deployment-checks command listing; docs SKILL.md adds config step for listing checks; skills SKILL.md adds configuration command group and deployment-checks creation step; configuration.md adds front-matter metadata and comprehensive "Deployment Checks" section with command reference and per-type examples.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(deployment-checks): add CRUD commands for deployment checks' accurately summarizes the main change: adding Create, Read, Update, Delete commands for deployment checks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/deployment-checks

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pkg/sdk/deployment_checks.go (1)

34-36: 💤 Low value

Clarify the comment: API uses PUT, not PATCH, and omitempty applies to non-pointer strings too.

The comment states "Pointer fields are omitted from the JSON body when nil" and mentions "PATCH", but:

  1. The Update method uses PUT (line 91), not PATCH.
  2. Non-pointer string fields with omitempty will also omit empty strings, so they support partial updates equally well.
📝 Suggested comment revision
-// DeploymentCheckCreateRequest is the payload for creating or updating a deployment check.
-// Pointer fields are omitted from the JSON body when nil, so callers only send what they
-// want to set (important for partial updates via PATCH).
+// DeploymentCheckCreateRequest is the payload for creating or updating a deployment check.
+// Fields with omitempty are excluded when empty/nil, enabling partial updates:
+// pointer bool/int fields distinguish unset from false/0, string fields omit empty values.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/sdk/deployment_checks.go` around lines 34 - 36, Update the comment on
DeploymentCheckCreateRequest to accurately reflect behavior: replace the
reference to PATCH with PUT (the Update method uses PUT) and clarify that
omitempty applies to non-pointer fields (e.g., empty strings) as well as pointer
fields, so fields tagged with `omitempty` are omitted when empty allowing
partial updates; reference the DeploymentCheckCreateRequest type and the Update
method to locate where the comment should be revised.
internal/commands/deployment_checks.go (1)

23-49: ⚡ Quick win

Add Args: cobra.NoArgs to the list subcommand.

The list subcommand does not accept arguments, but the command definition lacks Args: cobra.NoArgs. Other subcommands in this file (show on line 51, delete on line 71) correctly enforce argument count. Adding Args: cobra.NoArgs to list will provide consistent validation and a better error message if the user accidentally passes arguments.

✨ Proposed addition
 &cobra.Command{
-    Use: "list", Short: "List deployment checks",
+    Use: "list", Short: "List deployment checks", Args: cobra.NoArgs,
     RunE: func(cmd *cobra.Command, args []string) error {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/commands/deployment_checks.go` around lines 23 - 49, The "list"
subcommand's cobra.Command struct (the &cobra.Command{ Use: "list", Short: "List
deployment checks", RunE: func(...) {...} }) is missing argument validation; add
Args: cobra.NoArgs to that struct so the command rejects unexpected arguments
(matching the existing pattern used by the "show" and "delete" subcommands) to
provide consistent validation and clearer error messages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/commands/deployment_checks.go`:
- Around line 23-49: The "list" subcommand's cobra.Command struct (the
&cobra.Command{ Use: "list", Short: "List deployment checks", RunE: func(...)
{...} }) is missing argument validation; add Args: cobra.NoArgs to that struct
so the command rejects unexpected arguments (matching the existing pattern used
by the "show" and "delete" subcommands) to provide consistent validation and
clearer error messages.

In `@pkg/sdk/deployment_checks.go`:
- Around line 34-36: Update the comment on DeploymentCheckCreateRequest to
accurately reflect behavior: replace the reference to PATCH with PUT (the Update
method uses PUT) and clarify that omitempty applies to non-pointer fields (e.g.,
empty strings) as well as pointer fields, so fields tagged with `omitempty` are
omitted when empty allowing partial updates; reference the
DeploymentCheckCreateRequest type and the Update method to locate where the
comment should be revised.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c3640bd9-0831-430a-9c49-c036466103e5

📥 Commits

Reviewing files that changed from the base of the PR and between 79d2091 and e796303.

📒 Files selected for processing (9)
  • README.md
  • docs/SKILL.md
  • internal/commands/agent_metadata.go
  • internal/commands/deployment_checks.go
  • internal/commands/root.go
  • pkg/sdk/deployment_checks.go
  • pkg/sdk/deployment_checks_test.go
  • skills/deployhq/SKILL.md
  • skills/deployhq/references/configuration.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant