Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithunikzz committed Apr 26, 2024
1 parent a6f238d commit 495d5c3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 61 deletions.
27 changes: 12 additions & 15 deletions agent/container/pkg/clients/nats_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,22 @@ func NewNATSContext(conf *config.Config) (*NATSContext, error) {
if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
//nats.Token(conf.NatsToken),
nats.Secure(tlsConfig),
)
if err != nil {
log.Fatal("error while connecting with mtls ", err)
}
log.Println("Error while getting TLS config:", err)
return nil, err
}

}

if conn == nil {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
nats.Secure(tlsConfig),
)
if err != nil {
log.Fatal("Error while connecting with mTLS:", err)
}
} else {
conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
if err != nil {
return nil, fmt.Errorf("error while connecting with token: %w", err)
log.Println("Error while connecting with token:", err)
return nil, err
}
}

Expand Down
27 changes: 12 additions & 15 deletions agent/git/pkg/clients/nats_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,22 @@ func NewNATSContext(conf *config.Config) (*NATSContext, error) {
if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
//nats.Token(conf.NatsToken),
nats.Secure(tlsConfig),
)
if err != nil {
log.Fatal("error while connecting with mtls ", err)
}
log.Println("Error while getting TLS config:", err)
return nil, err
}

}

if conn == nil {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
nats.Secure(tlsConfig),
)
if err != nil {
log.Fatal("Error while connecting with mTLS:", err)
}
} else {
conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
if err != nil {
return nil, fmt.Errorf("error while connecting with token: %w", err)
log.Println("Error while connecting with token:", err)
return nil, err
}
}

Expand Down
32 changes: 15 additions & 17 deletions agent/kubviz/k8smetrics_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,23 @@ func main() {
if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
nc, err = nats.Connect(
natsurl,
nats.Name("K8s Metrics"),
//nats.Token(token),
nats.Secure(tlsConfig),
)
if err != nil {
log.Fatal("error while connecting with mtls ", err)
}
log.Println("Error while getting TLS config:", err)
//return nil, err
}

}

if nc == nil {
nc, err = nats.Connect(natsurl, nats.Name("K8s Metrics"), nats.Token(token))
events.CheckErr(err)
nc, err = nats.Connect(natsurl,
nats.Name("Github metrics"),
nats.Secure(tlsConfig),
)
if err != nil {
log.Fatal("Error while connecting with mTLS:", err)
}
} else {
nc, err = nats.Connect(natsurl, nats.Name("Github metrics"), nats.Token(token))
if err != nil {
log.Println("Error while connecting with token:", err)
//return nil, err
}
}
js, err := nc.JetStream()
events.CheckErr(err)
Expand Down
26 changes: 12 additions & 14 deletions client/pkg/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,22 @@ func NewNATSContext(conf *config.Config, dbClient clickhouse.DBInterface) (*NATS
if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
//nats.Token(conf.NatsToken),
nats.Secure(tlsConfig),
)
if err != nil {
log.Fatal("error while connecting with mtls ", err)
}
log.Println("Error while getting TLS config:", err)
return nil, err
}
}

if conn == nil {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
nats.Secure(tlsConfig),
)
if err != nil {
log.Fatal("Error while connecting with mTLS:", err)
}
} else {
conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
if err != nil {
return nil, fmt.Errorf("error while connecting with token: %w", err)
log.Println("Error while connecting with token:", err)
return nil, err
}
}

Expand Down

0 comments on commit 495d5c3

Please sign in to comment.