Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ linters:
- CustomDeploymentProtectionRuleRequest
- CustomProperty
- DependabotAlertState
- DependencyGraphSnapshot
- EncryptedSecret
- EnterpriseSecurityAnalysisSettings
- Hook
Expand Down Expand Up @@ -304,7 +303,6 @@ linters:
- CommitsSearchResult.Commits
- CommitsSearchResult.Total
- CreateOrgInvitationOptions.TeamID # TODO: TeamIDs
- DependencyGraphSnapshot.Sha # TODO: SHA
- Discussion.DiscussionCategory # TODO: Category ?
- EditOwner.OwnerInfo
- EnterpriseLicensedUsers.GithubComSamlNameID # TODO: GithubComSAMLNameID
Expand Down
30 changes: 16 additions & 14 deletions github/dependency_graph_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ type DependencyGraphSnapshotResolvedDependency struct {
//
// GitHub API docs: https://docs.github.com/rest/dependency-graph/dependency-submission?apiVersion=2022-11-28#create-a-snapshot-of-dependencies-for-a-repository
type DependencyGraphSnapshotJob struct {
Correlator *string `json:"correlator,omitempty"`
ID *string `json:"id,omitempty"`
Correlator string `json:"correlator"`
ID string `json:"id"`
HTMLURL *string `json:"html_url,omitempty"`
}

// DependencyGraphSnapshotDetector represents a description of the detector used.
//
// GitHub API docs: https://docs.github.com/rest/dependency-graph/dependency-submission?apiVersion=2022-11-28#create-a-snapshot-of-dependencies-for-a-repository
type DependencyGraphSnapshotDetector struct {
Name *string `json:"name,omitempty"`
Version *string `json:"version,omitempty"`
URL *string `json:"url,omitempty"`
Name string `json:"name"`
Version string `json:"version"`
URL string `json:"url"`
}

// DependencyGraphSnapshotManifestFile represents the file declaring the repository's dependencies.
Expand All @@ -66,22 +66,24 @@ type DependencyGraphSnapshotManifestFile struct {
//
// GitHub API docs: https://docs.github.com/rest/dependency-graph/dependency-submission?apiVersion=2022-11-28#create-a-snapshot-of-dependencies-for-a-repository
type DependencyGraphSnapshotManifest struct {
Name *string `json:"name,omitempty"`
Name string `json:"name"`
File *DependencyGraphSnapshotManifestFile `json:"file,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Resolved map[string]*DependencyGraphSnapshotResolvedDependency `json:"resolved,omitempty"`
}

// DependencyGraphSnapshot represent a snapshot of a repository's dependencies.
// CreateDependencyGraphSnapshotRequest represents a request to create a snapshot of a repository's dependencies.
//
// GitHub API docs: https://docs.github.com/rest/dependency-graph/dependency-submission?apiVersion=2022-11-28#create-a-snapshot-of-dependencies-for-a-repository
type DependencyGraphSnapshot struct {
//
//meta:schema request POST /repos/{owner}/{repo}/dependency-graph/snapshots
type CreateDependencyGraphSnapshotRequest struct {
Version int `json:"version"`
Sha *string `json:"sha,omitempty"`
Ref *string `json:"ref,omitempty"`
Job *DependencyGraphSnapshotJob `json:"job,omitempty"`
Detector *DependencyGraphSnapshotDetector `json:"detector,omitempty"`
Scanned *Timestamp `json:"scanned,omitempty"`
SHA string `json:"sha"`
Ref string `json:"ref"`
Job DependencyGraphSnapshotJob `json:"job"`
Detector DependencyGraphSnapshotDetector `json:"detector"`
Scanned Timestamp `json:"scanned"`
Metadata map[string]any `json:"metadata,omitempty"`
Manifests map[string]*DependencyGraphSnapshotManifest `json:"manifests,omitempty"`
}
Expand All @@ -106,7 +108,7 @@ type DependencyGraphSnapshotCreationData struct {
// GitHub API docs: https://docs.github.com/rest/dependency-graph/dependency-submission?apiVersion=2022-11-28#create-a-snapshot-of-dependencies-for-a-repository
//
//meta:operation POST /repos/{owner}/{repo}/dependency-graph/snapshots
func (s *DependencyGraphService) CreateSnapshot(ctx context.Context, owner, repo string, body *DependencyGraphSnapshot) (*DependencyGraphSnapshotCreationData, *Response, error) {
func (s *DependencyGraphService) CreateSnapshot(ctx context.Context, owner, repo string, body CreateDependencyGraphSnapshotRequest) (*DependencyGraphSnapshotCreationData, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/dependency-graph/snapshots", owner, repo)

req, err := s.client.NewRequest(ctx, "POST", url, body)
Expand Down
24 changes: 12 additions & 12 deletions github/dependency_graph_snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ func TestDependencyGraphService_CreateSnapshot(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

snapshot := &DependencyGraphSnapshot{
snapshot := CreateDependencyGraphSnapshotRequest{
Version: 0,
Sha: new("ce587453ced02b1526dfb4cb910479d431683101"),
Ref: new("refs/heads/main"),
Job: &DependencyGraphSnapshotJob{
Correlator: new("yourworkflowname_youractionname"),
ID: new("yourrunid"),
SHA: "ce587453ced02b1526dfb4cb910479d431683101",
Ref: "refs/heads/main",
Job: DependencyGraphSnapshotJob{
Correlator: "yourworkflowname_youractionname",
ID: "yourrunid",
HTMLURL: new("https://example.com"),
},
Detector: &DependencyGraphSnapshotDetector{
Name: new("octo-detector"),
Version: new("0.0.1"),
URL: new("https://github.com/octo-org/octo-repo"),
Detector: DependencyGraphSnapshotDetector{
Name: "octo-detector",
Version: "0.0.1",
URL: "https://github.com/octo-org/octo-repo",
},
Scanned: &referenceTimestamp,
Scanned: referenceTimestamp,
Metadata: map[string]any{
"key1": "value1",
"key2": "value2",
},
Manifests: map[string]*DependencyGraphSnapshotManifest{
"package-lock.json": {
Name: new("package-lock.json"),
Name: "package-lock.json",
File: &DependencyGraphSnapshotManifestFile{SourceLocation: new("src/package-lock.json")},
Metadata: map[string]any{
"key1": "value1",
Expand Down
148 changes: 74 additions & 74 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading