From f3e89705b58756b42e4baea37af900e6df125d05 Mon Sep 17 00:00:00 2001 From: Jener Rasmussen Date: Wed, 4 Dec 2024 14:31:24 +0100 Subject: [PATCH] Remove redundant struct definition --- pkg/tidydns/tidydns.go | 23 ++++++----------------- pkg/tidydns/types.go | 28 ++++++++++------------------ 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/pkg/tidydns/tidydns.go b/pkg/tidydns/tidydns.go index 4d386a4..b2da17e 100644 --- a/pkg/tidydns/tidydns.go +++ b/pkg/tidydns/tidydns.go @@ -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 @@ -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 @@ -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 } diff --git a/pkg/tidydns/types.go b/pkg/tidydns/types.go index b855371..c4432c7 100644 --- a/pkg/tidydns/types.go +++ b/pkg/tidydns/types.go @@ -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"` }