Skip to content

Commit

Permalink
Beholder: rename cert config option
Browse files Browse the repository at this point in the history
  • Loading branch information
pkcll committed Aug 9, 2024
1 parent 0bdc6d2 commit 5afe2ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions pkg/beholder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ func newOtelClient(cfg Config, errorHandler errorHandlerFunc, otlploggrpcNew otl
if err != nil {
return nil, err
}
var creds credentials.TransportCredentials
creds = insecure.NewCredentials()
if !cfg.InsecureConnection && cfg.TLSCertFile != "" {
creds, err = credentials.NewClientTLSFromFile(cfg.TLSCertFile, "")
creds := insecure.NewCredentials()
if !cfg.InsecureConnection && cfg.CACertFile != "" {
creds, err = credentials.NewClientTLSFromFile(cfg.CACertFile, "")
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/beholder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type Config struct {
InsecureConnection bool
TLSCertFile string
CACertFile string
OtelExporterGRPCEndpoint string

PackageName string
Expand All @@ -32,7 +32,7 @@ var defaultOtelAttributes = map[string]string{
func DefaultConfig() Config {
return Config{
InsecureConnection: true,
TLSCertFile: "",
CACertFile: "",
OtelExporterGRPCEndpoint: "localhost:4317",
PackageName: "beholder",
// Resource
Expand Down
4 changes: 2 additions & 2 deletions pkg/beholder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
func ExampleConfig() {
config := beholder.Config{
InsecureConnection: true,
TLSCertFile: "",
CACertFile: "",
OtelExporterGRPCEndpoint: "localhost:4317",
PackageName: packageName,
// Resource
Expand All @@ -34,5 +34,5 @@ func ExampleConfig() {
}
fmt.Printf("%+v", config)
// Output:
// {InsecureConnection:true TLSCertFile: OtelExporterGRPCEndpoint:localhost:4317 PackageName:beholder ResourceAttributes:map[package_name:beholder sender:beholdeclient] EmitterExportTimeout:1s TraceSampleRate:1 TraceBatchTimeout:1s MetricReaderInterval:1s LogExportTimeout:1s}
// {InsecureConnection:true CACertFile: OtelExporterGRPCEndpoint:localhost:4317 PackageName:beholder ResourceAttributes:map[package_name:beholder sender:beholdeclient] EmitterExportTimeout:1s TraceSampleRate:1 TraceBatchTimeout:1s MetricReaderInterval:1s LogExportTimeout:1s}
}

0 comments on commit 5afe2ec

Please sign in to comment.