Skip to content

Conversation

@yugannkt
Copy link

@yugannkt yugannkt commented Dec 2, 2025

Allow custom User-Agent headers for Helm repository requests

Adds support for configuring custom HTTP User-Agent headers for Helm repository requests. This enables users to identify and track requests from ArgoCD, meet server requirements, or debug connectivity issues.

Closes #25459

Motivation

Some Helm repositories and OCI registries require or recommend specific User-Agent headers for:

  • Request tracking and analytics
  • Rate limiting and access control policies
  • Debugging and troubleshooting connectivity issues
  • Compliance with internal organizational standards

Currently, ArgoCD uses default HTTP client User-Agent values that may not meet these requirements.

Changes

Core Implementation

  • Added UserAgent field to Repository CRD (pkg/apis/application/v1alpha1/repository_types.go)
  • Implemented User-Agent header support in Helm client for both traditional and OCI registries (util/helm/client.go, util/helm/creds.go)
  • Added priority handling: code-level > per-repository > default

CLI Support

  • Added --user-agent flag to argocd repo add command
  • Updated CLI command structure in cmd/util/repo.go and cmd/argocd/commands/repo.go

Documentation

  • Updated operator manual with declarative configuration examples (docs/operator-manual/declarative-setup.md)
  • Added user guide section with CLI and YAML examples (docs/user-guide/private-repositories.md)
  • Auto-generated CLI documentation updated

Testing

  • Added comprehensive test suite in util/helm/client_test.go:
    • TestUserAgentIsSet - Verifies default and custom User-Agent
    • TestUserAgentRequiredByServer - Tests server requirements
    • TestUserAgentPriority - Validates precedence rules
  • All new tests passing

Example Usage

CLI

argocd repo add https://charts.example.com --type=helm --user-agent="my-custom-agent/1.0"

Declarative

apiVersion: v1
kind: Secret
metadata:
  name: helm-repo
  namespace: argocd
  labels:
    argocd.argoproj.io/secret-type: repository
stringData:
  name: my-helm-repo
  url: https://charts.example.com
  type: helm
  userAgent: my-custom-agent/1.0

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Title of the PR
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).
  • My build is green (troubleshooting builds).

Enables configuration of a custom HTTP User-Agent header via CLI flag, declarative config, or API fields for Helm repository operations.

Signed-off-by: Yugan <[email protected]>
@yugannkt yugannkt requested review from a team as code owners December 2, 2025 12:04
@bunnyshell
Copy link

bunnyshell bot commented Dec 2, 2025

🔴 Preview Environment stopped on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔵 /bns:start to start the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

@yugannkt yugannkt force-pushed the feat/add-user-agent-helm branch from b458a3e to 2a00617 Compare December 2, 2025 12:20
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.52%. Comparing base (3bf3d8a) to head (fa6150d).

Files with missing lines Patch % Lines
reposerver/repository/repository.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #25473      +/-   ##
==========================================
+ Coverage   62.49%   62.52%   +0.02%     
==========================================
  Files         351      351              
  Lines       49602    49620      +18     
==========================================
+ Hits        31001    31026      +25     
+ Misses      15631    15621      -10     
- Partials     2970     2973       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 122 to 124
// UserAgent specifies a custom User-Agent string for HTTP requests to this Helm repository.
// If not set, a default User-Agent will be used.
UserAgent string `json:"userAgent,omitempty" protobuf:"bytes,28,opt,name=userAgent"`
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be set as an environment variable on the repo-server rather than being set on the repository.

Copy link
Author

@yugannkt yugannkt Dec 2, 2025

Choose a reason for hiding this comment

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

Thank you for the feedback! I'd like to understand your reasoning better before refactoring.

Questions:

  1. Would you prefer a single global User-Agent for all Helm repos, or should there be a way to override per-repository?
  2. Are there specific concerns with the current per-repository approach?
  3. Would a hybrid approach (env var as default + per-repo override) make sense?

My concern: Other repo-specific configs (credentials, proxy, TLS) are set per-repository. Would an env-var-only approach be inconsistent? Or is User-Agent different enough that it should be global?

Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Would you prefer a single global User-Agent for all Helm repos, or should there be a way to override per-repository?

IMO this should be a global option. Up until now there has been no need for setting a header for a Helm repository, and I don't anticipate there will be much of a need to configure this on a per repository basis either.

Are there specific concerns with the current per-repository approach?

We already have too many options on the Repository object as-is.

Would a hybrid approach (env var as default + per-repo override) make sense?

No

@yugannkt
Copy link
Author

yugannkt commented Dec 4, 2025

Hy @blakepettersson

Refactored per feedback - Changed from per-repository User-Agent configuration to a global environment variable approach, Please review it

Thank you :)

Copy link
Member

@blakepettersson blakepettersson left a comment

Choose a reason for hiding this comment

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

See comment

@yugannkt
Copy link
Author

yugannkt commented Dec 6, 2025

Hy @blakepettersson

All requested changes have been addressed:

The Helm User-Agent is now set globally via the repo-server using the ARGOCD_HELM_USER_AGENT environment variable.
Please review it :)

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.

Argocd helm library does not seem to provide an User-Agent when downloading charts

2 participants