From 11c57d3485c2e472819630f1a40ed0c29d462915 Mon Sep 17 00:00:00 2001 From: Yves Biener Date: Fri, 20 Oct 2023 13:53:38 +0200 Subject: [PATCH] mod(gitea-api): add json encoding informations for all structs --- internal/gitea/comment.go | 22 +++++++-------- internal/gitea/issue.go | 54 ++++++++++++++++++------------------ internal/gitea/milestone.go | 20 ++++++------- internal/gitea/repository.go | 8 +++--- internal/gitea/user.go | 42 ++++++++++++++-------------- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/internal/gitea/comment.go b/internal/gitea/comment.go index bc528b1..d367666 100644 --- a/internal/gitea/comment.go +++ b/internal/gitea/comment.go @@ -9,17 +9,17 @@ import ( ) type Comment struct { - Id uint - Body string - Issue_url string - Assets []string - Html_url string - User User - Original_author string - Original_author_id uint - Pull_request_url string - Created_at time.Time - Updated_at time.Time + Id uint `json:"id"` + Body string `json:"body"` + Issue_url string `json:"issue_url"` + Assets []string `json:"assets"` + Html_url string `json:"html_url"` + User User `json:"user"` + Original_author string `json:"original_author"` + Original_author_id uint `json:"original_author_id"` + Pull_request_url string `json:"pull_request_url"` + Created_at time.Time `json:"created_at"` + Updated_at time.Time `json:"updated_at"` } func (gitea *Gitea) GetComments(repo Repository) ([]Comment, error) { diff --git a/internal/gitea/issue.go b/internal/gitea/issue.go index 668e0dc..f8895ba 100644 --- a/internal/gitea/issue.go +++ b/internal/gitea/issue.go @@ -9,36 +9,36 @@ import ( ) type PullRequest struct { - Merged bool - Merged_at time.Time + Merged bool `json:"merged"` + Merged_at time.Time `json:"merged_at"` } type Issue struct { - Id uint - Url string - Html_url string - Number uint - User User - Original_author string - Original_author_id uint - Title string - Body string - Ref string - Assets []string - Labels []string - Milestone Milestone - Assignee User - Assignees []User - State string - Is_locked bool - Comments uint - Created_at time.Time - Updated_at time.Time - Closed_at time.Time - Due_date time.Time - Pull_request PullRequest - Repository Repository - Pin_order uint + Id uint `json:"id"` + Url string `json:"url"` + Html_url string `json:"html_url"` + Number uint `json:"number"` + User User `json:"user"` + Original_author string `json:"original_author"` + Original_author_id uint `json:"original_author_id"` + Title string `json:"title"` + Body string `json:"body"` + Ref string `json:"ref"` + Assets []string `json:"assets"` + Labels []string `json:"labels"` + Milestone Milestone `json:"milestone"` + Assignee User `json:"assignee"` + Assignees []User `json:"assignees"` + State string `json:"state"` + Is_locked bool `json:"is_locked"` + Comments uint `json:"comments"` + Created_at time.Time `json:"created_at"` + Updated_at time.Time `json:"updated_at"` + Closed_at time.Time `json:"closed_at"` + Due_date time.Time `json:"due_date"` + Pull_request PullRequest `json:"pull_request"` + Repository Repository `json:"repository"` + Pin_order uint `json:"pin_order"` } func (gitea *Gitea) GetIssues(repo Repository) ([]Issue, error) { diff --git a/internal/gitea/milestone.go b/internal/gitea/milestone.go index 96c5f89..87a024b 100644 --- a/internal/gitea/milestone.go +++ b/internal/gitea/milestone.go @@ -9,16 +9,16 @@ import ( ) type Milestone struct { - Id uint - Title string - Description string - State string - Open_issues uint - Closed_issues uint - Created_at time.Time - Updated_at time.Time - Due_on time.Time - Closed_at time.Time + Id uint `json:"id"` + Title string `json:"title"` + Description string `json:"description"` + State string `json:"state"` + Open_issues uint `json:"open_issues"` + Closed_issues uint `json:"closed_issues"` + Created_at time.Time `json:"created_at"` + Updated_at time.Time `json:"updated_at"` + Due_on time.Time `json:"due_on"` + Closed_at time.Time `json:"closed_at"` } func (gitea *Gitea) GetMilestones(repo Repository) ([]Milestone, error) { diff --git a/internal/gitea/repository.go b/internal/gitea/repository.go index 32dc2f1..aee2a58 100644 --- a/internal/gitea/repository.go +++ b/internal/gitea/repository.go @@ -7,10 +7,10 @@ import ( ) type Repository struct { - Id uint - Name string - Owner string - Full_name string + Id uint `json:"id"` + Name string `json:"name"` + Owner string `json:"owner"` + Full_name string `json:"full_name"` } func NewRepository(name, owner string) (repo Repository) { diff --git a/internal/gitea/user.go b/internal/gitea/user.go index 1265ee8..bab1a70 100644 --- a/internal/gitea/user.go +++ b/internal/gitea/user.go @@ -3,25 +3,25 @@ package gitea import "time" type User struct { - Id uint - Login string - Login_name string - Full_name string - Email string - Avatar_url string - Language string - Is_admin bool - Last_login time.Time - Created time.Time - Restricted bool - Active bool - Prohibit_login bool - Location string - Website string - Description string - Visibility string - Followers_count uint - Following_count uint - Starred_repos_count uint - Username string + Id uint `json:"id"` + Login string `json:"login"` + Login_name string `json:"login_name"` + Full_name string `json:"full_name"` + Email string `json:"email"` + Avatar_url string `json:"avatar_url"` + Language string `json:"language"` + Is_admin bool `json:"is_admin"` + Last_login time.Time `json:"last_login"` + Created time.Time `json:"created"` + Restricted bool `json:"restricted"` + Active bool `json:"active"` + Prohibit_login bool `json:"prohibit_login"` + Location string `json:"location"` + Website string `json:"website"` + Description string `json:"description"` + Visibility string `json:"visibility"` + Followers_count uint `json:"followers_count"` + Following_count uint `json:"following_count"` + Starred_repos_count uint `json:"starred_repos_count"` + Username string `json:"username"` }