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
12 changes: 6 additions & 6 deletions internal/codespaces/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/agent-task/capi/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ type Job struct {
}

type JobActor struct {
ID int `json:"id"`
ID int64 `json:"id"`
Login string `json:"login"`
}

type JobPullRequest struct {
ID int `json:"id"`
ID int64 `json:"id"`
Number int `json:"number"`
BaseRef string `json:"base_ref,omitempty"`
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/cache/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func deleteRun(opts *DeleteOptions) error {
}
}
for _, cache := range caches.ActionsCaches {
toDelete = append(toDelete, strconv.Itoa(cache.Id))
toDelete = append(toDelete, strconv.FormatInt(cache.Id, 10))
}
} else {
toDelete = append(toDelete, opts.Identifier)
Expand Down Expand Up @@ -201,7 +201,7 @@ func deleteCaches(opts *DeleteOptions, client *api.Client, repo ghrepo.Interface
return nil
}

func deleteCacheByID(client *api.Client, repo ghrepo.Interface, id int) error {
func deleteCacheByID(client *api.Client, repo ghrepo.Interface, id int64) error {
// returns HTTP 204 (NO CONTENT) on success
path := fmt.Sprintf("repos/%s/actions/caches/%d", ghrepo.FullName(repo), id)
return client.REST(repo.RepoHost(), "DELETE", path, nil, nil)
Expand All @@ -227,7 +227,7 @@ func deleteCacheByKey(client *api.Client, repo ghrepo.Interface, key, ref string
return payload.TotalCount, nil
}

func parseCacheID(arg string) (int, bool) {
id, err := strconv.Atoi(arg)
func parseCacheID(arg string) (int64, bool) {
id, err := strconv.ParseInt(arg, 10, 64)
return id, err == nil
}
2 changes: 1 addition & 1 deletion pkg/cmd/cache/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var CacheFields = []string{

type Cache struct {
CreatedAt time.Time `json:"created_at"`
Id int `json:"id"`
Id int64 `json:"id"`
Key string `json:"key"`
LastAccessedAt time.Time `json:"last_accessed_at"`
Ref string `json:"ref"`
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/codespace/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ type apiClient interface {
CreateCodespace(ctx context.Context, params *api.CreateCodespaceParams) (*api.Codespace, error)
EditCodespace(ctx context.Context, codespaceName string, params *api.EditCodespaceParams) (*api.Codespace, error)
GetRepository(ctx context.Context, nwo string) (*api.Repository, error)
GetCodespacesMachines(ctx context.Context, repoID int, branch string, location string, devcontainerPath string) ([]*api.Machine, error)
GetCodespacesPermissionsCheck(ctx context.Context, repoID int, branch string, devcontainerPath string) (bool, error)
GetCodespacesMachines(ctx context.Context, repoID int64, branch string, location string, devcontainerPath string) ([]*api.Machine, error)
GetCodespacesPermissionsCheck(ctx context.Context, repoID int64, branch string, devcontainerPath string) (bool, error)
GetCodespaceRepositoryContents(ctx context.Context, codespace *api.Codespace, path string) ([]byte, error)
ListDevContainers(ctx context.Context, repoID int, branch string, limit int) (devcontainers []api.DevContainerEntry, err error)
ListDevContainers(ctx context.Context, repoID int64, branch string, limit int) (devcontainers []api.DevContainerEntry, err error)
GetCodespaceRepoSuggestions(ctx context.Context, partialSearch string, params api.RepoSearchParameters) ([]string, error)
GetCodespaceBillableOwner(ctx context.Context, nwo string) (*api.User, error)
HTTPClient() (*http.Client, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/codespace/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func (a *App) showStatus(ctx context.Context, codespace *api.Codespace) error {
}

// getMachineName prompts the user to select the machine type, or validates the machine if non-empty.
func getMachineName(ctx context.Context, apiClient apiClient, prompter SurveyPrompter, repoID int, machine, branch, location string, devcontainerPath string) (string, error) {
func getMachineName(ctx context.Context, apiClient apiClient, prompter SurveyPrompter, repoID int64, machine, branch, location string, devcontainerPath string) (string, error) {
machines, err := apiClient.GetCodespacesMachines(ctx, repoID, branch, location, devcontainerPath)
if err != nil {
return "", fmt.Errorf("error requesting machine instance types: %w", err)
Expand Down
14 changes: 7 additions & 7 deletions pkg/cmd/codespace/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func TestApp_Create(t *testing.T) {
name: "create codespace with nonexistent machine results in error",
fields: fields{
apiClient: apiCreateDefaults(&apiClientMock{
GetCodespacesMachinesFunc: func(ctx context.Context, repoID int, branch, location string, devcontainerPath string) ([]*api.Machine, error) {
GetCodespacesMachinesFunc: func(ctx context.Context, repoID int64, branch, location string, devcontainerPath string) ([]*api.Machine, error) {
return []*api.Machine{
{
Name: "GIGA",
Expand Down Expand Up @@ -208,7 +208,7 @@ func TestApp_Create(t *testing.T) {
name: "create codespace with devcontainer path results in selecting the correct machine type",
fields: fields{
apiClient: apiCreateDefaults(&apiClientMock{
GetCodespacesMachinesFunc: func(ctx context.Context, repoID int, branch, location string, devcontainerPath string) ([]*api.Machine, error) {
GetCodespacesMachinesFunc: func(ctx context.Context, repoID int64, branch, location string, devcontainerPath string) ([]*api.Machine, error) {
if devcontainerPath == "" {
return []*api.Machine{
{
Expand Down Expand Up @@ -270,7 +270,7 @@ func TestApp_Create(t *testing.T) {
name: "create codespace with default branch with default devcontainer if no path provided and no devcontainer files exist in the repo",
fields: fields{
apiClient: apiCreateDefaults(&apiClientMock{
ListDevContainersFunc: func(ctx context.Context, repoID int, branch string, limit int) ([]api.DevContainerEntry, error) {
ListDevContainersFunc: func(ctx context.Context, repoID int64, branch string, limit int) ([]api.DevContainerEntry, error) {
return []api.DevContainerEntry{}, nil
},
CreateCodespaceFunc: func(ctx context.Context, params *api.CreateCodespaceParams) (*api.Codespace, error) {
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestApp_Create(t *testing.T) {
name: "returns error when getting devcontainer paths fails",
fields: fields{
apiClient: apiCreateDefaults(&apiClientMock{
ListDevContainersFunc: func(ctx context.Context, repoID int, branch string, limit int) ([]api.DevContainerEntry, error) {
ListDevContainersFunc: func(ctx context.Context, repoID int64, branch string, limit int) ([]api.DevContainerEntry, error) {
return nil, fmt.Errorf("some error")
},
}),
Expand Down Expand Up @@ -793,7 +793,7 @@ func TestHandleAdditionalPermissions(t *testing.T) {
CreateCodespaceFunc: func(ctx context.Context, params *api.CreateCodespaceParams) (*api.Codespace, error) {
return nil, tt.createCodespaceErr
},
GetCodespacesPermissionsCheckFunc: func(ctx context.Context, repoID int, branch string, devcontainerPath string) (bool, error) {
GetCodespacesPermissionsCheckFunc: func(ctx context.Context, repoID int64, branch string, devcontainerPath string) (bool, error) {
if tt.pollForPermissionsErr != nil {
return false, tt.pollForPermissionsErr
}
Expand Down Expand Up @@ -844,12 +844,12 @@ func apiCreateDefaults(c *apiClientMock) *apiClientMock {
}
}
if c.ListDevContainersFunc == nil {
c.ListDevContainersFunc = func(ctx context.Context, repoID int, branch string, limit int) ([]api.DevContainerEntry, error) {
c.ListDevContainersFunc = func(ctx context.Context, repoID int64, branch string, limit int) ([]api.DevContainerEntry, error) {
return []api.DevContainerEntry{{Path: ".devcontainer/devcontainer.json"}}, nil
}
}
if c.GetCodespacesMachinesFunc == nil {
c.GetCodespacesMachinesFunc = func(ctx context.Context, repoID int, branch, location string, devcontainerPath string) ([]*api.Machine, error) {
c.GetCodespacesMachinesFunc = func(ctx context.Context, repoID int64, branch, location string, devcontainerPath string) ([]*api.Machine, error) {
return []*api.Machine{
{
Name: "GIGA",
Expand Down
42 changes: 21 additions & 21 deletions pkg/cmd/codespace/mock_api.go

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

2 changes: 1 addition & 1 deletion pkg/cmd/gpg-key/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func deleteRun(opts *DeleteOptions) error {
id := ""
for _, gpgKey := range gpgKeys {
if gpgKey.KeyID == opts.KeyID {
id = strconv.Itoa(gpgKey.ID)
id = strconv.FormatInt(gpgKey.ID, 10)
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/gpg-key/delete/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

type gpgKey struct {
ID int
ID int64
KeyID string `json:"key_id"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/repo/autolink/shared/autolink.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package shared
import "github.com/cli/cli/v2/pkg/cmdutil"

type Autolink struct {
ID int `json:"id"`
ID int64 `json:"id"`
IsAlphanumeric bool `json:"is_alphanumeric"`
KeyPrefix string `json:"key_prefix"`
URLTemplate string `json:"url_template"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/repo/deploy-key/list/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

type deployKey struct {
ID int `json:"id"`
ID int64 `json:"id"`
Key string `json:"key"`
Title string `json:"title"`
CreatedAt time.Time `json:"created_at"`
Expand Down
Loading
Loading