Skip to content

Commit

Permalink
feat: allow no_proxy to be specified on repoCreds
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Liechti <[email protected]>
  • Loading branch information
the-technat committed Jun 20, 2024
1 parent 1aeed6a commit 534c567
Show file tree
Hide file tree
Showing 39 changed files with 1,116 additions and 863 deletions.
8 changes: 8 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8112,6 +8112,10 @@
"type": "string",
"title": "GithubAppPrivateKey specifies the private key PEM data for authentication via GitHub app"
},
"noProxy": {
"type": "string",
"title": "NoProxy specifies a list of targets where the proxy isn't used, applies only in cases where the proxy is applied"
},
"password": {
"type": "string",
"title": "Password for authenticating at the repo server"
Expand Down Expand Up @@ -8218,6 +8222,10 @@
"type": "string",
"title": "Name specifies a name to be used for this repo. Only used with Helm repos"
},
"noProxy": {
"type": "string",
"title": "NoProxy specifies a list of targets where the proxy isn't used, applies only in cases where the proxy is applied"
},
"password": {
"type": "string",
"title": "Password contains the password or PAT used for authenticating at the remote repository"
Expand Down
1 change: 1 addition & 0 deletions cmd/argocd/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func NewRepoAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
repoOpts.Repo.GithubAppInstallationId = repoOpts.GithubAppInstallationId
repoOpts.Repo.GitHubAppEnterpriseBaseURL = repoOpts.GitHubAppEnterpriseBaseURL
repoOpts.Repo.Proxy = repoOpts.Proxy
repoOpts.Repo.NoProxy = repoOpts.NoProxy
repoOpts.Repo.ForceHttpBasicAuth = repoOpts.ForceHttpBasicAuth

if repoOpts.Repo.Type == "helm" && repoOpts.Repo.Name == "" {
Expand Down
2 changes: 2 additions & 0 deletions cmd/util/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type RepoOptions struct {
GithubAppPrivateKeyPath string
GitHubAppEnterpriseBaseURL string
Proxy string
NoProxy string
GCPServiceAccountKeyPath string
ForceHttpBasicAuth bool
}
Expand All @@ -44,6 +45,7 @@ func AddRepoFlags(command *cobra.Command, opts *RepoOptions) {
command.Flags().StringVar(&opts.GithubAppPrivateKeyPath, "github-app-private-key-path", "", "private key of the GitHub Application")
command.Flags().StringVar(&opts.GitHubAppEnterpriseBaseURL, "github-app-enterprise-base-url", "", "base url to use when using GitHub Enterprise (e.g. https://ghe.example.com/api/v3")
command.Flags().StringVar(&opts.Proxy, "proxy", "", "use proxy to access repository")
command.Flags().StringVar(&opts.Proxy, "no-proxy", "", "don't access these targets via proxy")
command.Flags().StringVar(&opts.GCPServiceAccountKeyPath, "gcp-service-account-key-path", "", "service account key for the Google Cloud Platform")
command.Flags().BoolVar(&opts.ForceHttpBasicAuth, "force-http-basic-auth", false, "whether to force use of basic auth when connecting repository via HTTP")
}
7 changes: 5 additions & 2 deletions docs/operator-manual/declarative-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ data:

### Configure repositories with proxy

Proxy for your repository can be specified in the `proxy` field of the repository secret, along with other repository configurations. Argo CD uses this proxy to access the repository. Argo CD looks for the standard proxy environment variables in the repository server if the custom proxy is absent.
Proxy for your repository can be specified in the `proxy` field of the repository secret, along with a corresponding `noProxy` config. Argo CD uses this proxy/noProxy config to access the repository and do related helm/kustomize operations. Argo CD looks for the standard proxy environment variables in the repository server if the custom proxy config is absent.

An example repository with proxy:
An example repository with proxy and noProxy:

```yaml
apiVersion: v1
Expand All @@ -484,10 +484,13 @@ stringData:
type: git
url: https://github.com/argoproj/private-repo
proxy: https://proxy-server-url:8888
noProxy: ".internal.example.com"
password: my-password
username: my-username
```

A note on noProxy: Argo CD uses exec to interact with different tools such as helm and kustomize. Not all of these tools support the same noProxy syntax as the [httpproxy go package](https://cs.opensource.google/go/x/net/+/internal-branch.go1.21-vendor:http/httpproxy/proxy.go;l=38-50) does. In case you run in trouble with noProxy not beeing respected you might want to try using the full domain instead of a wildcard pattern or IP range to find a common syntax that all tools support.

### Legacy behaviour

In Argo CD version 2.0 and earlier, repositories were stored as part of the `argocd-cm` config map. For
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ argocd admin repo generate-spec REPOURL [flags]
--insecure-ignore-host-key disables SSH strict host key checking (deprecated, use --insecure-skip-server-verification instead)
--insecure-skip-server-verification disables server certificate and host key checks
--name string name of the repository, mandatory for repositories of type helm
--no-proxy string don't access these targets via proxy
-o, --output string Output format. One of: json|yaml (default "yaml")
--password string password to the repository
--project string project of the repository
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/commands/argocd_repo_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ argocd repo add REPOURL [flags]
--insecure-ignore-host-key disables SSH strict host key checking (deprecated, use --insecure-skip-server-verification instead)
--insecure-skip-server-verification disables server certificate and host key checks
--name string name of the repository, mandatory for repositories of type helm
--no-proxy string don't access these targets via proxy
--password string password to the repository
--project string project of the repository
--proxy string use proxy to access repository
Expand Down
2 changes: 1 addition & 1 deletion hack/gen-resources/generators/cluster_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (cg *ClusterGenerator) getClusterCredentials(namespace string, releaseSuffi

// TODO: also should provision service for vcluster pod
func (cg *ClusterGenerator) installVCluster(opts *util.GenerateOpts, namespace string, releaseName string) error {
cmd, err := helm.NewCmd("/tmp", "v3", "")
cmd, err := helm.NewCmd("/tmp", "v3", "", "")
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 534c567

Please sign in to comment.