Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
savnadya committed Feb 22, 2024
1 parent 11fc26f commit 8e056a8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
5 changes: 0 additions & 5 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import (
"k8s.io/utils/clock"
)

type Source interface {
GetUsers() ([]SourceUser, error)
GetGroupsWithMembers() ([]SourceGroupWithMembers, error)
}

type App struct {
syncInterval *time.Duration
usernameReplaces []ReplacementPair
Expand Down
4 changes: 4 additions & 0 deletions azure_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func (a *AzureFake) setGroups(groups []SourceGroupWithMembers) {
a.groups = groups
}

func (a *AzureFake) GetSourceType() SourceType {
return AzureSourceType
}

func (a *AzureFake) GetUsers() ([]SourceUser, error) {
return a.users, nil
}
Expand Down
4 changes: 4 additions & 0 deletions azure_real.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func handleNil[T any](s *T) T {
return result
}

func (a *AzureReal) GetSourceType() SourceType {
return AzureSourceType
}

func (a *AzureReal) GetUsers() ([]SourceUser, error) {
ctx, cancel := context.WithTimeout(context.Background(), a.timeout)
defer cancel()
Expand Down
4 changes: 2 additions & 2 deletions diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (a *App) syncUsers() (map[ObjectID]YtsaurusUser, error) {
}
}

ytUsers, err := a.ytsaurus.GetUsers()
ytUsers, err := a.ytsaurus.GetUsers(a.source.GetSourceType())
if err != nil {
return nil, errors.Wrap(err, "failed to get YTsaurus users")
}
Expand Down Expand Up @@ -118,7 +118,7 @@ func (a *App) syncGroups(usersMap map[ObjectID]YtsaurusUser) error {
if err != nil {
return errors.Wrap(err, "failed to get Source groups")
}
ytGroups, err := a.ytsaurus.GetGroupsWithMembers()
ytGroups, err := a.ytsaurus.GetGroupsWithMembers(a.source.GetSourceType())
if err != nil {
return errors.Wrap(err, "failed to get YTsaurus groups")
}
Expand Down
4 changes: 4 additions & 0 deletions ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func NewLdap(cfg *LdapConfig, logger appLoggerType) (*Ldap, error) {
}, nil
}

func (source *Ldap) GetSourceType() SourceType {
return LdapSourceType
}

func (source *Ldap) GetUsers() ([]SourceUser, error) {
res, err := source.Connection.Search(&ldap.SearchRequest{
BaseDN: source.Config.BaseDN,
Expand Down
6 changes: 6 additions & 0 deletions source_models.go → source.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const (
AzureSourceType SourceType = "azure"
)

type Source interface {
GetUsers() ([]SourceUser, error)
GetGroupsWithMembers() ([]SourceGroupWithMembers, error)
GetSourceType() SourceType
}

type SourceUser interface {
GetID() ObjectID
GetName() string
Expand Down

0 comments on commit 8e056a8

Please sign in to comment.