Skip to content
Snippets Groups Projects
Commit a7f39bde authored by ko_oler's avatar ko_oler
Browse files

правки

parent 8adb7cab
No related branches found
No related tags found
No related merge requests found
...@@ -93,6 +93,12 @@ func UpdateExistingClient() ClientsOption { ...@@ -93,6 +93,12 @@ func UpdateExistingClient() ClientsOption {
} }
} }
func PrepareClients(handler func(client *clients.Client)) ClientsOption {
return func(c *ClientConfig) {
handler(c.client)
}
}
func (s *Setup) InstallClients(ctx context.Context) error { func (s *Setup) InstallClients(ctx context.Context) error {
if len(s.Clients) == 0 { if len(s.Clients) == 0 {
return nil return nil
...@@ -101,9 +107,6 @@ func (s *Setup) InstallClients(ctx context.Context) error { ...@@ -101,9 +107,6 @@ func (s *Setup) InstallClients(ctx context.Context) error {
s.logger.Debug("Install clients", zap.String("Space ID", s.SpaceID)) s.logger.Debug("Install clients", zap.String("Space ID", s.SpaceID))
for _, c := range s.Clients { for _, c := range s.Clients {
if s.ClientsPrepareFn != nil {
s.ClientsPrepareFn(c.client)
}
err := s.InstallClient(ctx, c) err := s.InstallClient(ctx, c)
if err != nil { if err != nil {
s.logger.Error("Failed to install client", zap.String("Client ID", c.client.ID), zap.String("Client Name", c.client.Name), zap.Error(err)) s.logger.Error("Failed to install client", zap.String("Client ID", c.client.ID), zap.String("Client Name", c.client.Name), zap.Error(err))
......
...@@ -134,9 +134,6 @@ func (s *Setup) InstallCollections(ctx context.Context) (err error) { ...@@ -134,9 +134,6 @@ func (s *Setup) InstallCollections(ctx context.Context) (err error) {
var migrate, setSchema bool var migrate, setSchema bool
for _, c := range s.Collections { for _, c := range s.Collections {
if s.CollectionsPrepareFn != nil {
s.CollectionsPrepareFn(c.collection)
}
setSchema, err = s.InstallCollection(ctx, c) setSchema, err = s.InstallCollection(ctx, c)
if err != nil { if err != nil {
s.logger.Error("Failed to install collection", s.logger.Error("Failed to install collection",
......
...@@ -18,11 +18,6 @@ type Config struct { ...@@ -18,11 +18,6 @@ type Config struct {
Clients []ClientConfig Clients []ClientConfig
Collections []CollectionConfig Collections []CollectionConfig
Items []ItemConfig Items []ItemConfig
RolesPrepareFn func(r *roles.Role)
ClientsPrepareFn func(c *clients.Client)
CollectionsPrepareFn func(c *collections.Collection)
ItemsPrepareFn func(i *items.Item)
} }
func NewConfig() *Config { func NewConfig() *Config {
......
...@@ -190,9 +190,6 @@ func (s *Setup) InstallItems(ctx context.Context) (err error) { ...@@ -190,9 +190,6 @@ func (s *Setup) InstallItems(ctx context.Context) (err error) {
return err return err
} }
for _, c := range itms { for _, c := range itms {
if s.ItemsPrepareFn != nil {
s.ItemsPrepareFn(c.item)
}
if err := s.InstallItem(ctx, exists, c); err != nil { if err := s.InstallItem(ctx, exists, c); err != nil {
s.logger.Error("Failed to install item", s.logger.Error("Failed to install item",
zap.String("ID", c.item.ID), zap.String("ID", c.item.ID),
......
...@@ -113,9 +113,6 @@ func (s *Setup) InstallRoles(ctx context.Context) error { ...@@ -113,9 +113,6 @@ func (s *Setup) InstallRoles(ctx context.Context) error {
s.logger.Debug("Install role", zap.String("Space ID", s.SpaceID), zap.Int("Roles", len(s.Roles))) s.logger.Debug("Install role", zap.String("Space ID", s.SpaceID), zap.Int("Roles", len(s.Roles)))
for _, c := range s.Roles { for _, c := range s.Roles {
if s.RolesPrepareFn != nil {
s.RolesPrepareFn(c.role)
}
if err := s.InstallRole(ctx, c); err != nil { if err := s.InstallRole(ctx, c); err != nil {
s.logger.Error("Failed to install role", zap.String("Role ID", c.role.ID), zap.Error(err)) s.logger.Error("Failed to install role", zap.String("Role ID", c.role.ID), zap.Error(err))
return errors.Wrap(errors.WithDetailf(err, "Возникла ошибка при настройке роли %s(%s)", c.role.ID, c.role.Description), "failed to install role") return errors.Wrap(errors.WithDetailf(err, "Возникла ошибка при настройке роли %s(%s)", c.role.ID, c.role.Description), "failed to install role")
......
...@@ -68,12 +68,6 @@ func (s *Setup) WithForce(force bool) *Setup { ...@@ -68,12 +68,6 @@ func (s *Setup) WithForce(force bool) *Setup {
return &setup return &setup
} }
func (s *Setup) WithClientsPrepareFunc(fn func(c *clients.Client)) *Setup {
setup := *s
setup.ClientsPrepareFn = fn
return &setup
}
func (s *Setup) IsForce() bool { func (s *Setup) IsForce() bool {
return s.force return s.force
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment