Skip to content

Commit

Permalink
Remove redundant struct definition
Browse files Browse the repository at this point in the history
  • Loading branch information
jenrik committed Dec 4, 2024
1 parent 7b5d42d commit f3e8970
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 35 deletions.
23 changes: 6 additions & 17 deletions pkg/tidydns/tidydns.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ type UserInfo struct {
}

type UserInfoGroup struct {
GroupName string
Name string
Notes *string
Id int
Description *string
GroupName string `json:"groupname"`
Name string `json:"name"`
Notes *string `json:"notes,omitempty"`
Id int `json:"id"`
Description *string `json:"description,omitempty"`
}

type UserID int
Expand Down Expand Up @@ -218,17 +218,6 @@ func (c *tidyDNSClient) GetInternalUser(ctx context.Context, userID UserID) (*Us
return nil, err
}

var groups = make([]UserInfoGroup, 0, len(user.Groups))
for _, group := range user.Groups {
groups = append(groups, UserInfoGroup{
GroupName: group.GroupName,
Name: group.Name,
Notes: group.Notes,
Id: group.Id,
Description: group.Description,
})
}

modifiedDate, err := time.Parse(time.DateTime, user.ModifiedDate)
if err != nil {
return nil, err
Expand Down Expand Up @@ -258,7 +247,7 @@ func (c *tidyDNSClient) GetInternalUser(ctx context.Context, userID UserID) (*Us
Name: user.Name,
PasswdChangedDate: passwordChangedDate,
Id: UserID(user.Id),
Groups: groups,
Groups: user.Groups,
}, nil
}

Expand Down
28 changes: 10 additions & 18 deletions pkg/tidydns/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,14 @@ type userCreate struct {
}

type userRead struct {
ModifiedBy string `json:"modified_by"`
Description string `json:"description"`
ModifiedDate string `json:"modified_date"`
Username string `json:"username"`
AuthGroup string `json:"auth_group"`
Name string `json:"name"`
Epassword string `json:"epassword"`
PasswdChangedDate string `json:"passwd_changed_date"`
Id int `json:"id"`
Groups []userGroup `json:"groups"`
}

type userGroup struct {
GroupName string `json:"groupname"`
Name string `json:"name"`
Notes *string `json:"notes,omitempty"`
Id int `json:"id"`
Description *string `json:"description,omitempty"`
ModifiedBy string `json:"modified_by"`
Description string `json:"description"`
ModifiedDate string `json:"modified_date"`
Username string `json:"username"`
AuthGroup string `json:"auth_group"`
Name string `json:"name"`
Epassword string `json:"epassword"`
PasswdChangedDate string `json:"passwd_changed_date"`
Id int `json:"id"`
Groups []UserInfoGroup `json:"groups"`
}

0 comments on commit f3e8970

Please sign in to comment.