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 495d5c3 commit 7ac9968
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 62 deletions.
30 changes: 15 additions & 15 deletions agent/container/pkg/clients/nats_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,30 @@ func NewNATSContext(conf *config.Config) (*NATSContext, error) {
//conn, err := nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
var conn *nats.Conn
var err error
var mtlsConfig mtlsnats.MtlsConfig

if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("Error while getting TLS config:", err)
return nil, err
}
//var mtlsConfig mtlsnats.MtlsConfig

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)
}
} else {
conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
if err != nil {
log.Println("Error while connecting with token:", err)
return nil, err
log.Fatal("error while connecting with mtls ", err)
}
}

// if conn == nil {
// 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)
// }
// }

ctx := &NATSContext{
conf: conf,
conn: conn,
Expand Down
30 changes: 15 additions & 15 deletions agent/git/pkg/clients/nats_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,30 @@ func NewNATSContext(conf *config.Config) (*NATSContext, error) {

var conn *nats.Conn
var err error
var mtlsConfig mtlsnats.MtlsConfig

if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("Error while getting TLS config:", err)
return nil, err
}
//var mtlsConfig mtlsnats.MtlsConfig

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)
}
} else {
conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
if err != nil {
log.Println("Error while connecting with token:", err)
return nil, err
log.Fatal("error while connecting with mtls ", err)
}
}

// if conn == nil {
// 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)
// }
// }

ctx := &NATSContext{
conf: conf,
conn: conn,
Expand Down
34 changes: 17 additions & 17 deletions agent/kubviz/k8smetrics_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,30 @@ func main() {
clientset *kubernetes.Clientset
)

var mtlsConfig mtlsnats.MtlsConfig
//var mtlsConfig mtlsnats.MtlsConfig
var nc *nats.Conn

if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("Error while getting TLS config:", err)
//return nil, err
}

nc, err = nats.Connect(natsurl,
nats.Name("Github metrics"),
//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)
}
} 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
log.Fatal("error while connecting with mtls ", err)
}
}

// if nc == nil {
// nc, err = nats.Connect(natsurl, nats.Name("K8s Metrics"), nats.Token(token))
// events.CheckErr(err)
// }
js, err := nc.JetStream()
events.CheckErr(err)
err = events.CreateStream(js)
Expand Down
30 changes: 15 additions & 15 deletions client/pkg/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@ func NewNATSContext(conf *config.Config, dbClient clickhouse.DBInterface) (*NATS

var conn *nats.Conn
var err error
var mtlsConfig mtlsnats.MtlsConfig

if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("Error while getting TLS config:", err)
return nil, err
}
//var mtlsConfig mtlsnats.MtlsConfig

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)
}
} else {
conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
if err != nil {
log.Println("Error while connecting with token:", err)
return nil, err
log.Fatal("error while connecting with mtls ", err)
}
}

// if conn == nil {
// 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)
// }
// }

ctx := &NATSContext{
conf: conf,
conn: conn,
Expand Down

0 comments on commit 7ac9968

Please sign in to comment.