Skip to content

feat: add custom User-Agent for Nutanix API requests (fixes #508) - #797

Open
Himanshucodess wants to merge 1 commit into
nutanix-cloud-native:mainfrom
Himanshucodess:feat/user-agent-508
Open

Himanshucodess wants to merge 1 commit into
nutanix-cloud-native:mainfrom
Himanshucodess:feat/user-agent-508

Conversation

@Himanshucodess

Copy link
Copy Markdown

What does this PR do?

Implements custom User-Agent for Nutanix API requests as per #508.

  • Adds pkg/version with GitCommit and UserAgent helper (capx/, fallback dev).
  • Sets User-Agent on prism-go-client v3 cache via WithUserAgent in controllers/helpers.go.
  • Updates Makefile ldflags to propagate GIT_COMMIT_HASH to both main.gitCommitHash and pkg/version.GitCommit.

Filtering is client-side via existing SDK header mechanism; no undocumented API behavior introduced.

Why is this needed?

Improves observability and traceability in Nutanix API logs/metrics, facilitates debugging/support, and aligns with API best practices. Previously requests used generic SDK default (nutanix/v3).

Testing

  • go test ./pkg/version -v -> PASS (2 tests)
  • go test ./pkg/client -v -> PASS
  • go vet ./pkg/version ./pkg/client ./controllers -> PASS
  • gofmt -> PASS
  • E2E not run (requires Nutanix Prism Central)

Notes

  • Only v3 client has WithUserAgent in prism-go-client v0.8.2; v4 and converged clients use default until upstream adds support.
  • Version is git commit hash via ldflags, fallback dev if not set.
  • No breaking changes, no auth/TLS/proxy behavior change.

Fixes #508

…loud-native#508)

Add pkg/version with UserAgent helper (capx/<version>) set via ldflags.

Set User-Agent on prism-go-client v3 cache via WithUserAgent in helpers.go.

Update Makefile ldflags to propagate gitCommitHash to version package.
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.

Implement Custom User-Agent for Nutanix API Requests

1 participant