Skip to content

Commit

Permalink
Print monitor/processor configuration in debug
Browse files Browse the repository at this point in the history
To get some potentially helpful information on how the running
configuration is configured.

Signed-off-by: Nicolas Bock <[email protected]>
  • Loading branch information
nicolasbock committed Sep 26, 2023
1 parent a1fbb3d commit fbe4c0e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
13 changes: 10 additions & 3 deletions cmd/monitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ package main

import (
"context"
"os"
"os/signal"
"strings"
"syscall"

"github.com/canonical/athena-core/pkg/common"
"github.com/canonical/athena-core/pkg/config"
"github.com/canonical/athena-core/pkg/monitor"
"github.com/lileio/pubsub/v2"
"github.com/lileio/pubsub/v2/providers/nats"
"github.com/nats-io/stan.go"
log "github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
"os"
"os/signal"
"syscall"
)

var (
Expand All @@ -30,6 +33,10 @@ func main() {
if err != nil {
panic(err)
}
log.Debug("Configuration")
for _, line := range strings.Split(cfg.String(), "\n") {
log.Debug(line)
}

filesClient, err := common.NewFilesComClient(cfg.FilesCom.Key, cfg.FilesCom.Endpoint)
if err != nil {
Expand Down
12 changes: 9 additions & 3 deletions cmd/processor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package main

import (
"context"
"os"
"os/signal"
"strings"
"syscall"

"github.com/canonical/athena-core/pkg/common"
"github.com/canonical/athena-core/pkg/config"
"github.com/canonical/athena-core/pkg/processor"
Expand All @@ -11,9 +16,6 @@ import (
"github.com/nats-io/stan.go"
log "github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
"os"
"os/signal"
"syscall"
)

var (
Expand All @@ -31,6 +33,10 @@ func main() {
if err != nil {
panic(err)
}
log.Debug("Configuration")
for _, line := range strings.Split(cfg.String(), "\n") {
log.Debug(line)
}

filesClient, err := common.NewFilesComClient(cfg.FilesCom.Key, cfg.FilesCom.Endpoint)
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ type Config struct {
} `yaml:"filescom,omitempty"`
}

func (cfg *Config) String() string {
tempCfg := *cfg
// Sanitize output, i.e. remove sensitive information.
tempCfg.Salesforce.Password = "**********"
tempCfg.Salesforce.SecurityToken = "**********"
tempCfg.FilesCom.Key = "**********"
result, err := yaml.Marshal(tempCfg)
if err != nil {
return "could not marshal config"
}
return string(result)
}

func NewConfigFromFile(filePaths []string) (*Config, error) {
var config Config

Expand Down

0 comments on commit fbe4c0e

Please sign in to comment.