Use int64 for GitHub database IDs and add lint check
Change all struct fields representing GitHub database IDs from int to int64 to match the API spec and prevent potential overflow on 32-bit architectures. Add a custom go/analysis linter (idtype-checker) that flags struct fields with ID-like names or JSON tags using int instead of int64, integrated into make lint. Closes #9247 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
1e6bb88c6d
commit
d4cd79e28c
24 changed files with 272 additions and 58 deletions
|
|
@ -150,7 +150,7 @@ type RepositoryOwner struct {
|
|||
|
||||
// Repository represents a GitHub repository.
|
||||
type Repository struct {
|
||||
ID int `json:"id"`
|
||||
ID int64 `json:"id"`
|
||||
FullName string `json:"full_name"`
|
||||
DefaultBranch string `json:"default_branch"`
|
||||
Owner RepositoryOwner `json:"owner"`
|
||||
|
|
@ -602,7 +602,7 @@ type Machine struct {
|
|||
}
|
||||
|
||||
// GetCodespacesMachines returns the codespaces machines for the given repo, branch and location.
|
||||
func (a *API) GetCodespacesMachines(ctx context.Context, repoID int, branch, location string, devcontainerPath string) ([]*Machine, error) {
|
||||
func (a *API) GetCodespacesMachines(ctx context.Context, repoID int64, branch, location string, devcontainerPath string) ([]*Machine, error) {
|
||||
reqURL := fmt.Sprintf("%s/repositories/%d/codespaces/machines", a.githubAPI, repoID)
|
||||
req, err := http.NewRequest(http.MethodGet, reqURL, nil)
|
||||
if err != nil {
|
||||
|
|
@ -642,7 +642,7 @@ func (a *API) GetCodespacesMachines(ctx context.Context, repoID int, branch, loc
|
|||
}
|
||||
|
||||
// GetCodespacesPermissionsCheck returns a bool indicating whether the user has accepted permissions for the given repo and devcontainer path.
|
||||
func (a *API) GetCodespacesPermissionsCheck(ctx context.Context, repoID int, branch string, devcontainerPath string) (bool, error) {
|
||||
func (a *API) GetCodespacesPermissionsCheck(ctx context.Context, repoID int64, branch string, devcontainerPath string) (bool, error) {
|
||||
reqURL := fmt.Sprintf("%s/repositories/%d/codespaces/permissions_check", a.githubAPI, repoID)
|
||||
req, err := http.NewRequest(http.MethodGet, reqURL, nil)
|
||||
if err != nil {
|
||||
|
|
@ -804,7 +804,7 @@ func (a *API) GetCodespaceBillableOwner(ctx context.Context, nwo string) (*User,
|
|||
|
||||
// CreateCodespaceParams are the required parameters for provisioning a Codespace.
|
||||
type CreateCodespaceParams struct {
|
||||
RepositoryID int
|
||||
RepositoryID int64
|
||||
IdleTimeoutMinutes int
|
||||
RetentionPeriodMinutes *int
|
||||
Branch string
|
||||
|
|
@ -855,7 +855,7 @@ func (a *API) CreateCodespace(ctx context.Context, params *CreateCodespaceParams
|
|||
}
|
||||
|
||||
type startCreateRequest struct {
|
||||
RepositoryID int `json:"repository_id"`
|
||||
RepositoryID int64 `json:"repository_id"`
|
||||
IdleTimeoutMinutes int `json:"idle_timeout_minutes,omitempty"`
|
||||
RetentionPeriodMinutes *int `json:"retention_period_minutes,omitempty"`
|
||||
Ref string `json:"ref"`
|
||||
|
|
@ -1009,7 +1009,7 @@ type DevContainerEntry struct {
|
|||
|
||||
// ListDevContainers returns a list of valid devcontainer.json files for the repo. Pass a negative limit to request all pages from
|
||||
// the API until all devcontainer.json files have been fetched.
|
||||
func (a *API) ListDevContainers(ctx context.Context, repoID int, branch string, limit int) (devcontainers []DevContainerEntry, err error) {
|
||||
func (a *API) ListDevContainers(ctx context.Context, repoID int64, branch string, limit int) (devcontainers []DevContainerEntry, err error) {
|
||||
perPage := 100
|
||||
if limit > 0 && limit < 100 {
|
||||
perPage = limit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue