docs: clarify KV Remove template usage#5297
Conversation
Signed-off-by: SYED ASAD RAZA <syedasadrazadevops@gmail.com>
📝 WalkthroughWalkthroughDocumentation for the ChangesRemove method template usage documentation
🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
docs/notifications.md
| `Remove` expects a slice of strings. To remove literal keys in a template, use | ||
| the `stringSlice` function: | ||
|
|
||
| ``` | ||
| {{ .Annotations.Remove (stringSlice "summary" "description" "runbook_url") }} | ||
| ``` | ||
|
|
There was a problem hiding this comment.
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 -->
Pull Request Checklist
Which user-facing changes does this PR introduce?
Notes
This adds a short example showing how to use
KV.Removewith literal template keys viastringSlice, as discussed in #3393.Verification:
git diff --check HEAD~1..HEADscripts/assert-cncf-github-identity.ps1 -RepoPath upstreams/prometheus/alertmanagerNot run:
go test ./templatebecause Go is not installed in this local environment.