@@ -23,13 +23,10 @@ import (
23
23
)
24
24
25
25
type ArgoClient struct {
26
- client apiclient.Client
27
-
28
- repoClient repoapiclient.RepoServerServiceClient
29
- namespace string
30
- k8s kubernetes.Interface
31
- k8sConfig * rest.Config
32
- sendFullRepository bool
26
+ client apiclient.Client
27
+ k8s kubernetes.Interface
28
+ k8sConfig * rest.Config
29
+ cfg config.ServerConfig
33
30
}
34
31
35
32
func NewArgoClient (
@@ -56,27 +53,27 @@ func NewArgoClient(
56
53
return nil , err
57
54
}
58
55
56
+ return & ArgoClient {
57
+ cfg : cfg ,
58
+ client : argo ,
59
+ k8s : k8s .ClientSet (),
60
+ k8sConfig : k8s .Config (),
61
+ }, nil
62
+ }
63
+
64
+ func (a * ArgoClient ) createRepoServerClient () (repoapiclient.RepoServerServiceClient , * grpc.ClientConn , error ) {
59
65
log .Info ().Msg ("creating client" )
60
- tlsConfig := tls.Config {InsecureSkipVerify : cfg .ArgoCDRepositoryInsecure }
61
- conn , err := grpc .NewClient (cfg .ArgoCDRepositoryEndpoint ,
62
- // without this, kubechecks picks a single pod and sends all requests to it
63
- grpc .WithDefaultServiceConfig (`{"loadBalancingConfig": [{"round_robin":{}}]}` ),
66
+ tlsConfig := tls.Config {InsecureSkipVerify : a .cfg .ArgoCDRepositoryInsecure }
67
+ conn , err := grpc .NewClient (a .cfg .ArgoCDRepositoryEndpoint ,
64
68
grpc .WithTransportCredentials (
65
69
credentials .NewTLS (& tlsConfig ),
66
70
),
67
71
)
68
72
if err != nil {
69
- return nil , errors .Wrap (err , "failed to create client" )
73
+ return nil , nil , errors .Wrap (err , "failed to create client" )
70
74
}
71
75
72
- return & ArgoClient {
73
- repoClient : repoapiclient .NewRepoServerServiceClient (conn ),
74
- client : argo ,
75
- namespace : cfg .ArgoCDNamespace ,
76
- k8s : k8s .ClientSet (),
77
- k8sConfig : k8s .Config (),
78
- sendFullRepository : cfg .ArgoCDSendFullRepository ,
79
- }, nil
76
+ return repoapiclient .NewRepoServerServiceClient (conn ), conn , nil
80
77
}
81
78
82
79
// GetApplicationClient has related argocd diff code https://github.com/argoproj/argo-cd/blob/d3ff9757c460ae1a6a11e1231251b5d27aadcdd1/cmd/argocd/commands/app.go#L899
0 commit comments