@@ -79,39 +79,24 @@ type Application struct {
7979 asyncErrorChannel chan error
8080}
8181
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-
9782// 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 {
10085 return nil , err
10186 }
10287
10388 app := & Application {
104- info : params .BuildInfo ,
105- factories : params .Factories ,
89+ info : set .BuildInfo ,
90+ factories : set .Factories ,
10691 stateChannel : make (chan State , Closed + 1 ),
10792 }
10893
10994 rootCmd := & cobra.Command {
110- Use : params .BuildInfo .Command ,
111- Version : params .BuildInfo .Version ,
95+ Use : set .BuildInfo .Command ,
96+ Version : set .BuildInfo .Version ,
11297 RunE : func (cmd * cobra.Command , args []string ) error {
11398 var err error
114- if app .logger , err = newLogger (params .LoggingOptions ); err != nil {
99+ if app .logger , err = newLogger (set .LoggingOptions ); err != nil {
115100 return fmt .Errorf ("failed to get logger: %w" , err )
116101 }
117102
@@ -134,7 +119,7 @@ func New(params Parameters) (*Application, error) {
134119 rootCmd .Flags ().AddGoFlagSet (flagSet )
135120 app .rootCmd = rootCmd
136121
137- parserProvider := params .ParserProvider
122+ parserProvider := set .ParserProvider
138123 if parserProvider == nil {
139124 // use default provider.
140125 parserProvider = parserprovider .Default ()
@@ -235,9 +220,9 @@ func (app *Application) setupConfigurationComponents(ctx context.Context) error
235220
236221 app .logger .Info ("Applying configuration..." )
237222
238- service , err := newService (& settings {
239- Factories : app .factories ,
223+ service , err := newService (& svcSettings {
240224 BuildInfo : app .info ,
225+ Factories : app .factories ,
241226 Config : cfg ,
242227 Logger : app .logger ,
243228 AsyncErrorChannel : app .asyncErrorChannel ,
0 commit comments