• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mindersec / minder / 12583378746

02 Jan 2025 01:44PM UTC coverage: 55.135%. First build
12583378746

Pull #4829

github

web-flow
Merge 88258024f into 4cd5e165e
Pull Request #4829: Add NATS publisher support to reminder

17 of 32 new or added lines in 4 files covered. (53.13%)

16980 of 30797 relevant lines covered (55.14%)

38.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.38
/pkg/config/reminder/config.go
1
// SPDX-FileCopyrightText: Copyright 2024 The Minder Authors
2
// SPDX-License-Identifier: Apache-2.0
3

4
// Package reminder contains configuration options for the reminder service.
5
package reminder
6

7
import (
8
        "fmt"
9
        "strings"
10

11
        "github.com/spf13/pflag"
12
        "github.com/spf13/viper"
13

14
        "github.com/mindersec/minder/pkg/config"
15
        serverconfig "github.com/mindersec/minder/pkg/config/server"
16
        "github.com/mindersec/minder/pkg/eventer/constants"
17
)
18

19
// Config contains the configuration for the reminder service
20
type Config struct {
21
        Database         config.DatabaseConfig    `mapstructure:"database"`
22
        RecurrenceConfig RecurrenceConfig         `mapstructure:"recurrence"`
23
        EventConfig      serverconfig.EventConfig `mapstructure:"events"`
24
        LoggingConfig    LoggingConfig            `mapstructure:"logging"`
25
}
26

27
// Validate validates the configuration
28
func (c Config) Validate() error {
4✔
29
        err := c.RecurrenceConfig.Validate()
4✔
30
        if err != nil {
6✔
31
                return err
2✔
32
        }
2✔
33

34
        err = validateEventConfig(c.EventConfig)
2✔
35
        if err != nil {
3✔
36
                return err
1✔
37
        }
1✔
38

39
        return nil
1✔
40
}
41

42
// SetViperDefaults sets the default values for the configuration to be picked up by viper
43
func SetViperDefaults(v *viper.Viper) {
4✔
44
        v.SetEnvPrefix("reminder")
4✔
45
        v.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_"))
4✔
46
        config.SetViperStructDefaults(v, "", Config{})
4✔
47
}
4✔
48

49
// RegisterReminderFlags registers the flags for the minder cli
50
func RegisterReminderFlags(v *viper.Viper, flags *pflag.FlagSet) error {
1✔
51
        viperPath := "logging.level"
1✔
52
        if err := config.BindConfigFlag(v, flags, viperPath, "logging-level",
1✔
53
                v.GetString(viperPath), "Logging level for reminder", flags.String); err != nil {
1✔
54
                return err
×
55
        }
×
56

57
        if err := config.RegisterDatabaseFlags(v, flags); err != nil {
1✔
58
                return err
×
59
        }
×
60

61
        return registerRecurrenceFlags(v, flags)
1✔
62
}
63

64
func validateEventConfig(cfg serverconfig.EventConfig) error {
2✔
65
        switch cfg.Driver {
2✔
NEW
66
        case constants.NATSDriver:
×
67
        case constants.SQLDriver:
1✔
68
        default:
1✔
69
                return fmt.Errorf("events.driver %s is not supported", cfg.Driver)
1✔
70
        }
71

72
        return nil
1✔
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc