mirror of
https://github.com/kazhuravlev/database-gateway.git
synced 2025-07-03 12:12:25 +00:00
86 lines
2.6 KiB
Go
86 lines
2.6 KiB
Go
// Code generated by options-gen v0.49.0. DO NOT EDIT.
|
|
|
|
package app
|
|
|
|
import (
|
|
fmt461e464ebed9 "fmt"
|
|
"log/slog"
|
|
|
|
"github.com/kazhuravlev/database-gateway/internal/app/rules"
|
|
"github.com/kazhuravlev/database-gateway/internal/config"
|
|
"github.com/kazhuravlev/database-gateway/internal/storage"
|
|
errors461e464ebed9 "github.com/kazhuravlev/options-gen/pkg/errors"
|
|
validator461e464ebed9 "github.com/kazhuravlev/options-gen/pkg/validator"
|
|
)
|
|
|
|
type OptOptionsSetter func(o *Options)
|
|
|
|
func NewOptions(
|
|
logger *slog.Logger,
|
|
targets []config.Target,
|
|
users config.UsersConfig,
|
|
acls *rules.ACLs,
|
|
storage *storage.Service,
|
|
options ...OptOptionsSetter,
|
|
) Options {
|
|
var o Options
|
|
|
|
// Setting defaults from field tag (if present)
|
|
|
|
o.logger = logger
|
|
o.targets = targets
|
|
o.users = users
|
|
o.acls = acls
|
|
o.storage = storage
|
|
|
|
for _, opt := range options {
|
|
opt(&o)
|
|
}
|
|
return o
|
|
}
|
|
|
|
func (o *Options) Validate() error {
|
|
errs := new(errors461e464ebed9.ValidationErrors)
|
|
errs.Add(errors461e464ebed9.NewValidationError("logger", _validate_Options_logger(o)))
|
|
errs.Add(errors461e464ebed9.NewValidationError("targets", _validate_Options_targets(o)))
|
|
errs.Add(errors461e464ebed9.NewValidationError("users", _validate_Options_users(o)))
|
|
errs.Add(errors461e464ebed9.NewValidationError("acls", _validate_Options_acls(o)))
|
|
errs.Add(errors461e464ebed9.NewValidationError("storage", _validate_Options_storage(o)))
|
|
return errs.AsError()
|
|
}
|
|
|
|
func _validate_Options_logger(o *Options) error {
|
|
if err := validator461e464ebed9.GetValidatorFor(o).Var(o.logger, "required"); err != nil {
|
|
return fmt461e464ebed9.Errorf("field `logger` did not pass the test: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func _validate_Options_targets(o *Options) error {
|
|
if err := validator461e464ebed9.GetValidatorFor(o).Var(o.targets, "required"); err != nil {
|
|
return fmt461e464ebed9.Errorf("field `targets` did not pass the test: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func _validate_Options_users(o *Options) error {
|
|
if err := validator461e464ebed9.GetValidatorFor(o).Var(o.users, "required"); err != nil {
|
|
return fmt461e464ebed9.Errorf("field `users` did not pass the test: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func _validate_Options_acls(o *Options) error {
|
|
if err := validator461e464ebed9.GetValidatorFor(o).Var(o.acls, "required"); err != nil {
|
|
return fmt461e464ebed9.Errorf("field `acls` did not pass the test: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func _validate_Options_storage(o *Options) error {
|
|
if err := validator461e464ebed9.GetValidatorFor(o).Var(o.storage, "required"); err != nil {
|
|
return fmt461e464ebed9.Errorf("field `storage` did not pass the test: %w", err)
|
|
}
|
|
return nil
|
|
}
|