From 7fbdfb0d0840bc4a6af4f75fd3f92f87cc7ac1fa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Dec 2024 16:21:51 +0330 Subject: [PATCH] fix: updated models --- provider/describer/action_artifact.go | 29 +- .../describer/action_repository_runner.go | 24 +- .../describer/action_repository_secret.go | 28 +- provider/describer/action_workflow_run.go | 45 +- provider/describer/audit_log.go | 33 +- provider/describer/branch.go | 360 ++++++++++-- provider/describer/branch_protection.go | 63 +- provider/describer/commit.go | 118 +++- provider/describer/issue.go | 437 ++++++++++++-- provider/model/model.go | 550 ++++++++++++++---- 10 files changed, 1370 insertions(+), 317 deletions(-) diff --git a/provider/describer/action_artifact.go b/provider/describer/action_artifact.go index 4f52d4b8..a71450a4 100644 --- a/provider/describer/action_artifact.go +++ b/provider/describer/action_artifact.go @@ -6,6 +6,7 @@ import ( "github.com/opengovern/og-describer-github/pkg/sdk/models" "github.com/opengovern/og-describer-github/provider/model" "strconv" + "time" ) func GetAllArtifacts(ctx context.Context, githubClient GitHubClient, organizationName string, stream *models.StreamSender) ([]models.Resource, error) { @@ -37,20 +38,22 @@ func GetRepositoryArtifacts(ctx context.Context, githubClient GitHubClient, stre return nil, err } for _, artifact := range artifacts.Artifacts { + createdAt := artifact.GetCreatedAt().Format(time.RFC3339) + expiresAt := artifact.GetExpiresAt().Format(time.RFC3339) value := models.Resource{ ID: strconv.Itoa(int(artifact.GetID())), Name: artifact.GetName(), Description: JSONAllFieldsMarshaller{ Value: model.ArtifactDescription{ ID: artifact.GetID(), - NodeID: artifact.GetNodeID(), - Name: artifact.GetName(), + NodeID: artifact.NodeID, + Name: artifact.Name, SizeInBytes: artifact.GetSizeInBytes(), - ArchiveDownloadURL: artifact.GetArchiveDownloadURL(), + ArchiveDownloadURL: artifact.ArchiveDownloadURL, Expired: artifact.GetExpired(), - CreatedAt: artifact.GetCreatedAt(), - ExpiresAt: artifact.GetExpiresAt(), - RepoFullName: repoFullName, + CreatedAt: &createdAt, + ExpiresAt: &expiresAt, + RepoFullName: &repoFullName, }, }, } @@ -81,20 +84,22 @@ func GetArtifact(ctx context.Context, githubClient GitHubClient, organizationNam if err != nil { return nil, err } + createdAt := artifact.GetCreatedAt().Format(time.RFC3339) + expiresAt := artifact.GetExpiresAt().Format(time.RFC3339) value := models.Resource{ ID: strconv.Itoa(int(artifact.GetID())), Name: artifact.GetName(), Description: JSONAllFieldsMarshaller{ Value: model.ArtifactDescription{ ID: artifact.GetID(), - NodeID: artifact.GetNodeID(), - Name: artifact.GetName(), + NodeID: artifact.NodeID, + Name: artifact.Name, SizeInBytes: artifact.GetSizeInBytes(), - ArchiveDownloadURL: artifact.GetArchiveDownloadURL(), + ArchiveDownloadURL: artifact.ArchiveDownloadURL, Expired: artifact.GetExpired(), - CreatedAt: artifact.GetCreatedAt(), - ExpiresAt: artifact.GetExpiresAt(), - RepoFullName: repoFullName, + CreatedAt: &createdAt, + ExpiresAt: &expiresAt, + RepoFullName: &repoFullName, }, }, } diff --git a/provider/describer/action_repository_runner.go b/provider/describer/action_repository_runner.go index e4cba876..0bb4949d 100644 --- a/provider/describer/action_repository_runner.go +++ b/provider/describer/action_repository_runner.go @@ -37,6 +37,14 @@ func GetRepositoryRunners(ctx context.Context, githubClient GitHubClient, stream return nil, err } for _, runner := range runners.Runners { + var labels []*model.RunnerLabels + for _, runnerLabel := range runner.Labels { + labels = append(labels, &model.RunnerLabels{ + ID: runnerLabel.ID, + Name: runnerLabel.Name, + Type: runnerLabel.Type, + }) + } value := models.Resource{ ID: strconv.Itoa(int(runner.GetID())), Name: runner.GetName(), @@ -47,8 +55,8 @@ func GetRepositoryRunners(ctx context.Context, githubClient GitHubClient, stream OS: runner.OS, Status: runner.Status, Busy: runner.Busy, - Labels: runner.Labels, - RepoFullName: repoFullName, + Labels: labels, + RepoFullName: &repoFullName, }, }, } @@ -79,6 +87,14 @@ func GetActionRunner(ctx context.Context, githubClient GitHubClient, organizatio if err != nil { return nil, err } + var labels []*model.RunnerLabels + for _, runnerLabel := range runner.Labels { + labels = append(labels, &model.RunnerLabels{ + ID: runnerLabel.ID, + Name: runnerLabel.Name, + Type: runnerLabel.Type, + }) + } value := models.Resource{ ID: strconv.Itoa(int(runner.GetID())), Name: runner.GetName(), @@ -89,8 +105,8 @@ func GetActionRunner(ctx context.Context, githubClient GitHubClient, organizatio OS: runner.OS, Status: runner.Status, Busy: runner.Busy, - Labels: runner.Labels, - RepoFullName: repoFullName, + Labels: labels, + RepoFullName: &repoFullName, }, }, } diff --git a/provider/describer/action_repository_secret.go b/provider/describer/action_repository_secret.go index 157f474c..fff8e973 100644 --- a/provider/describer/action_repository_secret.go +++ b/provider/describer/action_repository_secret.go @@ -39,17 +39,19 @@ func GetRepositorySecrets(ctx context.Context, githubClient GitHubClient, stream } for _, secret := range secrets.Secrets { id := fmt.Sprintf("%s/%s/%s", owner, repo, secret.Name) + createdAt := secret.CreatedAt.Format(time.RFC3339) + updatedAt := secret.UpdatedAt.Format(time.RFC3339) value := models.Resource{ ID: id, Name: secret.Name, Description: JSONAllFieldsMarshaller{ Value: model.SecretDescription{ - Name: secret.Name, - CreatedAt: secret.CreatedAt.Format(time.RFC3339), - UpdatedAt: secret.UpdatedAt.Format(time.RFC3339), - Visibility: secret.Visibility, - SelectedRepositoriesURL: secret.SelectedRepositoriesURL, - RepoFullName: repoFullName, + Name: &secret.Name, + CreatedAt: &createdAt, + UpdatedAt: &updatedAt, + Visibility: &secret.Visibility, + SelectedRepositoriesURL: &secret.SelectedRepositoriesURL, + RepoFullName: &repoFullName, }, }, } @@ -77,17 +79,19 @@ func GetRepoActionSecret(ctx context.Context, githubClient GitHubClient, organiz return nil, err } id := fmt.Sprintf("%s/%s/%s", organizationName, repositoryName, secret.Name) + createdAt := secret.CreatedAt.Format(time.RFC3339) + updatedAt := secret.UpdatedAt.Format(time.RFC3339) value := models.Resource{ ID: id, Name: secret.Name, Description: JSONAllFieldsMarshaller{ Value: model.SecretDescription{ - Name: secret.Name, - CreatedAt: secret.CreatedAt.Format(time.RFC3339), - UpdatedAt: secret.UpdatedAt.Format(time.RFC3339), - Visibility: secret.Visibility, - SelectedRepositoriesURL: secret.SelectedRepositoriesURL, - RepoFullName: repoFullName, + Name: &secret.Name, + CreatedAt: &createdAt, + UpdatedAt: &updatedAt, + Visibility: &secret.Visibility, + SelectedRepositoriesURL: &secret.SelectedRepositoriesURL, + RepoFullName: &repoFullName, }, }, } diff --git a/provider/describer/action_workflow_run.go b/provider/describer/action_workflow_run.go index 24ceabf2..0a35d273 100644 --- a/provider/describer/action_workflow_run.go +++ b/provider/describer/action_workflow_run.go @@ -183,10 +183,14 @@ func GetRepositoryWorkflowRuns(ctx context.Context, sdk *resilientbridge.Resilie } runDetail.ArtifactCount = artifactCount runDetail.Artifacts = artifacts + var name string + if runDetail.Name != nil { + name = *runDetail.Name + } value := models.Resource{ ID: strconv.Itoa(runDetail.ID), - Name: runDetail.Name, + Name: name, Description: JSONAllFieldsMarshaller{ Value: runDetail, }, @@ -441,19 +445,19 @@ func fetchRunDetails(sdk *resilientbridge.ResilientBridge, owner, repo string, r return model.WorkflowRunDescription{ ID: fullDetail.ID, - Name: fullDetail.Name, - HeadBranch: fullDetail.HeadBranch, - HeadSHA: fullDetail.HeadSHA, - Status: fullDetail.Status, - Conclusion: fullDetail.Conclusion, - HTMLURL: fullDetail.HTMLURL, + Name: &fullDetail.Name, + HeadBranch: &fullDetail.HeadBranch, + HeadSHA: &fullDetail.HeadSHA, + Status: &fullDetail.Status, + Conclusion: &fullDetail.Conclusion, + HTMLURL: &fullDetail.HTMLURL, WorkflowID: fullDetail.WorkflowID, RunNumber: fullDetail.RunNumber, - Event: fullDetail.Event, - CreatedAt: fullDetail.CreatedAt, - UpdatedAt: fullDetail.UpdatedAt, + Event: &fullDetail.Event, + CreatedAt: &fullDetail.CreatedAt, + UpdatedAt: &fullDetail.UpdatedAt, RunAttempt: fullDetail.RunAttempt, - RunStartedAt: fullDetail.RunStartedAt, + RunStartedAt: &fullDetail.RunStartedAt, Actor: fullDetail.Actor, HeadCommit: fullDetail.HeadCommit, Repository: fullDetail.Repository, @@ -484,5 +488,22 @@ func fetchArtifactsForRun(sdk *resilientbridge.ResilientBridge, owner, repo stri return 0, nil, fmt.Errorf("error decoding artifacts response: %w", err) } - return artResp.TotalCount, artResp.Artifacts, nil + var artifacts []model.WorkflowArtifact + + for _, artifact := range artResp.Artifacts { + artifacts = append(artifacts, model.WorkflowArtifact{ + ID: artifact.ID, + NodeID: &artifact.NodeID, + Name: &artifact.Name, + SizeInBytes: artifact.SizeInBytes, + URL: &artifact.URL, + ArchiveDownloadURL: &artifact.ArchiveDownloadURL, + Expired: artifact.Expired, + CreatedAt: &artifact.CreatedAt, + UpdatedAt: &artifact.UpdatedAt, + ExpiresAt: &artifact.ExpiresAt, + }) + } + + return artResp.TotalCount, artifacts, nil } diff --git a/provider/describer/audit_log.go b/provider/describer/audit_log.go index aa0f0dba..34405237 100644 --- a/provider/describer/audit_log.go +++ b/provider/describer/audit_log.go @@ -5,6 +5,7 @@ import ( "github.com/google/go-github/v55/github" "github.com/opengovern/og-describer-github/pkg/sdk/models" "github.com/opengovern/og-describer-github/provider/model" + "time" ) func GetAllAuditLogs(ctx context.Context, githubClient GitHubClient, organizationName string, stream *models.StreamSender) ([]models.Resource, error) { @@ -33,23 +34,31 @@ func GetRepositoryAuditLog(ctx context.Context, githubClient GitHubClient, strea return nil, err } for _, audit := range auditResults { + createdAt := audit.CreatedAt.Format(time.RFC3339) + actorLocation := model.ActorLocation{ + CountryCode: audit.ActorLocation.CountryCode, + } + data := model.AuditEntryData{ + OldName: audit.Data.OldName, + OldLogin: audit.Data.OldLogin, + } value := models.Resource{ ID: audit.GetDocumentID(), Name: audit.GetName(), Description: JSONAllFieldsMarshaller{ Value: model.AuditLogDescription{ - ID: audit.GetDocumentID(), - CreatedAt: audit.GetCreatedAt(), - Organization: org, - Phrase: phrase, - Include: include, - Action: audit.GetAction(), - Actor: audit.GetActor(), - ActorLocation: audit.GetActorLocation(), - Team: audit.GetTeam(), - UserLogin: audit.GetUser(), - Repo: audit.GetRepository(), - Data: audit.GetData(), + ID: audit.DocumentID, + CreatedAt: &createdAt, + Organization: &org, + Phrase: &phrase, + Include: &include, + Action: audit.Action, + Actor: audit.Actor, + ActorLocation: &actorLocation, + Team: audit.Team, + UserLogin: audit.User, + Repo: audit.Repository, + Data: &data, }, }, } diff --git a/provider/describer/branch.go b/provider/describer/branch.go index b403e907..b1abe957 100644 --- a/provider/describer/branch.go +++ b/provider/describer/branch.go @@ -7,6 +7,7 @@ import ( "github.com/opengovern/og-describer-github/provider/model" "github.com/shurcooL/githubv4" steampipemodels "github.com/turbot/steampipe-plugin-github/github/models" + "time" ) func GetAllBranches(ctx context.Context, githubClient GitHubClient, organizationName string, stream *models.StreamSender) ([]models.Resource, error) { @@ -63,15 +64,133 @@ func GetRepositoryBranches(ctx context.Context, githubClient GitHubClient, strea } protected := branchInfo.GetProtected() id := fmt.Sprintf("%s/%s/%s", owner, repo, branch.Node.Name) + + authoredDate := branch.Node.Target.Commit.AuthoredDate.Format(time.RFC3339) + authorDate := branch.Node.Target.Commit.Author.Date.Format(time.RFC3339) + authorUserCreatedAt := branch.Node.Target.Commit.Author.User.CreatedAt.Format(time.RFC3339) + authorUserUpdatedAt := branch.Node.Target.Commit.Author.User.UpdatedAt.Format(time.RFC3339) + commiterUserCreatedAt := branch.Node.Target.Commit.Committer.User.CreatedAt.Format(time.RFC3339) + commiterUserUpdatedAt := branch.Node.Target.Commit.Committer.User.UpdatedAt.Format(time.RFC3339) + committedDate := branch.Node.Target.Commit.CommittedDate.Format(time.RFC3339) + commiterDate := branch.Node.Target.Commit.Committer.Date.Format(time.RFC3339) + + authorUser := model.BasicUser{ + Id: branch.Node.Target.Commit.Author.User.Id, + NodeId: &branch.Node.Target.Commit.Author.User.NodeId, + Name: &branch.Node.Target.Commit.Author.User.Name, + Login: &branch.Node.Target.Commit.Author.User.Login, + Email: &branch.Node.Target.Commit.Author.User.Email, + CreatedAt: &authorUserCreatedAt, + UpdatedAt: &authorUserUpdatedAt, + Url: &branch.Node.Target.Commit.Author.User.Url, + } + + commiterUser := model.BasicUser{ + Id: branch.Node.Target.Commit.Committer.User.Id, + NodeId: &branch.Node.Target.Commit.Committer.User.NodeId, + Name: &branch.Node.Target.Commit.Committer.User.Name, + Login: &branch.Node.Target.Commit.Committer.User.Login, + Email: &branch.Node.Target.Commit.Committer.User.Email, + CreatedAt: &commiterUserCreatedAt, + UpdatedAt: &commiterUserUpdatedAt, + Url: &branch.Node.Target.Commit.Committer.User.Url, + } + + author := model.GitActor{ + AvatarUrl: &branch.Node.Target.Commit.Author.AvatarUrl, + Date: &authorDate, + Email: &branch.Node.Target.Commit.Author.Email, + Name: &branch.Node.Target.Commit.Author.Name, + User: authorUser, + } + + commiter := model.GitActor{ + AvatarUrl: &branch.Node.Target.Commit.Committer.AvatarUrl, + Date: &commiterDate, + Email: &branch.Node.Target.Commit.Committer.Email, + Name: &branch.Node.Target.Commit.Committer.Name, + User: commiterUser, + } + + signature := model.Signature{ + Email: &branch.Node.Target.Commit.Signature.Email, + IsValid: branch.Node.Target.Commit.Signature.IsValid, + State: &branch.Node.Target.Commit.Signature.State, + WasSignedByGitHub: branch.Node.Target.Commit.Signature.WasSignedByGitHub, + Signer: struct { + Email *string + Login *string + }{Email: &branch.Node.Target.Commit.Signature.Signer.Email, Login: &branch.Node.Target.Commit.Signature.Signer.Login}, + } + + status := model.CommitStatus{ + State: &branch.Node.Target.Commit.Status.State, + } + + commit := model.BaseCommit{ + Sha: &branch.Node.Target.Commit.Sha, + ShortSha: &branch.Node.Target.Commit.ShortSha, + AuthoredDate: &authoredDate, + Author: author, + CommittedDate: &committedDate, + Committer: commiter, + Message: &branch.Node.Target.Commit.Message, + Url: &branch.Node.Target.Commit.Url, + Additions: branch.Node.Target.Commit.Additions, + AuthoredByCommitter: branch.Node.Target.Commit.AuthoredByCommitter, + ChangedFiles: branch.Node.Target.Commit.ChangedFiles, + CommittedViaWeb: branch.Node.Target.Commit.CommittedViaWeb, + CommitUrl: &branch.Node.Target.Commit.CommitUrl, + Deletions: branch.Node.Target.Commit.Deletions, + Signature: signature, + TarballUrl: &branch.Node.Target.Commit.TarballUrl, + TreeUrl: &branch.Node.Target.Commit.TreeUrl, + CanSubscribe: branch.Node.Target.Commit.CanSubscribe, + Subscription: &branch.Node.Target.Commit.Subscription, + ZipballUrl: &branch.Node.Target.Commit.ZipballUrl, + MessageHeadline: &branch.Node.Target.Commit.MessageHeadline, + Status: status, + NodeId: &branch.Node.Target.Commit.NodeId, + } + + branchProtctionRule := model.BranchProtectionRule{ + AllowsDeletions: branch.Node.BranchProtectionRule.AllowsDeletions, + AllowsForcePushes: branch.Node.BranchProtectionRule.AllowsForcePushes, + BlocksCreations: branch.Node.BranchProtectionRule.BlocksCreations, + CreatorLogin: &branch.Node.BranchProtectionRule.Creator.Login, + Id: branch.Node.BranchProtectionRule.Id, + NodeId: &branch.Node.BranchProtectionRule.NodeId, + DismissesStaleReviews: branch.Node.BranchProtectionRule.DismissesStaleReviews, + IsAdminEnforced: branch.Node.BranchProtectionRule.IsAdminEnforced, + LockAllowsFetchAndMerge: branch.Node.BranchProtectionRule.LockAllowsFetchAndMerge, + LockBranch: branch.Node.BranchProtectionRule.LockBranch, + Pattern: &branch.Node.BranchProtectionRule.Pattern, + RequireLastPushApproval: branch.Node.BranchProtectionRule.RequireLastPushApproval, + RequiredApprovingReviewCount: branch.Node.BranchProtectionRule.RequiredApprovingReviewCount, + RequiredDeploymentEnvironments: branch.Node.BranchProtectionRule.RequiredDeploymentEnvironments, + RequiredStatusChecks: branch.Node.BranchProtectionRule.RequiredStatusChecks, + RequiresApprovingReviews: branch.Node.BranchProtectionRule.RequiresApprovingReviews, + RequiresConversationResolution: branch.Node.BranchProtectionRule.RequiresConversationResolution, + RequiresCodeOwnerReviews: branch.Node.BranchProtectionRule.RequiresCodeOwnerReviews, + RequiresCommitSignatures: branch.Node.BranchProtectionRule.RequiresCommitSignatures, + RequiresDeployments: branch.Node.BranchProtectionRule.RequiresDeployments, + RequiresLinearHistory: branch.Node.BranchProtectionRule.RequiresLinearHistory, + RequiresStatusChecks: branch.Node.BranchProtectionRule.RequiresStatusChecks, + RequiresStrictStatusChecks: branch.Node.BranchProtectionRule.RequiresStrictStatusChecks, + RestrictsPushes: branch.Node.BranchProtectionRule.RestrictsPushes, + RestrictsReviewDismissals: branch.Node.BranchProtectionRule.RestrictsReviewDismissals, + MatchingBranches: branch.Node.BranchProtectionRule.MatchingBranches.TotalCount, + } + value := models.Resource{ ID: id, Name: branch.Node.Name, Description: JSONAllFieldsMarshaller{ Value: model.BranchDescription{ - Name: branch.Node.Name, - Commit: branch.Node.Target.Commit, - BranchProtectionRule: branch.Node.BranchProtectionRule, - RepoFullName: repoFullName, + Name: &branch.Node.Name, + Commit: commit, + BranchProtectionRule: branchProtctionRule, + RepoFullName: &repoFullName, Protected: protected, }, }, @@ -92,60 +211,179 @@ func GetRepositoryBranches(ctx context.Context, githubClient GitHubClient, strea return values, nil } -func GetRepositoryBranch(ctx context.Context, githubClient GitHubClient, organizationName string, repositoryName string, branchName string, stream *models.StreamSender) (*models.Resource, error) { - branchInfo, _, err := githubClient.RestClient.Repositories.GetBranch(ctx, organizationName, repositoryName, branchName, true) - if err != nil { - return nil, err - } - repoFullName := formRepositoryFullName(organizationName, repositoryName) - - id := fmt.Sprintf("%s/%s/%s", organizationName, repositoryName, branchInfo.GetName()) - value := models.Resource{ - ID: id, - Name: branchInfo.GetName(), - Description: JSONAllFieldsMarshaller{ - Value: model.BranchDescription{ - Name: branchInfo.GetName(), - Commit: steampipemodels.BaseCommit{ - BasicCommit: steampipemodels.BasicCommit{ - Sha: branchInfo.GetCommit().GetSHA(), - Url: branchInfo.GetCommit().GetURL(), - Author: steampipemodels.GitActor{ - Name: branchInfo.GetCommit().GetAuthor().GetName(), - Email: branchInfo.GetCommit().GetAuthor().GetEmail(), - AvatarUrl: branchInfo.GetCommit().GetAuthor().GetAvatarURL(), - User: steampipemodels.BasicUser{ - Login: branchInfo.GetCommit().GetAuthor().GetLogin(), - Email: branchInfo.GetCommit().GetAuthor().GetEmail(), - Url: branchInfo.GetCommit().GetAuthor().GetURL(), - }, - }, - Message: branchInfo.GetCommit().GetCommit().GetMessage(), - Committer: steampipemodels.GitActor{ - Name: branchInfo.GetCommit().GetCommitter().GetName(), - Email: branchInfo.GetCommit().GetCommitter().GetEmail(), - AvatarUrl: branchInfo.GetCommit().GetCommitter().GetAvatarURL(), - User: steampipemodels.BasicUser{ - Login: branchInfo.GetCommit().GetCommitter().GetLogin(), - Email: branchInfo.GetCommit().GetCommitter().GetEmail(), - Url: branchInfo.GetCommit().GetCommitter().GetURL(), - }, - }, - ShortSha: branchInfo.GetCommit().GetCommit().GetSHA(), - }, - Status: steampipemodels.CommitStatus{ - State: branchInfo.GetCommit().GetStats().String(), - }, - }, - RepoFullName: repoFullName, - Protected: branchInfo.GetProtected(), - }, - }, - } - if stream != nil { - if err := (*stream)(value); err != nil { - return nil, err - } - } - return &value, nil -} +//TODO: Change the get function api call (The resource type model in Get function is different from model in List function) +//func GetRepositoryBranch(ctx context.Context, githubClient GitHubClient, organizationName string, repositoryName string, branchName string, stream *models.StreamSender) (*models.Resource, error) { +// branchInfo, _, err := githubClient.RestClient.Repositories.GetBranch(ctx, organizationName, repositoryName, branchName, true) +// if err != nil { +// return nil, err +// } +// repoFullName := formRepositoryFullName(organizationName, repositoryName) +// +// id := fmt.Sprintf("%s/%s/%s", organizationName, repositoryName, branchInfo.GetName()) +// +// authoredDate := branch.Node.Target.Commit.AuthoredDate.Format(time.RFC3339) +// authorDate := branch.Node.Target.Commit.Author.Date.Format(time.RFC3339) +// authorUserCreatedAt := branch.Node.Target.Commit.Author.User.CreatedAt.Format(time.RFC3339) +// authorUserUpdatedAt := branch.Node.Target.Commit.Author.User.UpdatedAt.Format(time.RFC3339) +// commiterUserCreatedAt := branch.Node.Target.Commit.Committer.User.CreatedAt.Format(time.RFC3339) +// commiterUserUpdatedAt := branch.Node.Target.Commit.Committer.User.UpdatedAt.Format(time.RFC3339) +// committedDate := branch.Node.Target.Commit.CommittedDate.Format(time.RFC3339) +// commiterDate := branch.Node.Target.Commit.Committer.Date.Format(time.RFC3339) +// +// authorUser := model.BasicUser{ +// Id: branch.Node.Target.Commit.Author.User.Id, +// NodeId: &branch.Node.Target.Commit.Author.User.NodeId, +// Name: &branch.Node.Target.Commit.Author.User.Name, +// Login: &branch.Node.Target.Commit.Author.User.Login, +// Email: &branch.Node.Target.Commit.Author.User.Email, +// CreatedAt: &authorUserCreatedAt, +// UpdatedAt: &authorUserUpdatedAt, +// Url: &branch.Node.Target.Commit.Author.User.Url, +// } +// +// commiterUser := model.BasicUser{ +// Id: branch.Node.Target.Commit.Committer.User.Id, +// NodeId: &branch.Node.Target.Commit.Committer.User.NodeId, +// Name: &branch.Node.Target.Commit.Committer.User.Name, +// Login: &branch.Node.Target.Commit.Committer.User.Login, +// Email: &branch.Node.Target.Commit.Committer.User.Email, +// CreatedAt: &commiterUserCreatedAt, +// UpdatedAt: &commiterUserUpdatedAt, +// Url: &branch.Node.Target.Commit.Committer.User.Url, +// } +// +// author := model.GitActor{ +// AvatarUrl: &branch.Node.Target.Commit.Author.AvatarUrl, +// Date: &authorDate, +// Email: &branch.Node.Target.Commit.Author.Email, +// Name: &branch.Node.Target.Commit.Author.Name, +// User: authorUser, +// } +// +// commiter := model.GitActor{ +// AvatarUrl: &branch.Node.Target.Commit.Committer.AvatarUrl, +// Date: &commiterDate, +// Email: &branch.Node.Target.Commit.Committer.Email, +// Name: &branch.Node.Target.Commit.Committer.Name, +// User: commiterUser, +// } +// +// signature := model.Signature{ +// Email: &branch.Node.Target.Commit.Signature.Email, +// IsValid: branch.Node.Target.Commit.Signature.IsValid, +// State: &branch.Node.Target.Commit.Signature.State, +// WasSignedByGitHub: branch.Node.Target.Commit.Signature.WasSignedByGitHub, +// Signer: struct { +// Email *string +// Login *string +// }{Email: &branch.Node.Target.Commit.Signature.Signer.Email, Login: &branch.Node.Target.Commit.Signature.Signer.Login}, +// } +// +// status := model.CommitStatus{ +// State: &branch.Node.Target.Commit.Status.State, +// } +// +// commit := model.BaseCommit{ +// Sha: &branch.Node.Target.Commit.Sha, +// ShortSha: &branch.Node.Target.Commit.ShortSha, +// AuthoredDate: &authoredDate, +// Author: author, +// CommittedDate: &committedDate, +// Committer: commiter, +// Message: &branch.Node.Target.Commit.Message, +// Url: &branch.Node.Target.Commit.Url, +// Additions: branch.Node.Target.Commit.Additions, +// AuthoredByCommitter: branch.Node.Target.Commit.AuthoredByCommitter, +// ChangedFiles: branch.Node.Target.Commit.ChangedFiles, +// CommittedViaWeb: branch.Node.Target.Commit.CommittedViaWeb, +// CommitUrl: &branch.Node.Target.Commit.CommitUrl, +// Deletions: branch.Node.Target.Commit.Deletions, +// Signature: signature, +// TarballUrl: &branch.Node.Target.Commit.TarballUrl, +// TreeUrl: &branch.Node.Target.Commit.TreeUrl, +// CanSubscribe: branch.Node.Target.Commit.CanSubscribe, +// Subscription: &branch.Node.Target.Commit.Subscription, +// ZipballUrl: &branch.Node.Target.Commit.ZipballUrl, +// MessageHeadline: &branch.Node.Target.Commit.MessageHeadline, +// Status: status, +// NodeId: &branch.Node.Target.Commit.NodeId, +// } +// +// branchProtctionRule := model.BranchProtectionRule{ +// AllowsDeletions: branch.Node.BranchProtectionRule.AllowsDeletions, +// AllowsForcePushes: branch.Node.BranchProtectionRule.AllowsForcePushes, +// BlocksCreations: branch.Node.BranchProtectionRule.BlocksCreations, +// CreatorLogin: &branch.Node.BranchProtectionRule.Creator.Login, +// Id: branch.Node.BranchProtectionRule.Id, +// NodeId: &branch.Node.BranchProtectionRule.NodeId, +// DismissesStaleReviews: branch.Node.BranchProtectionRule.DismissesStaleReviews, +// IsAdminEnforced: branch.Node.BranchProtectionRule.IsAdminEnforced, +// LockAllowsFetchAndMerge: branch.Node.BranchProtectionRule.LockAllowsFetchAndMerge, +// LockBranch: branch.Node.BranchProtectionRule.LockBranch, +// Pattern: &branch.Node.BranchProtectionRule.Pattern, +// RequireLastPushApproval: branch.Node.BranchProtectionRule.RequireLastPushApproval, +// RequiredApprovingReviewCount: branch.Node.BranchProtectionRule.RequiredApprovingReviewCount, +// RequiredDeploymentEnvironments: branch.Node.BranchProtectionRule.RequiredDeploymentEnvironments, +// RequiredStatusChecks: branch.Node.BranchProtectionRule.RequiredStatusChecks, +// RequiresApprovingReviews: branch.Node.BranchProtectionRule.RequiresApprovingReviews, +// RequiresConversationResolution: branch.Node.BranchProtectionRule.RequiresConversationResolution, +// RequiresCodeOwnerReviews: branch.Node.BranchProtectionRule.RequiresCodeOwnerReviews, +// RequiresCommitSignatures: branch.Node.BranchProtectionRule.RequiresCommitSignatures, +// RequiresDeployments: branch.Node.BranchProtectionRule.RequiresDeployments, +// RequiresLinearHistory: branch.Node.BranchProtectionRule.RequiresLinearHistory, +// RequiresStatusChecks: branch.Node.BranchProtectionRule.RequiresStatusChecks, +// RequiresStrictStatusChecks: branch.Node.BranchProtectionRule.RequiresStrictStatusChecks, +// RestrictsPushes: branch.Node.BranchProtectionRule.RestrictsPushes, +// RestrictsReviewDismissals: branch.Node.BranchProtectionRule.RestrictsReviewDismissals, +// MatchingBranches: branch.Node.BranchProtectionRule.MatchingBranches.TotalCount, +// } +// +// value := models.Resource{ +// ID: id, +// Name: branchInfo.GetName(), +// Description: JSONAllFieldsMarshaller{ +// Value: model.BranchDescription{ +// Name: branchInfo.Name, +// Commit: steampipemodels.BaseCommit{ +// BasicCommit: steampipemodels.BasicCommit{ +// Sha: branchInfo.GetCommit().GetSHA(), +// Url: branchInfo.GetCommit().GetURL(), +// Author: steampipemodels.GitActor{ +// Name: branchInfo.GetCommit().GetAuthor().GetName(), +// Email: branchInfo.GetCommit().GetAuthor().GetEmail(), +// AvatarUrl: branchInfo.GetCommit().GetAuthor().GetAvatarURL(), +// User: steampipemodels.BasicUser{ +// Login: branchInfo.GetCommit().GetAuthor().GetLogin(), +// Email: branchInfo.GetCommit().GetAuthor().GetEmail(), +// Url: branchInfo.GetCommit().GetAuthor().GetURL(), +// }, +// }, +// Message: branchInfo.GetCommit().GetCommit().GetMessage(), +// Committer: steampipemodels.GitActor{ +// Name: branchInfo.GetCommit().GetCommitter().GetName(), +// Email: branchInfo.GetCommit().GetCommitter().GetEmail(), +// AvatarUrl: branchInfo.GetCommit().GetCommitter().GetAvatarURL(), +// User: steampipemodels.BasicUser{ +// Login: branchInfo.GetCommit().GetCommitter().GetLogin(), +// Email: branchInfo.GetCommit().GetCommitter().GetEmail(), +// Url: branchInfo.GetCommit().GetCommitter().GetURL(), +// }, +// }, +// ShortSha: branchInfo.GetCommit().GetCommit().GetSHA(), +// }, +// Status: steampipemodels.CommitStatus{ +// State: branchInfo.GetCommit().GetStats().String(), +// }, +// }, +// RepoFullName: repoFullName, +// Protected: branchInfo.GetProtected(), +// }, +// }, +// } +// if stream != nil { +// if err := (*stream)(value); err != nil { +// return nil, err +// } +// } +// return &value, nil +//} diff --git a/provider/describer/branch_protection.go b/provider/describer/branch_protection.go index 060a60e6..8755ee2b 100644 --- a/provider/describer/branch_protection.go +++ b/provider/describer/branch_protection.go @@ -83,19 +83,55 @@ func GetRepositoryBranchProtections(ctx context.Context, githubClient GitHubClie } } for _, node := range rule.PushAllowances.Nodes { - pushAllowanceApps = append(pushAllowanceApps, node.Actor.App) - pushAllowanceTeams = append(pushAllowanceTeams, node.Actor.Team) - pushAllowanceUsers = append(pushAllowanceUsers, node.Actor.User) + app := model.BranchApp{ + Name: &node.Actor.App.Name, + Slug: &node.Actor.App.Slug, + } + team := model.BranchTeam{ + Name: &node.Actor.Team.Name, + Slug: &node.Actor.Team.Slug, + } + user := model.BranchUser{ + Name: &node.Actor.User.Name, + Login: &node.Actor.User.Login, + } + pushAllowanceApps = append(pushAllowanceApps, app) + pushAllowanceTeams = append(pushAllowanceTeams, team) + pushAllowanceUsers = append(pushAllowanceUsers, user) } for _, node := range rule.BypassForcePushAllowances.Nodes { - bypassForcePushAllowanceApps = append(bypassForcePushAllowanceApps, node.Actor.App) - bypassForcePushAllowanceTeams = append(bypassForcePushAllowanceTeams, node.Actor.Team) - bypassForcePushAllowanceUsers = append(bypassForcePushAllowanceUsers, node.Actor.User) + app := model.BranchApp{ + Name: &node.Actor.App.Name, + Slug: &node.Actor.App.Slug, + } + team := model.BranchTeam{ + Name: &node.Actor.Team.Name, + Slug: &node.Actor.Team.Slug, + } + user := model.BranchUser{ + Name: &node.Actor.User.Name, + Login: &node.Actor.User.Login, + } + bypassForcePushAllowanceApps = append(bypassForcePushAllowanceApps, app) + bypassForcePushAllowanceTeams = append(bypassForcePushAllowanceTeams, team) + bypassForcePushAllowanceUsers = append(bypassForcePushAllowanceUsers, user) } for _, node := range rule.BypassForcePushAllowances.Nodes { - bypassPullRequestAllowanceApps = append(bypassPullRequestAllowanceApps, node.Actor.App) - bypassPullRequestAllowanceTeams = append(bypassPullRequestAllowanceTeams, node.Actor.Team) - bypassPullRequestAllowanceUsers = append(bypassPullRequestAllowanceUsers, node.Actor.User) + app := model.BranchApp{ + Name: &node.Actor.App.Name, + Slug: &node.Actor.App.Slug, + } + team := model.BranchTeam{ + Name: &node.Actor.Team.Name, + Slug: &node.Actor.Team.Slug, + } + user := model.BranchUser{ + Name: &node.Actor.User.Name, + Login: &node.Actor.User.Login, + } + bypassPullRequestAllowanceApps = append(bypassPullRequestAllowanceApps, app) + bypassPullRequestAllowanceTeams = append(bypassPullRequestAllowanceTeams, team) + bypassPullRequestAllowanceUsers = append(bypassPullRequestAllowanceUsers, user) } value := models.Resource{ ID: strconv.Itoa(rule.Id), @@ -105,14 +141,13 @@ func GetRepositoryBranchProtections(ctx context.Context, githubClient GitHubClie AllowsDeletions: rule.AllowsDeletions, AllowsForcePushes: rule.AllowsForcePushes, BlocksCreations: rule.BlocksCreations, - Creator: rule.Creator, Id: rule.Id, - NodeId: rule.NodeId, + NodeId: &rule.NodeId, DismissesStaleReviews: rule.DismissesStaleReviews, IsAdminEnforced: rule.IsAdminEnforced, LockAllowsFetchAndMerge: rule.LockAllowsFetchAndMerge, LockBranch: rule.LockBranch, - Pattern: rule.Pattern, + Pattern: &rule.Pattern, RequireLastPushApproval: rule.RequireLastPushApproval, RequiredApprovingReviewCount: rule.RequiredApprovingReviewCount, RequiredDeploymentEnvironments: rule.RequiredDeploymentEnvironments, @@ -127,8 +162,8 @@ func GetRepositoryBranchProtections(ctx context.Context, githubClient GitHubClie RequiresStrictStatusChecks: rule.RequiresStrictStatusChecks, RestrictsPushes: rule.RestrictsPushes, RestrictsReviewDismissals: rule.RestrictsReviewDismissals, - RepoFullName: repoFullName, - CreatorLogin: rule.Creator.Login, + RepoFullName: &repoFullName, + CreatorLogin: &rule.Creator.Login, MatchingBranches: rule.MatchingBranches.TotalCount, PushAllowanceApps: pushAllowanceApps, PushAllowanceTeams: pushAllowanceTeams, diff --git a/provider/describer/commit.go b/provider/describer/commit.go index 135b6c1c..6c838631 100644 --- a/provider/describer/commit.go +++ b/provider/describer/commit.go @@ -95,22 +95,118 @@ func GetRepositoryCommits(ctx context.Context, sdk *resilientbridge.ResilientBri log.Printf("Error unmarshaling JSON for commit %s: %v", j.sha, err) continue } + + tree := model.Tree{ + SHA: &commit.CommitDetail.Tree.SHA, + URL: &commit.CommitDetail.Tree.URL, + } + + verification := model.Verification{ + Verified: commit.CommitDetail.Verification.Verified, + Reason: &commit.CommitDetail.Verification.Reason, + Signature: commit.CommitDetail.Verification.Signature, + Payload: commit.CommitDetail.Verification.Payload, + VerifiedAt: commit.CommitDetail.Verification.VerifiedAt, + } + + commitDetail := model.CommitDetail{ + Message: &commit.CommitDetail.Message, + Tree: tree, + CommentCount: commit.CommitDetail.CommentCount, + Verification: verification, + } + + author := model.User{ + Login: &commit.Author.Login, + ID: commit.Author.ID, + NodeID: &commit.Author.NodeID, + AvatarURL: &commit.Author.AvatarURL, + GravatarID: &commit.Author.GravatarID, + URL: &commit.Author.URL, + HTMLURL: &commit.Author.HTMLURL, + FollowersURL: &commit.Author.FollowersURL, + FollowingURL: &commit.Author.FollowingURL, + GistsURL: &commit.Author.GistsURL, + StarredURL: &commit.Author.StarredURL, + SubscriptionsURL: &commit.Author.SubscriptionsURL, + OrganizationsURL: &commit.Author.OrganizationsURL, + ReposURL: &commit.Author.ReposURL, + EventsURL: &commit.Author.EventsURL, + ReceivedEventsURL: &commit.Author.ReceivedEventsURL, + Type: &commit.Author.Type, + UserViewType: &commit.Author.UserViewType, + SiteAdmin: commit.Author.SiteAdmin, + } + + commiter := model.User{ + Login: &commit.Committer.Login, + ID: commit.Committer.ID, + NodeID: &commit.Committer.NodeID, + AvatarURL: &commit.Committer.AvatarURL, + GravatarID: &commit.Committer.GravatarID, + URL: &commit.Committer.URL, + HTMLURL: &commit.Committer.HTMLURL, + FollowersURL: &commit.Committer.FollowersURL, + FollowingURL: &commit.Committer.FollowingURL, + GistsURL: &commit.Committer.GistsURL, + StarredURL: &commit.Committer.StarredURL, + SubscriptionsURL: &commit.Committer.SubscriptionsURL, + OrganizationsURL: &commit.Committer.OrganizationsURL, + ReposURL: &commit.Committer.ReposURL, + EventsURL: &commit.Committer.EventsURL, + ReceivedEventsURL: &commit.Committer.ReceivedEventsURL, + Type: &commit.Committer.Type, + UserViewType: &commit.Committer.UserViewType, + SiteAdmin: commit.Committer.SiteAdmin, + } + + var parents []model.Parent + for _, parent := range commit.Parents { + parents = append(parents, model.Parent{ + SHA: &parent.SHA, + URL: &parent.URL, + HTMLURL: &parent.HTMLURL, + }) + } + + stats := model.Stats{ + Total: commit.Stats.Total, + Additions: commit.Stats.Additions, + Deletions: commit.Stats.Deletions, + } + + var files []model.File + for _, file := range files { + files = append(files, model.File{ + SHA: file.SHA, + Filename: file.Filename, + Status: file.Status, + Additions: file.Additions, + Deletions: file.Deletions, + Changes: file.Changes, + BlobURL: file.BlobURL, + RawURL: file.RawURL, + ContentsURL: file.ContentsURL, + Patch: file.Patch, + }) + } + value := models.Resource{ ID: commit.SHA, Name: commit.SHA, Description: JSONAllFieldsMarshaller{ Value: model.CommitDescription{ - SHA: commit.SHA, - NodeID: commit.NodeID, - CommitDetail: commit.CommitDetail, - URL: commit.URL, - HTMLURL: commit.HTMLURL, - CommentsURL: commit.CommentsURL, - Author: commit.Author, - Committer: commit.Committer, - Parents: commit.Parents, - Stats: commit.Stats, - Files: commit.Files, + SHA: &commit.SHA, + NodeID: &commit.NodeID, + CommitDetail: commitDetail, + URL: &commit.URL, + HTMLURL: &commit.HTMLURL, + CommentsURL: &commit.CommentsURL, + Author: author, + Committer: commiter, + Parents: parents, + Stats: stats, + Files: files, }, }, } diff --git a/provider/describer/issue.go b/provider/describer/issue.go index 1a5a753b..a04469f6 100644 --- a/provider/describer/issue.go +++ b/provider/describer/issue.go @@ -8,6 +8,7 @@ import ( steampipemodels "github.com/turbot/steampipe-plugin-github/github/models" "math" "strconv" + "time" ) func GetIssueList(ctx context.Context, githubClient GitHubClient, organizationName string, stream *models.StreamSender) ([]models.Resource, error) { @@ -47,43 +48,211 @@ func GetIssueList(ctx context.Context, githubClient GitHubClient, organizationNa for _, issue := range query.Repository.Issues.Nodes { labelsSrcLength := int(math.Min(float64(len(issue.Labels.Nodes)), 100.0)) labelsSrc := issue.Labels.Nodes[:labelsSrcLength] - labels := make(map[string]steampipemodels.Label) + var finalLabelsSrc []model.Label + for _, labelSrc := range labelsSrc { + finalLabelsSrc = append(finalLabelsSrc, model.Label{ + NodeId: &labelSrc.NodeId, + Name: &labelSrc.Name, + Description: &labelSrc.Description, + IsDefault: labelSrc.IsDefault, + Color: &labelSrc.Color, + }) + } + labels := make(map[string]model.Label) for _, label := range issue.Labels.Nodes { - labels[label.Name] = label + labels[label.Name] = model.Label{ + NodeId: &label.NodeId, + Name: &label.Name, + Description: &label.Description, + IsDefault: label.IsDefault, + Color: &label.Color, + } + } + + author := model.Actor{ + AvatarUrl: &issue.Author.AvatarUrl, + Login: &issue.Author.Login, + Url: &issue.Author.Url, + } + + editor := model.Actor{ + AvatarUrl: &issue.Editor.AvatarUrl, + Login: &issue.Editor.Login, + Url: &issue.Editor.Url, + } + + milestoneClosedAt := issue.Milestone.ClosedAt.Format(time.RFC3339) + milestoneCreatedAt := issue.Milestone.CreatedAt.Format(time.RFC3339) + milestoneDueOn := issue.Milestone.DueOn.Format(time.RFC3339) + milestoneUpdatedAt := issue.Milestone.UpdatedAt.Format(time.RFC3339) + + milestoneCreator := model.Actor{ + AvatarUrl: &issue.Milestone.Creator.AvatarUrl, + Login: &issue.Milestone.Creator.Login, + Url: &issue.Milestone.Creator.Url, + } + + milestone := model.Milestone{ + Closed: issue.Milestone.Closed, + ClosedAt: &milestoneClosedAt, + CreatedAt: &milestoneCreatedAt, + Creator: milestoneCreator, + Description: &issue.Milestone.Description, + DueOn: &milestoneDueOn, + Number: issue.Milestone.Number, + ProgressPercentage: issue.Milestone.ProgressPercentage, + State: &issue.Milestone.State, + Title: &issue.Milestone.Title, + UpdatedAt: &milestoneUpdatedAt, + UserCanClose: issue.Milestone.UserCanClose, + UserCanReopen: issue.Milestone.UserCanReopen, } + + var assignees []model.BaseUser + for _, assignee := range issue.Assignees.Nodes { + assigneeCreatedAt := assignee.CreatedAt.Format(time.RFC3339) + assigneeUpdatedAt := assignee.UpdatedAt.Format(time.RFC3339) + interactionAbilityExpiresAt := assignee.InteractionAbility.ExpiresAt.Format(time.RFC3339) + sponsorListingCreatedAt := assignee.SponsorsListing.CreatedAt.Format(time.RFC3339) + nextPayoutDate := assignee.SponsorsListing.NextPayoutDate.Format(time.RFC3339) + statusCreatedAt := assignee.Status.CreatedAt.Format(time.RFC3339) + statusUpdatedAt := assignee.Status.UpdatedAt.Format(time.RFC3339) + statusExpiresAt := assignee.Status.ExpiresAt.Format(time.RFC3339) + + interactionAbility := model.RepositoryInteractionAbility{ + ExpiresAt: &interactionAbilityExpiresAt, + Limit: &assignee.InteractionAbility.Limit, + Origin: &assignee.InteractionAbility.Origin, + } + + activeGoal := model.SponsorsGoal{ + Description: &assignee.SponsorsListing.ActiveGoal.Description, + PercentComplete: assignee.SponsorsListing.ActiveGoal.PercentComplete, + TargetValue: assignee.SponsorsListing.ActiveGoal.TargetValue, + Title: &assignee.SponsorsListing.ActiveGoal.Title, + Kind: &assignee.SponsorsListing.ActiveGoal.Kind, + } + + activeStripeConnectAccount := model.StripeConnectAccount{ + AccountId: &assignee.SponsorsListing.ActiveStripeConnectAccount.AccountId, + BillingCountryOrRegion: &assignee.SponsorsListing.ActiveStripeConnectAccount.BillingCountryOrRegion, + CountryOrRegion: &assignee.SponsorsListing.ActiveStripeConnectAccount.CountryOrRegion, + IsActive: assignee.SponsorsListing.ActiveStripeConnectAccount.IsActive, + StripeDashboardUrl: &assignee.SponsorsListing.ActiveStripeConnectAccount.StripeDashboardUrl, + } + + sponsorListing := model.SponsorsListing{ + Id: &assignee.SponsorsListing.Id, + ActiveGoal: activeGoal, + ActiveStripeConnectAccount: activeStripeConnectAccount, + BillingCountryOrRegion: &assignee.SponsorsListing.BillingCountryOrRegion, + ContactEmailAddress: &assignee.SponsorsListing.ContactEmailAddress, + CreatedAt: &sponsorListingCreatedAt, + DashboardUrl: &assignee.SponsorsListing.DashboardUrl, + FullDescription: &assignee.SponsorsListing.FullDescription, + IsPublic: assignee.SponsorsListing.IsPublic, + Name: &assignee.SponsorsListing.Name, + NextPayoutDate: &nextPayoutDate, + ResidenceCountryOrRegion: &assignee.SponsorsListing.ResidenceCountryOrRegion, + ShortDescription: &assignee.SponsorsListing.ShortDescription, + Slug: &assignee.SponsorsListing.Slug, + Url: &assignee.SponsorsListing.Url, + } + + status := model.UserStatus{ + CreatedAt: &statusCreatedAt, + UpdatedAt: &statusUpdatedAt, + ExpiresAt: &statusExpiresAt, + Emoji: &assignee.Status.Emoji, + Message: &assignee.Status.Message, + IndicatesLimitedAvailability: assignee.Status.IndicatesLimitedAvailability, + } + + assignees = append(assignees, model.BaseUser{ + BasicUser: model.BasicUser{ + Id: assignee.Id, + NodeId: &assignee.NodeId, + Name: &assignee.Name, + Login: &assignee.Login, + Email: &assignee.Email, + CreatedAt: &assigneeCreatedAt, + UpdatedAt: &assigneeUpdatedAt, + Url: &assignee.Url, + }, + AnyPinnableItems: assignee.AnyPinnableItems, + AvatarUrl: &assignee.AvatarUrl, + Bio: &assignee.Bio, + Company: &assignee.Company, + EstimatedNextSponsorsPayoutInCents: assignee.EstimatedNextSponsorsPayoutInCents, + HasSponsorsListing: assignee.HasSponsorsListing, + InteractionAbility: interactionAbility, + IsBountyHunter: assignee.IsBountyHunter, + IsCampusExpert: assignee.IsCampusExpert, + IsDeveloperProgramMember: assignee.IsDeveloperProgramMember, + IsEmployee: assignee.IsEmployee, + IsFollowingYou: assignee.IsFollowingYou, + IsGitHubStar: assignee.IsGitHubStar, + IsHireable: assignee.IsHireable, + IsSiteAdmin: assignee.IsSiteAdmin, + IsSponsoringYou: assignee.IsSponsoringYou, + IsYou: assignee.IsYou, + Location: &assignee.Location, + MonthlyEstimatedSponsorsIncomeInCents: assignee.MonthlyEstimatedSponsorsIncomeInCents, + PinnedItemsRemaining: assignee.PinnedItemsRemaining, + ProjectsUrl: &assignee.ProjectsUrl, + Pronouns: &assignee.Pronouns, + SponsorsListing: sponsorListing, + Status: status, + TwitterUsername: &assignee.TwitterUsername, + CanChangedPinnedItems: assignee.CanChangedPinnedItems, + CanCreateProjects: assignee.CanCreateProjects, + CanFollow: assignee.CanFollow, + CanSponsor: assignee.CanSponsor, + IsFollowing: assignee.IsFollowing, + IsSponsoring: assignee.IsSponsoring, + WebsiteUrl: &assignee.WebsiteUrl, + }) + } + + closedAt := issue.ClosedAt.Format(time.RFC3339) + createdAt := issue.CreatedAt.Format(time.RFC3339) + lastEditedAt := issue.LastEditedAt.Format(time.RFC3339) + publishedAt := issue.PublishedAt.Format(time.RFC3339) + updatedAt := issue.UpdatedAt.Format(time.RFC3339) + value := models.Resource{ ID: strconv.Itoa(issue.Id), Name: issue.Title, Description: JSONAllFieldsMarshaller{ Value: model.IssueDescription{ - RepositoryFullName: r.GetFullName(), + RepositoryFullName: r.FullName, Id: issue.Id, - NodeId: issue.NodeId, + NodeId: &issue.NodeId, Number: issue.Number, - ActiveLockReason: issue.ActiveLockReason, - Author: issue.Author, - AuthorLogin: issue.Author.Login, - AuthorAssociation: issue.AuthorAssociation, - Body: issue.Body, - BodyUrl: issue.BodyUrl, + ActiveLockReason: &issue.ActiveLockReason, + Author: author, + AuthorLogin: &issue.Author.Login, + AuthorAssociation: &issue.AuthorAssociation, + Body: &issue.Body, + BodyUrl: &issue.BodyUrl, Closed: issue.Closed, - ClosedAt: issue.ClosedAt, - CreatedAt: issue.CreatedAt, + ClosedAt: &closedAt, + CreatedAt: &createdAt, CreatedViaEmail: issue.CreatedViaEmail, - Editor: issue.Editor, - FullDatabaseId: issue.FullDatabaseId, + Editor: editor, + FullDatabaseId: &issue.FullDatabaseId, IncludesCreatedEdit: issue.IncludesCreatedEdit, IsPinned: issue.IsPinned, IsReadByUser: issue.IsReadByUser, - LastEditedAt: issue.LastEditedAt, + LastEditedAt: &lastEditedAt, Locked: issue.Locked, - Milestone: issue.Milestone, - PublishedAt: issue.PublishedAt, - State: issue.State, - StateReason: issue.StateReason, - Title: issue.Title, - UpdatedAt: issue.UpdatedAt, - Url: issue.Url, + Milestone: milestone, + PublishedAt: &publishedAt, + State: &issue.State, + StateReason: &issue.StateReason, + Title: &issue.Title, + UpdatedAt: &updatedAt, + Url: &issue.Url, UserCanClose: issue.UserCanClose, UserCanReact: issue.UserCanReact, UserCanReopen: issue.UserCanReopen, @@ -91,13 +260,13 @@ func GetIssueList(ctx context.Context, githubClient GitHubClient, organizationNa UserCanUpdate: issue.UserCanUpdate, UserCannotUpdateReasons: issue.UserCannotUpdateReasons, UserDidAuthor: issue.UserDidAuthor, - UserSubscription: issue.UserSubscription, + UserSubscription: &issue.UserSubscription, CommentsTotalCount: issue.Comments.TotalCount, LabelsTotalCount: issue.Labels.TotalCount, - LabelsSrc: labelsSrc, + LabelsSrc: finalLabelsSrc, Labels: labels, AssigneesTotalCount: issue.Assignees.TotalCount, - Assignees: issue.Assignees.Nodes, + Assignees: assignees, }, }, } @@ -146,43 +315,211 @@ func GetIssue(ctx context.Context, githubClient GitHubClient, organizationName s } labelsSrcLength := int(math.Min(float64(len(query.Repository.Issue.Labels.Nodes)), 100.0)) labelsSrc := query.Repository.Issue.Labels.Nodes[:labelsSrcLength] - labels := make(map[string]steampipemodels.Label) + var finalLabelsSrc []model.Label + for _, labelSrc := range labelsSrc { + finalLabelsSrc = append(finalLabelsSrc, model.Label{ + NodeId: &labelSrc.NodeId, + Name: &labelSrc.Name, + Description: &labelSrc.Description, + IsDefault: labelSrc.IsDefault, + Color: &labelSrc.Color, + }) + } + labels := make(map[string]model.Label) for _, label := range query.Repository.Issue.Labels.Nodes { - labels[label.Name] = label + labels[label.Name] = model.Label{ + NodeId: &label.NodeId, + Name: &label.Name, + Description: &label.Description, + IsDefault: label.IsDefault, + Color: &label.Color, + } + } + + author := model.Actor{ + AvatarUrl: &query.Repository.Issue.Author.AvatarUrl, + Login: &query.Repository.Issue.Author.Login, + Url: &query.Repository.Issue.Author.Url, + } + + editor := model.Actor{ + AvatarUrl: &query.Repository.Issue.Editor.AvatarUrl, + Login: &query.Repository.Issue.Editor.Login, + Url: &query.Repository.Issue.Editor.Url, + } + + milestoneClosedAt := query.Repository.Issue.Milestone.ClosedAt.Format(time.RFC3339) + milestoneCreatedAt := query.Repository.Issue.Milestone.CreatedAt.Format(time.RFC3339) + milestoneDueOn := query.Repository.Issue.Milestone.DueOn.Format(time.RFC3339) + milestoneUpdatedAt := query.Repository.Issue.Milestone.UpdatedAt.Format(time.RFC3339) + + milestoneCreator := model.Actor{ + AvatarUrl: &query.Repository.Issue.Milestone.Creator.AvatarUrl, + Login: &query.Repository.Issue.Milestone.Creator.Login, + Url: &query.Repository.Issue.Milestone.Creator.Url, + } + + milestone := model.Milestone{ + Closed: query.Repository.Issue.Milestone.Closed, + ClosedAt: &milestoneClosedAt, + CreatedAt: &milestoneCreatedAt, + Creator: milestoneCreator, + Description: &query.Repository.Issue.Milestone.Description, + DueOn: &milestoneDueOn, + Number: query.Repository.Issue.Milestone.Number, + ProgressPercentage: query.Repository.Issue.Milestone.ProgressPercentage, + State: &query.Repository.Issue.Milestone.State, + Title: &query.Repository.Issue.Milestone.Title, + UpdatedAt: &milestoneUpdatedAt, + UserCanClose: query.Repository.Issue.Milestone.UserCanClose, + UserCanReopen: query.Repository.Issue.Milestone.UserCanReopen, } + + var assignees []model.BaseUser + for _, assignee := range query.Repository.Issue.Assignees.Nodes { + assigneeCreatedAt := assignee.CreatedAt.Format(time.RFC3339) + assigneeUpdatedAt := assignee.UpdatedAt.Format(time.RFC3339) + interactionAbilityExpiresAt := assignee.InteractionAbility.ExpiresAt.Format(time.RFC3339) + sponsorListingCreatedAt := assignee.SponsorsListing.CreatedAt.Format(time.RFC3339) + nextPayoutDate := assignee.SponsorsListing.NextPayoutDate.Format(time.RFC3339) + statusCreatedAt := assignee.Status.CreatedAt.Format(time.RFC3339) + statusUpdatedAt := assignee.Status.UpdatedAt.Format(time.RFC3339) + statusExpiresAt := assignee.Status.ExpiresAt.Format(time.RFC3339) + + interactionAbility := model.RepositoryInteractionAbility{ + ExpiresAt: &interactionAbilityExpiresAt, + Limit: &assignee.InteractionAbility.Limit, + Origin: &assignee.InteractionAbility.Origin, + } + + activeGoal := model.SponsorsGoal{ + Description: &assignee.SponsorsListing.ActiveGoal.Description, + PercentComplete: assignee.SponsorsListing.ActiveGoal.PercentComplete, + TargetValue: assignee.SponsorsListing.ActiveGoal.TargetValue, + Title: &assignee.SponsorsListing.ActiveGoal.Title, + Kind: &assignee.SponsorsListing.ActiveGoal.Kind, + } + + activeStripeConnectAccount := model.StripeConnectAccount{ + AccountId: &assignee.SponsorsListing.ActiveStripeConnectAccount.AccountId, + BillingCountryOrRegion: &assignee.SponsorsListing.ActiveStripeConnectAccount.BillingCountryOrRegion, + CountryOrRegion: &assignee.SponsorsListing.ActiveStripeConnectAccount.CountryOrRegion, + IsActive: assignee.SponsorsListing.ActiveStripeConnectAccount.IsActive, + StripeDashboardUrl: &assignee.SponsorsListing.ActiveStripeConnectAccount.StripeDashboardUrl, + } + + sponsorListing := model.SponsorsListing{ + Id: &assignee.SponsorsListing.Id, + ActiveGoal: activeGoal, + ActiveStripeConnectAccount: activeStripeConnectAccount, + BillingCountryOrRegion: &assignee.SponsorsListing.BillingCountryOrRegion, + ContactEmailAddress: &assignee.SponsorsListing.ContactEmailAddress, + CreatedAt: &sponsorListingCreatedAt, + DashboardUrl: &assignee.SponsorsListing.DashboardUrl, + FullDescription: &assignee.SponsorsListing.FullDescription, + IsPublic: assignee.SponsorsListing.IsPublic, + Name: &assignee.SponsorsListing.Name, + NextPayoutDate: &nextPayoutDate, + ResidenceCountryOrRegion: &assignee.SponsorsListing.ResidenceCountryOrRegion, + ShortDescription: &assignee.SponsorsListing.ShortDescription, + Slug: &assignee.SponsorsListing.Slug, + Url: &assignee.SponsorsListing.Url, + } + + status := model.UserStatus{ + CreatedAt: &statusCreatedAt, + UpdatedAt: &statusUpdatedAt, + ExpiresAt: &statusExpiresAt, + Emoji: &assignee.Status.Emoji, + Message: &assignee.Status.Message, + IndicatesLimitedAvailability: assignee.Status.IndicatesLimitedAvailability, + } + + assignees = append(assignees, model.BaseUser{ + BasicUser: model.BasicUser{ + Id: assignee.Id, + NodeId: &assignee.NodeId, + Name: &assignee.Name, + Login: &assignee.Login, + Email: &assignee.Email, + CreatedAt: &assigneeCreatedAt, + UpdatedAt: &assigneeUpdatedAt, + Url: &assignee.Url, + }, + AnyPinnableItems: assignee.AnyPinnableItems, + AvatarUrl: &assignee.AvatarUrl, + Bio: &assignee.Bio, + Company: &assignee.Company, + EstimatedNextSponsorsPayoutInCents: assignee.EstimatedNextSponsorsPayoutInCents, + HasSponsorsListing: assignee.HasSponsorsListing, + InteractionAbility: interactionAbility, + IsBountyHunter: assignee.IsBountyHunter, + IsCampusExpert: assignee.IsCampusExpert, + IsDeveloperProgramMember: assignee.IsDeveloperProgramMember, + IsEmployee: assignee.IsEmployee, + IsFollowingYou: assignee.IsFollowingYou, + IsGitHubStar: assignee.IsGitHubStar, + IsHireable: assignee.IsHireable, + IsSiteAdmin: assignee.IsSiteAdmin, + IsSponsoringYou: assignee.IsSponsoringYou, + IsYou: assignee.IsYou, + Location: &assignee.Location, + MonthlyEstimatedSponsorsIncomeInCents: assignee.MonthlyEstimatedSponsorsIncomeInCents, + PinnedItemsRemaining: assignee.PinnedItemsRemaining, + ProjectsUrl: &assignee.ProjectsUrl, + Pronouns: &assignee.Pronouns, + SponsorsListing: sponsorListing, + Status: status, + TwitterUsername: &assignee.TwitterUsername, + CanChangedPinnedItems: assignee.CanChangedPinnedItems, + CanCreateProjects: assignee.CanCreateProjects, + CanFollow: assignee.CanFollow, + CanSponsor: assignee.CanSponsor, + IsFollowing: assignee.IsFollowing, + IsSponsoring: assignee.IsSponsoring, + WebsiteUrl: &assignee.WebsiteUrl, + }) + } + + closedAt := query.Repository.Issue.ClosedAt.Format(time.RFC3339) + createdAt := query.Repository.Issue.CreatedAt.Format(time.RFC3339) + lastEditedAt := query.Repository.Issue.LastEditedAt.Format(time.RFC3339) + publishedAt := query.Repository.Issue.PublishedAt.Format(time.RFC3339) + updatedAt := query.Repository.Issue.UpdatedAt.Format(time.RFC3339) + value := models.Resource{ ID: strconv.Itoa(query.Repository.Issue.Id), Name: query.Repository.Issue.Title, Description: JSONAllFieldsMarshaller{ Value: model.IssueDescription{ - RepositoryFullName: repoFullName, + RepositoryFullName: &repoFullName, Id: query.Repository.Issue.Id, - NodeId: query.Repository.Issue.NodeId, + NodeId: &query.Repository.Issue.NodeId, Number: query.Repository.Issue.Number, - ActiveLockReason: query.Repository.Issue.ActiveLockReason, - Author: query.Repository.Issue.Author, - AuthorLogin: query.Repository.Issue.Author.Login, - AuthorAssociation: query.Repository.Issue.AuthorAssociation, - Body: query.Repository.Issue.Body, - BodyUrl: query.Repository.Issue.BodyUrl, + ActiveLockReason: &query.Repository.Issue.ActiveLockReason, + Author: author, + AuthorLogin: &query.Repository.Issue.Author.Login, + AuthorAssociation: &query.Repository.Issue.AuthorAssociation, + Body: &query.Repository.Issue.Body, + BodyUrl: &query.Repository.Issue.BodyUrl, Closed: query.Repository.Issue.Closed, - ClosedAt: query.Repository.Issue.ClosedAt, - CreatedAt: query.Repository.Issue.CreatedAt, + ClosedAt: &closedAt, + CreatedAt: &createdAt, CreatedViaEmail: query.Repository.Issue.CreatedViaEmail, - Editor: query.Repository.Issue.Editor, - FullDatabaseId: query.Repository.Issue.FullDatabaseId, + Editor: editor, + FullDatabaseId: &query.Repository.Issue.FullDatabaseId, IncludesCreatedEdit: query.Repository.Issue.IncludesCreatedEdit, IsPinned: query.Repository.Issue.IsPinned, IsReadByUser: query.Repository.Issue.IsReadByUser, - LastEditedAt: query.Repository.Issue.LastEditedAt, + LastEditedAt: &lastEditedAt, Locked: query.Repository.Issue.Locked, - Milestone: query.Repository.Issue.Milestone, - PublishedAt: query.Repository.Issue.PublishedAt, - State: query.Repository.Issue.State, - StateReason: query.Repository.Issue.StateReason, - Title: query.Repository.Issue.Title, - UpdatedAt: query.Repository.Issue.UpdatedAt, - Url: query.Repository.Issue.Url, + Milestone: milestone, + PublishedAt: &publishedAt, + State: &query.Repository.Issue.State, + StateReason: &query.Repository.Issue.StateReason, + Title: &query.Repository.Issue.Title, + UpdatedAt: &updatedAt, + Url: &query.Repository.Issue.Url, UserCanClose: query.Repository.Issue.UserCanClose, UserCanReact: query.Repository.Issue.UserCanReact, UserCanReopen: query.Repository.Issue.UserCanReopen, @@ -190,13 +527,13 @@ func GetIssue(ctx context.Context, githubClient GitHubClient, organizationName s UserCanUpdate: query.Repository.Issue.UserCanUpdate, UserCannotUpdateReasons: query.Repository.Issue.UserCannotUpdateReasons, UserDidAuthor: query.Repository.Issue.UserDidAuthor, - UserSubscription: query.Repository.Issue.UserSubscription, + UserSubscription: &query.Repository.Issue.UserSubscription, CommentsTotalCount: query.Repository.Issue.Comments.TotalCount, LabelsTotalCount: query.Repository.Issue.Labels.TotalCount, - LabelsSrc: labelsSrc, + LabelsSrc: finalLabelsSrc, Labels: labels, AssigneesTotalCount: query.Repository.Issue.Assignees.TotalCount, - Assignees: query.Repository.Issue.Assignees.Nodes, + Assignees: assignees, }, }, } diff --git a/provider/model/model.go b/provider/model/model.go index 474fc30e..371ee3b4 100755 --- a/provider/model/model.go +++ b/provider/model/model.go @@ -18,14 +18,20 @@ type Metadata struct{} type ArtifactDescription struct { ID int64 - NodeID string - Name string + NodeID *string + Name *string SizeInBytes int64 - ArchiveDownloadURL string + ArchiveDownloadURL *string Expired bool - CreatedAt github.Timestamp - ExpiresAt github.Timestamp - RepoFullName string + CreatedAt *string + ExpiresAt *string + RepoFullName *string +} + +type RunnerLabels struct { + ID *int64 + Name *string + Type *string } type RunnerDescription struct { @@ -34,50 +40,50 @@ type RunnerDescription struct { OS *string Status *string Busy *bool - Labels []*github.RunnerLabels - RepoFullName string + Labels []*RunnerLabels + RepoFullName *string } type SecretDescription struct { - Name string - CreatedAt string - UpdatedAt string - Visibility string - SelectedRepositoriesURL string - RepoFullName string + Name *string + CreatedAt *string + UpdatedAt *string + Visibility *string + SelectedRepositoriesURL *string + RepoFullName *string } type SimpleActor struct { - Login string `json:"login"` - ID int `json:"id"` - NodeID string `json:"node_id"` - Type string `json:"type"` + Login *string + ID int + NodeID *string + Type *string } type SimpleRepo struct { - ID int `json:"id"` - NodeID string `json:"node_id"` + ID int + NodeID *string } type CommitRefWorkflow struct { - ID string `json:"id"` + ID *string } type WorkflowRunDescription struct { ID int - Name string - HeadBranch string - HeadSHA string - Status string - Conclusion string - HTMLURL string + Name *string + HeadBranch *string + HeadSHA *string + Status *string + Conclusion *string + HTMLURL *string WorkflowID int RunNumber int - Event string - CreatedAt string - UpdatedAt string + Event *string + CreatedAt *string + UpdatedAt *string RunAttempt int - RunStartedAt string + RunStartedAt *string Actor *SimpleActor HeadCommit *CommitRefWorkflow Repository *SimpleRepo @@ -92,7 +98,7 @@ type WorkflowRunsResponse struct { WorkflowRuns []WorkflowRunDescription `json:"workflow_runs"` } -type WorkflowArtifact struct { +type WorkflowArtifactJSON struct { ID int `json:"id"` NodeID string `json:"node_id"` Name string `json:"name"` @@ -105,24 +111,46 @@ type WorkflowArtifact struct { ExpiresAt string `json:"expires_at"` } +type WorkflowArtifact struct { + ID int + NodeID *string + Name *string + SizeInBytes int + URL *string + ArchiveDownloadURL *string + Expired bool + CreatedAt *string + UpdatedAt *string + ExpiresAt *string +} + type ArtifactsResponse struct { - TotalCount int `json:"total_count"` - Artifacts []WorkflowArtifact `json:"artifacts"` + TotalCount int `json:"total_count"` + Artifacts []WorkflowArtifactJSON `json:"artifacts"` +} + +type ActorLocation struct { + CountryCode *string +} + +type AuditEntryData struct { + OldName *string + OldLogin *string } type AuditLogDescription struct { - ID string - CreatedAt github.Timestamp - Organization string - Phrase string - Include string - Action string - Actor string - ActorLocation *github.ActorLocation - Team string - UserLogin string - Repo string - Data *github.AuditEntryData + ID *string + CreatedAt *string + Organization *string + Phrase *string + Include *string + Action *string + Actor *string + ActorLocation *ActorLocation + Team *string + UserLogin *string + Repo *string + Data *AuditEntryData } //type BlobDescription struct { @@ -135,41 +163,135 @@ type AuditLogDescription struct { // RepoFullName string //} +type BasicUser struct { + Id int + NodeId *string + Name *string + Login *string + Email *string + CreatedAt *string + UpdatedAt *string + Url *string +} + +type GitActor struct { + AvatarUrl *string + Date *string + Email *string + Name *string + User BasicUser +} + +type Signature struct { + Email *string + IsValid bool + State *string + WasSignedByGitHub bool + Signer struct { + Email *string + Login *string + } +} + +type CommitStatus struct { + State *string +} + +type BaseCommit struct { + Sha *string + ShortSha *string + AuthoredDate *string + Author GitActor + CommittedDate *string + Committer GitActor + Message *string + Url *string + Additions int + AuthoredByCommitter bool + ChangedFiles int + CommittedViaWeb bool + CommitUrl *string + Deletions int + Signature Signature + TarballUrl *string + TreeUrl *string + CanSubscribe bool + Subscription *string + ZipballUrl *string + MessageHeadline *string + Status CommitStatus + NodeId *string +} + +type Actor struct { + AvatarUrl *string + Login *string + Url *string +} + +type BranchProtectionRule struct { + AllowsDeletions bool + AllowsForcePushes bool + BlocksCreations bool + CreatorLogin *string + Id int + NodeId *string + DismissesStaleReviews bool + IsAdminEnforced bool + LockAllowsFetchAndMerge bool + LockBranch bool + Pattern *string + RequireLastPushApproval bool + RequiredApprovingReviewCount int + RequiredDeploymentEnvironments []string + RequiredStatusChecks []string + RequiresApprovingReviews bool + RequiresConversationResolution bool + RequiresCodeOwnerReviews bool + RequiresCommitSignatures bool + RequiresDeployments bool + RequiresLinearHistory bool + RequiresStatusChecks bool + RequiresStrictStatusChecks bool + RestrictsPushes bool + RestrictsReviewDismissals bool + MatchingBranches int +} + type BranchDescription struct { - RepoFullName string - Name string - Commit steampipemodels.BaseCommit - BranchProtectionRule steampipemodels.BranchProtectionRule + RepoFullName *string + Name *string + Commit BaseCommit + BranchProtectionRule BranchProtectionRule Protected bool } type BranchApp struct { - Name string - Slug string + Name *string + Slug *string } type BranchTeam struct { - Name string - Slug string + Name *string + Slug *string } type BranchUser struct { - Name string - Login string + Name *string + Login *string } type BranchProtectionDescription struct { AllowsDeletions bool AllowsForcePushes bool BlocksCreations bool - Creator steampipemodels.Actor Id int - NodeId string + NodeId *string DismissesStaleReviews bool IsAdminEnforced bool LockAllowsFetchAndMerge bool LockBranch bool - Pattern string + Pattern *string RequireLastPushApproval bool RequiredApprovingReviewCount int RequiredDeploymentEnvironments []string @@ -184,8 +306,8 @@ type BranchProtectionDescription struct { RequiresStrictStatusChecks bool RestrictsPushes bool RestrictsReviewDismissals bool - RepoFullName string - CreatorLogin string + RepoFullName *string + CreatorLogin *string MatchingBranches int PushAllowanceApps []BranchApp PushAllowanceTeams []BranchTeam @@ -198,12 +320,17 @@ type BranchProtectionDescription struct { BypassPullRequestAllowanceUsers []BranchUser } -type Tree struct { +type TreeJSON struct { SHA string `json:"sha"` URL string `json:"url"` } -type File struct { +type Tree struct { + SHA *string + URL *string +} + +type FileJSON struct { SHA string `json:"sha"` Filename string `json:"filename"` Status string `json:"status"` @@ -216,13 +343,20 @@ type File struct { Patch *string `json:"patch"` } -type Target struct { - Branch string `json:"branch"` - Organization string `json:"organization"` - Repository string `json:"repository"` -} - -type Verification struct { +type File struct { + SHA *string + Filename *string + Status *string + Additions int + Deletions int + Changes int + BlobURL *string + RawURL *string + ContentsURL *string + Patch *string +} + +type VerificationJSON struct { Verified bool `json:"verified"` Reason string `json:"reason"` Signature *string `json:"signature"` @@ -230,7 +364,15 @@ type Verification struct { VerifiedAt *string `json:"verified_at"` } -type User struct { +type Verification struct { + Verified bool + Reason *string + Signature *string + Payload *string + VerifiedAt *string +} + +type UserJSON struct { Login string `json:"login"` ID int `json:"id"` NodeID string `json:"node_id"` @@ -252,49 +394,90 @@ type User struct { SiteAdmin bool `json:"site_admin"` } -type CommitDetail struct { +type User struct { + Login *string `json:"login"` + ID int `json:"id"` + NodeID *string `json:"node_id"` + AvatarURL *string `json:"avatar_url"` + GravatarID *string `json:"gravatar_id"` + URL *string `json:"url"` + HTMLURL *string `json:"html_url"` + FollowersURL *string `json:"followers_url"` + FollowingURL *string `json:"following_url"` + GistsURL *string `json:"gists_url"` + StarredURL *string `json:"starred_url"` + SubscriptionsURL *string `json:"subscriptions_url"` + OrganizationsURL *string `json:"organizations_url"` + ReposURL *string `json:"repos_url"` + EventsURL *string `json:"events_url"` + ReceivedEventsURL *string `json:"received_events_url"` + Type *string `json:"type"` + UserViewType *string `json:"user_view_type"` + SiteAdmin bool `json:"site_admin"` +} + +type CommitDetailJSON struct { //Author UserMinimalInfo `json:"author"` //Committer UserMinimalInfo `json:"committer"` - Message string `json:"message"` - Tree Tree `json:"tree"` //URL string `json:"url"` - CommentCount int `json:"comment_count"` - Verification Verification `json:"verification"` + Message string `json:"message"` + Tree TreeJSON `json:"tree"` + CommentCount int `json:"comment_count"` + Verification VerificationJSON `json:"verification"` } -type Parent struct { +type CommitDetail struct { + Message *string + Tree Tree + CommentCount int + Verification Verification +} + +type ParentJSON struct { SHA string `json:"sha"` URL string `json:"url"` HTMLURL string `json:"html_url"` } -type Stats struct { +type Parent struct { + SHA *string + URL *string + HTMLURL *string +} + +type StatsJSON struct { Total int `json:"total"` Additions int `json:"additions"` Deletions int `json:"deletions"` } +type Stats struct { + Total int + Additions int + Deletions int +} + type CommitResp struct { - SHA string `json:"sha"` - NodeID string `json:"node_id"` - CommitDetail CommitDetail `json:"commit"` - URL string `json:"url"` - HTMLURL string `json:"html_url"` - CommentsURL string `json:"comments_url"` - Author User `json:"author"` - Committer User `json:"committer"` - Parents []Parent `json:"parents"` - Stats Stats `json:"stats"` - Files []File `json:"files"` + SHA string `json:"sha"` + NodeID string `json:"node_id"` + CommitDetail CommitDetailJSON `json:"commit"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + CommentsURL string `json:"comments_url"` + Author UserJSON `json:"author"` + Committer UserJSON `json:"committer"` + Parents []ParentJSON `json:"parents"` + Stats StatsJSON `json:"stats"` + Files []FileJSON `json:"files"` } type CommitDescription struct { - SHA string - NodeID string + SHA *string + NodeID *string CommitDetail CommitDetail - URL string - HTMLURL string - CommentsURL string + URL *string + HTMLURL *string + CommentsURL *string Author User Committer User Parents []Parent @@ -302,35 +485,144 @@ type CommitDescription struct { Files []File } +type Milestone struct { + Closed bool + ClosedAt *string + CreatedAt *string + Creator Actor + Description *string + DueOn *string + Number int + ProgressPercentage float32 + State *githubv4.MilestoneState + Title *string + UpdatedAt *string + UserCanClose bool + UserCanReopen bool +} + +type Label struct { + NodeId *string + Name *string + Description *string + IsDefault bool + Color *string +} + +type RepositoryInteractionAbility struct { + ExpiresAt *string + Limit *string + Origin *string +} + +type SponsorsGoal struct { + Description *string + PercentComplete int + TargetValue int + Title *string + Kind *githubv4.SponsorsGoalKind +} + +type StripeConnectAccount struct { + AccountId *string + BillingCountryOrRegion *string + CountryOrRegion *string + IsActive bool + StripeDashboardUrl *string +} + +type SponsorsListing struct { + Id *string + ActiveGoal SponsorsGoal + ActiveStripeConnectAccount StripeConnectAccount + BillingCountryOrRegion *string + ContactEmailAddress *string + CreatedAt *string + DashboardUrl *string + FullDescription *string + IsPublic bool + Name *string + NextPayoutDate *string + ResidenceCountryOrRegion *string + ShortDescription *string + Slug *string + Url *string +} + +type BaseUser struct { + BasicUser + AnyPinnableItems bool + AvatarUrl *string + Bio *string + Company *string + EstimatedNextSponsorsPayoutInCents int + HasSponsorsListing bool + InteractionAbility RepositoryInteractionAbility + IsBountyHunter bool + IsCampusExpert bool + IsDeveloperProgramMember bool + IsEmployee bool + IsFollowingYou bool + IsGitHubStar bool + IsHireable bool + IsSiteAdmin bool + IsSponsoringYou bool + IsYou bool + Location *string + MonthlyEstimatedSponsorsIncomeInCents int + PinnedItemsRemaining int + ProjectsUrl *string + Pronouns *string + SponsorsListing SponsorsListing + Status UserStatus + TwitterUsername *string + CanChangedPinnedItems bool + CanCreateProjects bool + CanFollow bool + CanSponsor bool + IsFollowing bool + IsSponsoring bool + WebsiteUrl *string +} + +type UserStatus struct { + CreatedAt *string + UpdatedAt *string + ExpiresAt *string + Emoji *string + Message *string + IndicatesLimitedAvailability bool +} + type IssueDescription struct { - RepositoryFullName string + RepositoryFullName *string Id int - NodeId string + NodeId *string Number int - ActiveLockReason githubv4.LockReason - Author steampipemodels.Actor - AuthorLogin string - AuthorAssociation githubv4.CommentAuthorAssociation - Body string - BodyUrl string + ActiveLockReason *githubv4.LockReason + Author Actor + AuthorLogin *string + AuthorAssociation *githubv4.CommentAuthorAssociation + Body *string + BodyUrl *string Closed bool - ClosedAt steampipemodels.NullableTime - CreatedAt steampipemodels.NullableTime + ClosedAt *string + CreatedAt *string CreatedViaEmail bool - Editor steampipemodels.Actor - FullDatabaseId string + Editor Actor + FullDatabaseId *string IncludesCreatedEdit bool IsPinned bool IsReadByUser bool - LastEditedAt steampipemodels.NullableTime + LastEditedAt *string Locked bool - Milestone steampipemodels.Milestone - PublishedAt steampipemodels.NullableTime - State githubv4.IssueState - StateReason githubv4.IssueStateReason - Title string - UpdatedAt steampipemodels.NullableTime - Url string + Milestone Milestone + PublishedAt *string + State *githubv4.IssueState + StateReason *githubv4.IssueStateReason + Title *string + UpdatedAt *string + Url *string UserCanClose bool UserCanReact bool UserCanReopen bool @@ -338,13 +630,13 @@ type IssueDescription struct { UserCanUpdate bool UserCannotUpdateReasons []githubv4.CommentCannotUpdateReason UserDidAuthor bool - UserSubscription githubv4.SubscriptionState + UserSubscription *githubv4.SubscriptionState CommentsTotalCount int LabelsTotalCount int - LabelsSrc []steampipemodels.Label - Labels map[string]steampipemodels.Label + LabelsSrc []Label + Labels map[string]Label AssigneesTotalCount int - Assignees []steampipemodels.BaseUser + Assignees []BaseUser } //type IssueCommentDescription struct { @@ -1348,15 +1640,15 @@ type CommitResponse struct { } type ArtifactDockerFileDescription struct { - Sha *string - Name *string - Path *string - LastUpdatedAt *string - GitURL *string - HTMLURL *string - URI *string // Unique identifier - DockerfileContent string - DockerfileContentBase64 *string - Repository map[string]interface{} - Images []string // New field to store extracted base images + Sha *string + Name *string + Path *string + LastUpdatedAt *string + GitURL *string + HTMLURL *string + URI *string // Unique identifier + DockerfileContent string + DockerfileContentBase64 *string + Repository map[string]interface{} + Images []string // New field to store extracted base images }