@@ -79,39 +79,24 @@ type Application struct {
79
79
asyncErrorChannel chan error
80
80
}
81
81
82
- // Parameters holds configuration for creating a new Application.
83
- type Parameters struct {
84
- // Factories component factories.
85
- Factories component.Factories
86
- // BuildInfo provides application start information.
87
- BuildInfo component.BuildInfo
88
- // ParserProvider provides the configuration's Parser.
89
- // If it is not provided a default provider is used. The default provider loads the configuration
90
- // from a config file define by the --config command line flag and overrides component's configuration
91
- // properties supplied via --set command line flag.
92
- ParserProvider parserprovider.ParserProvider
93
- // LoggingOptions provides a way to change behavior of zap logging.
94
- LoggingOptions []zap.Option
95
- }
96
-
97
82
// New creates and returns a new instance of Application.
98
- func New (params Parameters ) (* Application , error ) {
99
- if err := configcheck .ValidateConfigFromFactories (params .Factories ); err != nil {
83
+ func New (set AppSettings ) (* Application , error ) {
84
+ if err := configcheck .ValidateConfigFromFactories (set .Factories ); err != nil {
100
85
return nil , err
101
86
}
102
87
103
88
app := & Application {
104
- info : params .BuildInfo ,
105
- factories : params .Factories ,
89
+ info : set .BuildInfo ,
90
+ factories : set .Factories ,
106
91
stateChannel : make (chan State , Closed + 1 ),
107
92
}
108
93
109
94
rootCmd := & cobra.Command {
110
- Use : params .BuildInfo .Command ,
111
- Version : params .BuildInfo .Version ,
95
+ Use : set .BuildInfo .Command ,
96
+ Version : set .BuildInfo .Version ,
112
97
RunE : func (cmd * cobra.Command , args []string ) error {
113
98
var err error
114
- if app .logger , err = newLogger (params .LoggingOptions ); err != nil {
99
+ if app .logger , err = newLogger (set .LoggingOptions ); err != nil {
115
100
return fmt .Errorf ("failed to get logger: %w" , err )
116
101
}
117
102
@@ -134,7 +119,7 @@ func New(params Parameters) (*Application, error) {
134
119
rootCmd .Flags ().AddGoFlagSet (flagSet )
135
120
app .rootCmd = rootCmd
136
121
137
- parserProvider := params .ParserProvider
122
+ parserProvider := set .ParserProvider
138
123
if parserProvider == nil {
139
124
// use default provider.
140
125
parserProvider = parserprovider .Default ()
@@ -235,9 +220,9 @@ func (app *Application) setupConfigurationComponents(ctx context.Context) error
235
220
236
221
app .logger .Info ("Applying configuration..." )
237
222
238
- service , err := newService (& settings {
239
- Factories : app .factories ,
223
+ service , err := newService (& svcSettings {
240
224
BuildInfo : app .info ,
225
+ Factories : app .factories ,
241
226
Config : cfg ,
242
227
Logger : app .logger ,
243
228
AsyncErrorChannel : app .asyncErrorChannel ,
0 commit comments