From ee797599fd6c0d023c760afbf62e9b673ac131cb Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Sat, 23 Sep 2023 11:12:13 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20time=20parsing=20in=20gith?= =?UTF-8?q?ub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The child object might be non-pointers, but their parents are all pointers now. Correctly handle nil-values. Signed-off-by: Dominik Richter --- providers/github/resources/github_org.go | 18 ++++++++--------- providers/github/resources/github_repo.go | 24 +++++++++++------------ providers/github/resources/github_user.go | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/providers/github/resources/github_org.go b/providers/github/resources/github_org.go index 885563caef..c4c6409fcd 100644 --- a/providers/github/resources/github_org.go +++ b/providers/github/resources/github_org.go @@ -56,8 +56,8 @@ func initGithubOrganization(runtime *plugin.Runtime, args map[string]*llx.RawDat args["followers"] = llx.IntData(convert.ToInt64FromInt(org.Followers)) args["following"] = llx.IntData(convert.ToInt64FromInt(org.Following)) args["description"] = llx.StringDataPtr(org.Description) - args["createdAt"] = llx.TimeData(org.CreatedAt.Time) - args["updatedAt"] = llx.TimeData(org.UpdatedAt.Time) + args["createdAt"] = llx.TimeDataPtr(githubTimestamp(org.CreatedAt)) + args["updatedAt"] = llx.TimeDataPtr(githubTimestamp(org.UpdatedAt)) args["totalPrivateRepos"] = llx.IntDataPtr(org.TotalPrivateRepos) args["ownedPrivateRepos"] = llx.IntDataPtr(org.OwnedPrivateRepos) args["privateGists"] = llx.IntData(convert.ToInt64FromInt(org.PrivateGists)) @@ -176,9 +176,9 @@ func (g *mqlGithubOrganization) owners() ([]interface{}, error) { "following": llx.IntData(int64(member.GetFollowing())), "twitterUsername": llx.StringData(member.GetTwitterUsername()), "bio": llx.StringDataPtr(member.Bio), - "createdAt": llx.TimeData(member.CreatedAt.Time), - "updatedAt": llx.TimeData(member.UpdatedAt.Time), - "suspendedAt": llx.TimeData(member.SuspendedAt.Time), + "createdAt": llx.TimeDataPtr(githubTimestamp(member.CreatedAt)), + "updatedAt": llx.TimeDataPtr(githubTimestamp(member.UpdatedAt)), + "suspendedAt": llx.TimeDataPtr(githubTimestamp(member.SuspendedAt)), "company": llx.StringDataPtr(member.Company), }) if err != nil { @@ -385,8 +385,8 @@ func (g *mqlGithubOrganization) packages() ([]interface{}, error) { "name": llx.StringDataPtr(p.Name), "packageType": llx.StringDataPtr(p.PackageType), "owner": llx.ResourceData(owner, owner.MqlName()), - "createdAt": llx.TimeData(p.CreatedAt.Time), - "updatedAt": llx.TimeData(p.UpdatedAt.Time), + "createdAt": llx.TimeDataPtr(githubTimestamp(p.CreatedAt)), + "updatedAt": llx.TimeDataPtr(githubTimestamp(p.UpdatedAt)), "versionCount": llx.IntDataPtr(p.VersionCount), "visibility": llx.StringDataPtr(p.Visibility), }) @@ -473,8 +473,8 @@ func (g *mqlGithubOrganization) installations() ([]interface{}, error) { "id": llx.IntData(id), "appId": llx.IntDataPtr(app.AppID), "appSlug": llx.StringDataPtr(app.AppSlug), - "createdAt": llx.TimeData(app.CreatedAt.Time), - "updatedAt": llx.TimeData(app.UpdatedAt.Time), + "createdAt": llx.TimeDataPtr(githubTimestamp(app.CreatedAt)), + "updatedAt": llx.TimeDataPtr(githubTimestamp(app.UpdatedAt)), }) if err != nil { return nil, err diff --git a/providers/github/resources/github_repo.go b/providers/github/resources/github_repo.go index 1645dcbfe9..333dc3a876 100644 --- a/providers/github/resources/github_repo.go +++ b/providers/github/resources/github_repo.go @@ -40,9 +40,9 @@ func newMqlGithubRepository(runtime *plugin.Runtime, repo *github.Repository) (* "homepage": llx.StringDataPtr(repo.Homepage), "topics": llx.ArrayData(convert.SliceAnyToInterface[string](repo.Topics), types.String), "language": llx.StringData(repo.GetLanguage()), - "createdAt": llx.TimeData(repo.CreatedAt.Time), - "updatedAt": llx.TimeData(repo.UpdatedAt.Time), - "pushedAt": llx.TimeData(repo.PushedAt.Time), + "createdAt": llx.TimeDataPtr(githubTimestamp(repo.CreatedAt)), + "updatedAt": llx.TimeDataPtr(githubTimestamp(repo.UpdatedAt)), + "pushedAt": llx.TimeDataPtr(githubTimestamp(repo.PushedAt)), "archived": llx.BoolDataPtr(repo.Archived), "disabled": llx.BoolDataPtr(repo.Disabled), "private": llx.BoolDataPtr(repo.Private), @@ -188,9 +188,9 @@ func initGithubRepository(runtime *plugin.Runtime, args map[string]*llx.RawData) args["forksCount"] = llx.IntData(int64(repo.GetForksCount())) args["openIssuesCount"] = llx.IntData(int64(repo.GetOpenIssues())) args["stargazersCount"] = llx.IntData(int64(repo.GetStargazersCount())) - args["createdAt"] = llx.TimeData(repo.CreatedAt.Time) - args["updatedAt"] = llx.TimeData(repo.UpdatedAt.Time) - args["pushedAt"] = llx.TimeData(repo.PushedAt.Time) + args["createdAt"] = llx.TimeDataPtr(githubTimestamp(repo.CreatedAt)) + args["updatedAt"] = llx.TimeDataPtr(githubTimestamp(repo.UpdatedAt)) + args["pushedAt"] = llx.TimeDataPtr(githubTimestamp(repo.PushedAt)) args["archived"] = llx.BoolDataPtr(repo.Archived) args["disabled"] = llx.BoolDataPtr(repo.Disabled) args["private"] = llx.BoolDataPtr(repo.Private) @@ -331,7 +331,7 @@ func (g *mqlGithubRepository) openMergeRequests() ([]interface{}, error) { "number": llx.IntData(int64(*pr.Number)), "state": llx.StringDataPtr(pr.State), "labels": llx.ArrayData(labels, types.Any), - "createdAt": llx.TimeData(pr.CreatedAt.Time), + "createdAt": llx.TimeDataPtr(githubTimestamp(pr.CreatedAt)), "title": llx.StringDataPtr(pr.Title), "owner": llx.ResourceData(owner, owner.MqlName()), "assignees": llx.ArrayData(assigneesRes, types.Any), @@ -1069,8 +1069,8 @@ func (g *mqlGithubRepository) workflows() ([]interface{}, error) { "name": llx.StringDataPtr(w.Name), "path": llx.StringDataPtr(w.Path), "state": llx.StringDataPtr(w.State), - "createdAt": llx.TimeData(w.CreatedAt.Time), - "updatedAt": llx.TimeData(w.UpdatedAt.Time), + "createdAt": llx.TimeDataPtr(githubTimestamp(w.CreatedAt)), + "updatedAt": llx.TimeDataPtr(githubTimestamp(w.UpdatedAt)), }) if err != nil { return nil, err @@ -1475,9 +1475,9 @@ func (g *mqlGithubRepository) getIssues(state string) ([]interface{}, error) { "state": llx.StringData(issue.GetState()), "body": llx.StringData(issue.GetBody()), "url": llx.StringData(issue.GetURL()), - "createdAt": llx.TimeData(issue.CreatedAt.Time), - "updatedAt": llx.TimeData(issue.UpdatedAt.Time), - "closedAt": llx.TimeData(issue.ClosedAt.Time), + "createdAt": llx.TimeDataPtr(githubTimestamp(issue.CreatedAt)), + "updatedAt": llx.TimeDataPtr(githubTimestamp(issue.UpdatedAt)), + "closedAt": llx.TimeDataPtr(githubTimestamp(issue.ClosedAt)), "assignees": llx.ArrayData(assignees, types.Any), "closedBy": llx.AnyData(closedBy), }) diff --git a/providers/github/resources/github_user.go b/providers/github/resources/github_user.go index e8fb577863..adc82aa970 100644 --- a/providers/github/resources/github_user.go +++ b/providers/github/resources/github_user.go @@ -191,8 +191,8 @@ func (g *mqlGithubUser) gists() ([]interface{}, error) { r, err := CreateResource(g.MqlRuntime, "github.gist", map[string]*llx.RawData{ "id": llx.StringDataPtr(gist.ID), "description": llx.StringDataPtr(gist.Description), - "createdAt": llx.TimeData(gist.CreatedAt.Time), - "updatedAt": llx.TimeData(gist.UpdatedAt.Time), + "createdAt": llx.TimeDataPtr(githubTimestamp(gist.CreatedAt)), + "updatedAt": llx.TimeDataPtr(githubTimestamp(gist.UpdatedAt)), "public": llx.BoolDataPtr(gist.Public), "owner": llx.ResourceData(g, g.MqlName()), "files": llx.ArrayData(files, types.Any),