Skip to content

feat(gitops): add bulk sync, cancel operation, resource actions, repo credentials and cluster links - #506

Draft
BlueLabelscotch wants to merge 4 commits into
feat/gitops-readsfrom
feat/gitops-writes
Draft

BlueLabelscotch wants to merge 4 commits into
feat/gitops-readsfrom
feat/gitops-writes

Conversation

@BlueLabelscotch

Copy link
Copy Markdown
Collaborator

Stacked on #505 (base is feat/gitops-reads).

Adds write commands matching the MCP gitops toolset:

  • execute gitops_application:bulk_sync, :cancel_operation, :run_resource_action
  • list/get/delete gitops_repocred
  • list/create/delete gitops_clusterlink

Spec only.

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

Review completed with 5 suggestions.

Reviewed commit: 83b7ca8

Comment thread pkg/spec/gitops.spec.yaml Outdated
method: POST
path: /gitops/api/v1/applications/bulk/sync
body_params:
applicationTargets: 'map(flags.target, {{"agentIdentifier": split(#, "/")[0], "applicationName": split(#, "/")[1]}})'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

bulk_sync accepts a malformed target like agent/app/extra and silently syncs agent/app, including pruning if requested. A target with no slash makes the expression fail, and the body builder then drops applicationTargets for the entire batch instead of reporting the bad target.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/spec/gitops.spec.yaml Outdated
handler_type: endpoint
endpoint:
method: DELETE
path: /gitops/api/v1/agents/{{ctx.idParts[0]}}/applications/{{ctx.idParts[1]}}/operation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

buildCtx strips account. and org. before populating ctx.idParts for multi-level nouns, so cancel_operation sends a bare agent ID where the API requires a scope-prefixed one. Other locations where this applies: pkg/spec/gitops.spec.yaml:1530 (run_resource_action), :1576 (get gitops_repocred), and :1593 (delete gitops_repocred).

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/spec/gitops.spec.yaml
searchTerm: 'flags.search != "" ? flags.search : nil'
agentIdentifier: 'flags.agent != "" ? flags.agent : nil'
paging:
paging_strategy: flat_list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

list gitops_repocred treats the paginated /repocreds endpoint as a flat list, so the CLI stops after the first server page even with --all. If more credentials match than the server returns in that page, --count also reports only the first page's length.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/spec/gitops.spec.yaml Outdated
page_size_param: size
page_size_default: 50
page_size_max: 100
total_expr: it.data.totalItems

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

The MCP contract test models /ng/api/gitops/clusters returning its count as data.totalElements, but total_expr only reads data.totalItems. With that response, the CLI's paging code returns an error instead of displaying any links, even on the first page.

Severity: high


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/spec/gitops.spec.yaml

- noun: gitops_clusterlink
short_desc: "Link between a GitOps cluster and a Harness environment (identifiers are raw, not scope-prefixed)."
noun_aliases: [gitops_clusterlinks]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

gitops_clusterlink isn't marked multi-level, so its commands don't expose --level to select the environment's scope. With a project-scoped profile, list/create/delete still send the profile's project for an account- or org-level environment; --scope only selects the cluster's scope.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

@augmentcode

augmentcode Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

CLI Grammar Review · session (Harness team members only) · 1f413a7

CLI grammar changes (beta) · Advisory only, FYI, not required changes.

  • 🟡 New harness create gitops_clusterlink (gitops_clusterlinks): --cluster, --environment, --agent, --scope
    • create gitops_cluster takes positional <agent/cluster_id>; here agent and cluster are flags. Consider <agent/cluster_id> positional.
    • --scope values differ from core --level (project/org/account); consider documenting the distinction.
  • 🟡 New harness delete gitops_clusterlink (gitops_clusterlinks) <cluster>: --environment, --agent, --scope
    • ID is <cluster> here but --cluster on create; delete gitops_cluster uses <agent/cluster_id>. Consider matching.
  • 🟡 New harness list gitops_clusterlink (gitops_clusterlinks): --environment, --search, --scope
    • Required parent --environment is a flag, unlike other gitops lists that use a positional parent. Consider a positional parent.
  • 🟢 New harness execute gitops_application:bulk_sync: --target, --prune, --dry-run, --sync-option
  • 🟢 New harness execute gitops_application:cancel_operation <agent/app>
  • 🟢 New harness execute gitops_application:run_resource_action <agent/app>: --namespace, --resource-name, --kind, --action, --group, --version
  • 🟢 New harness list gitops_repocred (gitops_repocreds): --search, --agent
  • 🟢 New harness get gitops_repocred <agent/credential_id>
  • 🟢 New harness delete gitops_repocred <agent/credential_id>

Overall: 🟡 Recommend manual review

@BlueLabelscotch

Copy link
Copy Markdown
Collaborator Author

cosmos review

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

Review completed with 3 suggestions.

Reviewed commit: 1f413a7

Comment thread pkg/spec/gitops.spec.yaml
handler_type: endpoint
endpoint:
method: DELETE
path: '/gitops/api/v1/agents/{{ctx.level == "account" ? "account." + ctx.idParts[0] : (ctx.level == "org" ? "org." + ctx.idParts[0] : ctx.idParts[0])}}/applications/{{ctx.idParts[1]}}/operation'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

With account.<agent> or org.<agent>, cancel_operation restores the agent prefix in the path but ScopedAuth drops projectIdentifier, whereas the MCP operation sends the application’s project separately from the agent ID. This loses the project scope for apps managed by a shared agent, and --level project conflicts with the prefixed ID; the same applies to run_resource_action at pkg/spec/gitops.spec.yaml:1596.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/spec/gitops.spec.yaml
page_size_default: 50
page_size_max: 100
total_expr: it.data.totalItems ?? it.data.totalElements ?? 0
columns: [name, agent, scope]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

list gitops_clusterlink shows the API’s scope-prefixed name (for example, account.incluster), but pasting that value into delete gitops_clusterlink makes the CLI interpret the cluster’s prefix as the environment’s scope. An account cluster linked to a project environment therefore produces an account-scoped delete request, or a scope conflict if --level project is explicit.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

"prune": true,
"sync-option": []string{"CreateNamespace=true"},
}}
got, err := bulkSyncBody(ctx)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

TestBulkSyncBody only exercises --dry-run when it is off. It would still pass if bulkSyncBody dropped or misnamed dryRun when the flag is set, turning a requested simulation into a live sync.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

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