Skip to content

docs: clarify KV Remove template usage#5297

Open
SyedAsadRazaDevops wants to merge 1 commit into
prometheus:mainfrom
SyedAsadRazaDevops:syedasadrazadevops/3393-kv-remove-docs
Open

docs: clarify KV Remove template usage#5297
SyedAsadRazaDevops wants to merge 1 commit into
prometheus:mainfrom
SyedAsadRazaDevops:syedasadrazadevops/3393-kv-remove-docs

Conversation

@SyedAsadRazaDevops

@SyedAsadRazaDevops SyedAsadRazaDevops commented Jun 11, 2026

Copy link
Copy Markdown

Pull Request Checklist

  • Please list all open issue(s) discussed with maintainers related to this change
  • Is this a new Receiver integration?
    • I have already tried to use the Webhook Receiver Integration and 3rd party integrations before adding this new Receiver Integration
  • Is this a bugfix?
    • I have added tests that can reproduce the bug which pass with this bugfix applied
  • Is this a new feature?
    • I have added tests that test the new feature's functionality
  • Does this change affect performance?
    • I have provided benchmarks comparison that shows performance is improved or is not degraded
    • I have added new benchmarks if required or requested by maintainers
  • Is this a breaking change?
    • My changes do not break the existing cluster messages
    • My changes do not break the existing api
  • I have added/updated the required documentation
  • I have signed-off my commits
  • I will follow best practices for contributing to this project

Which user-facing changes does this PR introduce?

NONE

Notes

This adds a short example showing how to use KV.Remove with literal template keys via stringSlice, as discussed in #3393.

Verification:

  • git diff --check HEAD~1..HEAD
  • scripts/assert-cncf-github-identity.ps1 -RepoPath upstreams/prometheus/alertmanager

Not run:

  • go test ./template because Go is not installed in this local environment.

Signed-off-by: SYED ASAD RAZA <syedasadrazadevops@gmail.com>
@SyedAsadRazaDevops SyedAsadRazaDevops requested a review from a team as a code owner June 11, 2026 04:55
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Documentation for the Remove method in docs/notifications.md now clarifies that it expects a slice of string keys and provides a Go-template example demonstrating how to use the stringSlice function to remove multiple annotation keys from .Annotations.

Changes

Remove method template usage documentation

Layer / File(s) Summary
Remove method parameter and template example documentation
docs/notifications.md
Added documentation explaining that Remove requires a slice of strings and provided a Go-template example using stringSlice to remove multiple annotation keys during template rendering.

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: clarify KV Remove template usage' clearly and specifically describes the main change: adding documentation clarification about the KV Remove function's template usage.
Linked Issues check ✅ Passed The PR directly addresses issue #3393 by adding documentation/examples for using KV.Remove with stringSlice in Go templates, fulfilling the request for clarification and examples on template usage.
Out of Scope Changes check ✅ Passed The change is documentation-only, limited to docs/notifications.md, and directly addresses the scope of issue #3393 regarding KV.Remove template usage clarification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description addresses the template checklist comprehensively, references the linked issue #3393, documents that no release notes are needed, confirms documentation updates and signed commits, and includes verification steps. The description explains the purpose clearly and is well-structured according to the template requirements.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@docs/notifications.md`:
- Around line 78-84: The fenced code block demonstrating the template usage
lacks a language identifier for syntax highlighting; update the block start to
include a language tag (e.g., "gotmpl") so the example for `.Annotations.Remove`
with `stringSlice` is fenced as ```gotmpl and the inner line `{{
.Annotations.Remove (stringSlice "summary" "description" "runbook_url") }}`
remains unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bb5e41e1-f6cf-4de4-8f81-f732e0a00c50

📥 Commits

Reviewing files that changed from the base of the PR and between 364a227 and e69e693.

📒 Files selected for processing (1)
  • docs/notifications.md

Comment thread docs/notifications.md
Comment on lines +78 to +84
`Remove` expects a slice of strings. To remove literal keys in a template, use
the `stringSlice` function:

```
{{ .Annotations.Remove (stringSlice "summary" "description" "runbook_url") }}
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Documentation content looks good; consider adding language identifier to code block.

The explanation and example correctly demonstrate how to use Remove with stringSlice in Go templates, matching both the upstream implementation and test coverage. This addresses the linked issue effectively.

📝 Suggested fix for the markdown linter warning

Add a language identifier to the fenced code block for syntax highlighting:

 `Remove` expects a slice of strings. To remove literal keys in a template, use
 the `stringSlice` function:
 
-```
+```gotmpl
 {{ .Annotations.Remove (stringSlice "summary" "description" "runbook_url") }}

</details>

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 markdownlint-cli2 (0.22.1)</summary>

[warning] 81-81: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @docs/notifications.md around lines 78 - 84, The fenced code block
demonstrating the template usage lacks a language identifier for syntax
highlighting; update the block start to include a language tag (e.g., "gotmpl")
so the example for .Annotations.Remove with stringSlice is fenced as
```gotmpl and the inner line {{ .Annotations.Remove (stringSlice "summary" "description" "runbook_url") }} remains unchanged.


</details>

<!-- fingerprinting:phantom:triton:puma -->

<!-- cr-comment:v1:e971b723f5cb7f92591ef380 -->

_Source: Linters/SAST tools_

<!-- This is an auto-generated comment by CodeRabbit -->

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.

Remove function in KV is hard to use from templates

1 participant