Skip to content

Commit

Permalink
add some debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
djeebus committed Feb 26, 2024
1 parent 25216c2 commit a40c17e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 6 additions & 4 deletions cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ func newContainer(ctx context.Context, cfg config.ServerConfig) (container.Conta
err = fmt.Errorf("unknown vcs-type: %q", cfg.VcsType)
}
if err != nil {
return ctr, err
return ctr, errors.Wrap(err, "failed to create vcs client")
}

ctr.ArgoClient = argo_client.NewArgoClient(cfg)
if ctr.ArgoClient, err = argo_client.NewArgoClient(cfg); err != nil {
return ctr, errors.Wrap(err, "failed to create argo client")
}

vcsToArgoMap := appdir.NewVcsToArgoMap()
ctr.VcsToArgoMap = vcsToArgoMap

if cfg.MonitorAllApplications {
if err = buildAppsMap(ctx, ctr.ArgoClient, ctr.VcsToArgoMap); err != nil {
return ctr, err
return ctr, errors.Wrap(err, "failed to build apps map")
}

ctr.ApplicationWatcher, err = app_watcher.NewApplicationWatcher(vcsToArgoMap)
if err != nil {
return ctr, err
return ctr, errors.Wrap(err, "failed to create watch applications")
}

go ctr.ApplicationWatcher.Run(ctx, 1)
Expand Down
18 changes: 13 additions & 5 deletions pkg/argo_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,29 @@ type ArgoClient struct {
client apiclient.Client
}

func NewArgoClient(cfg config.ServerConfig) *ArgoClient {
clientOptions := &apiclient.ClientOptions{
func NewArgoClient(cfg config.ServerConfig) (*ArgoClient, error) {
opts := &apiclient.ClientOptions{
ServerAddr: cfg.ArgoCDServerAddr,
AuthToken: cfg.ArgoCDToken,
GRPCWebRootPath: cfg.ArgoCDPathPrefix,
Insecure: cfg.ArgoCDInsecure,
}
argo, err := apiclient.NewClient(clientOptions)

log.Info().
Str("server-addr", opts.ServerAddr).
Int("auth-token", len(opts.AuthToken)).
Str("grpc-web-root-path", opts.GRPCWebRootPath).
Bool("insecure", cfg.ArgoCDInsecure).
Msg("ArgoCD client configuration")

argo, err := apiclient.NewClient(opts)
if err != nil {
log.Fatal().Err(err).Msg("could not create ArgoCD API client")
return nil, err
}

return &ArgoClient{
client: argo,
}
}, nil
}

// GetApplicationClient has related argocd diff code https://github.com/argoproj/argo-cd/blob/d3ff9757c460ae1a6a11e1231251b5d27aadcdd1/cmd/argocd/commands/app.go#L899
Expand Down

0 comments on commit a40c17e

Please sign in to comment.