[CASCL-1323] kubectl-datadog: delegate OCI image parsing to go-containerregistry#2971
[CASCL-1323] kubectl-datadog: delegate OCI image parsing to go-containerregistry#2971
kubectl-datadog: delegate OCI image parsing to go-containerregistry#2971Conversation
kubectl-datadog: delegate OCI image parsing to go-containerregistry
…nerregistry imageRepoEndsWith (renamed to imageRepoPathHasSuffix) and imageTag now use name.ParseReference from github.com/google/go-containerregistry/pkg/name (already a direct dep) instead of open-coding the registry-port-vs-tag heuristic. The @digest pre-strip handles combined tag@digest forms (parsed as Digest by pkg/name) and malformed digests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4d7fcf9 to
995ae59
Compare
|
@codex review |
1 similar comment
|
@codex review |
The new dependency introduced when delegating OCI image parsing to go-containerregistry must be recorded in LICENSE-3rdparty.csv; fix the failing `verify-licenses` CI check. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
🎯 Code Coverage (details) 🔗 Commit SHA: 1b0e22f | Docs | Datadog PR Page | Give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2971 +/- ##
==========================================
- Coverage 41.40% 41.39% -0.01%
==========================================
Files 331 331
Lines 28908 28911 +3
==========================================
Hits 11969 11969
- Misses 16084 16086 +2
- Partials 855 856 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Add a malformed-input case to TestImageRepoPathHasSuffix and a "malformed image falls back to label" case to TestClassify_ClusterAutoscalerVersion to exercise the `name.ParseReference` error branches in imageRepoPathHasSuffix and imageTag. Lifts patch coverage above the Datadog gate threshold. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
What does this PR do?
Replaces two hand-rolled OCI image-reference parsers under
cmd/kubectl-datadog/autoscaling/cluster/with calls togithub.com/google/go-containerregistry/pkg/name(already a direct dependency of the project).imageRepoEndsWith→ renamedimageRepoPathHasSuffixto reflect component-aware suffix matching against the registry-stripped repository path.imageTag→ returns the OCI tag, or empty for digest-only / tagless images.Both helpers pre-strip a trailing
@digestso combinedtag@digestforms (whichpkg/nameparses as aname.Digest, dropping the tag) and malformed digests parse uniformly.Motivation
The two helpers re-implemented the subtle "
:is a registry port vs. a tag separator" logic by hand. Delegating to the canonicalpkg/nameparser makes the intent clearer and removes a chunk of bespoke parsing.Additional Notes
No behavior change on the existing test corpus (combined
tag@digest, registries with port, digest-only, single-component image names, plural-form false-positive guard).Minimum Agent Versions
N/A —
kubectl-datadogplugin only.Describe your test plan
go test ./cmd/kubectl-datadog/autoscaling/cluster/install/guess/... ./cmd/kubectl-datadog/autoscaling/cluster/common/clusterinfo/...— passesmake lint— passesmake kubectl-datadog— buildsChecklist
/label refactoring
/label qa/skip-qa