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
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
|||
2
pkg/cmd/cache/delete/delete.go
vendored
2
pkg/cmd/cache/delete/delete.go
vendored
|
|
@ -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)
|
||||
|
|
|
|||
2
pkg/cmd/cache/shared/shared.go
vendored
2
pkg/cmd/cache/shared/shared.go
vendored
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
@ -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{
|
||||
{
|
||||
|
|
@ -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) {
|
||||
|
|
@ -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")
|
||||
},
|
||||
}),
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ import (
|
|||
// GetCodespaceRepositoryContentsFunc: func(ctx context.Context, codespace *codespacesAPI.Codespace, path string) ([]byte, error) {
|
||||
// panic("mock out the GetCodespaceRepositoryContents method")
|
||||
// },
|
||||
// GetCodespacesMachinesFunc: func(ctx context.Context, repoID int, branch string, location string, devcontainerPath string) ([]*codespacesAPI.Machine, error) {
|
||||
// GetCodespacesMachinesFunc: func(ctx context.Context, repoID int64, branch string, location string, devcontainerPath string) ([]*codespacesAPI.Machine, error) {
|
||||
// panic("mock out the GetCodespacesMachines method")
|
||||
// },
|
||||
// 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) {
|
||||
// panic("mock out the GetCodespacesPermissionsCheck method")
|
||||
// },
|
||||
// GetOrgMemberCodespaceFunc: func(ctx context.Context, orgName string, userName string, codespaceName string) (*codespacesAPI.Codespace, error) {
|
||||
|
|
@ -59,7 +59,7 @@ import (
|
|||
// ListCodespacesFunc: func(ctx context.Context, opts codespacesAPI.ListCodespacesOptions) ([]*codespacesAPI.Codespace, error) {
|
||||
// panic("mock out the ListCodespaces method")
|
||||
// },
|
||||
// ListDevContainersFunc: func(ctx context.Context, repoID int, branch string, limit int) ([]codespacesAPI.DevContainerEntry, error) {
|
||||
// ListDevContainersFunc: func(ctx context.Context, repoID int64, branch string, limit int) ([]codespacesAPI.DevContainerEntry, error) {
|
||||
// panic("mock out the ListDevContainers method")
|
||||
// },
|
||||
// ServerURLFunc: func() string {
|
||||
|
|
@ -100,10 +100,10 @@ type apiClientMock struct {
|
|||
GetCodespaceRepositoryContentsFunc func(ctx context.Context, codespace *codespacesAPI.Codespace, path string) ([]byte, error)
|
||||
|
||||
// GetCodespacesMachinesFunc mocks the GetCodespacesMachines method.
|
||||
GetCodespacesMachinesFunc func(ctx context.Context, repoID int, branch string, location string, devcontainerPath string) ([]*codespacesAPI.Machine, error)
|
||||
GetCodespacesMachinesFunc func(ctx context.Context, repoID int64, branch string, location string, devcontainerPath string) ([]*codespacesAPI.Machine, error)
|
||||
|
||||
// GetCodespacesPermissionsCheckFunc mocks the GetCodespacesPermissionsCheck method.
|
||||
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)
|
||||
|
||||
// GetOrgMemberCodespaceFunc mocks the GetOrgMemberCodespace method.
|
||||
GetOrgMemberCodespaceFunc func(ctx context.Context, orgName string, userName string, codespaceName string) (*codespacesAPI.Codespace, error)
|
||||
|
|
@ -121,7 +121,7 @@ type apiClientMock struct {
|
|||
ListCodespacesFunc func(ctx context.Context, opts codespacesAPI.ListCodespacesOptions) ([]*codespacesAPI.Codespace, error)
|
||||
|
||||
// ListDevContainersFunc mocks the ListDevContainers method.
|
||||
ListDevContainersFunc func(ctx context.Context, repoID int, branch string, limit int) ([]codespacesAPI.DevContainerEntry, error)
|
||||
ListDevContainersFunc func(ctx context.Context, repoID int64, branch string, limit int) ([]codespacesAPI.DevContainerEntry, error)
|
||||
|
||||
// ServerURLFunc mocks the ServerURL method.
|
||||
ServerURLFunc func() string
|
||||
|
|
@ -200,7 +200,7 @@ type apiClientMock struct {
|
|||
// Ctx is the ctx argument value.
|
||||
Ctx context.Context
|
||||
// RepoID is the repoID argument value.
|
||||
RepoID int
|
||||
RepoID int64
|
||||
// Branch is the branch argument value.
|
||||
Branch string
|
||||
// Location is the location argument value.
|
||||
|
|
@ -213,7 +213,7 @@ type apiClientMock struct {
|
|||
// Ctx is the ctx argument value.
|
||||
Ctx context.Context
|
||||
// RepoID is the repoID argument value.
|
||||
RepoID int
|
||||
RepoID int64
|
||||
// Branch is the branch argument value.
|
||||
Branch string
|
||||
// DevcontainerPath is the devcontainerPath argument value.
|
||||
|
|
@ -257,7 +257,7 @@ type apiClientMock struct {
|
|||
// Ctx is the ctx argument value.
|
||||
Ctx context.Context
|
||||
// RepoID is the repoID argument value.
|
||||
RepoID int
|
||||
RepoID int64
|
||||
// Branch is the branch argument value.
|
||||
Branch string
|
||||
// Limit is the limit argument value.
|
||||
|
|
@ -582,13 +582,13 @@ func (mock *apiClientMock) GetCodespaceRepositoryContentsCalls() []struct {
|
|||
}
|
||||
|
||||
// GetCodespacesMachines calls GetCodespacesMachinesFunc.
|
||||
func (mock *apiClientMock) GetCodespacesMachines(ctx context.Context, repoID int, branch string, location string, devcontainerPath string) ([]*codespacesAPI.Machine, error) {
|
||||
func (mock *apiClientMock) GetCodespacesMachines(ctx context.Context, repoID int64, branch string, location string, devcontainerPath string) ([]*codespacesAPI.Machine, error) {
|
||||
if mock.GetCodespacesMachinesFunc == nil {
|
||||
panic("apiClientMock.GetCodespacesMachinesFunc: method is nil but apiClient.GetCodespacesMachines was just called")
|
||||
}
|
||||
callInfo := struct {
|
||||
Ctx context.Context
|
||||
RepoID int
|
||||
RepoID int64
|
||||
Branch string
|
||||
Location string
|
||||
DevcontainerPath string
|
||||
|
|
@ -611,14 +611,14 @@ func (mock *apiClientMock) GetCodespacesMachines(ctx context.Context, repoID int
|
|||
// len(mockedapiClient.GetCodespacesMachinesCalls())
|
||||
func (mock *apiClientMock) GetCodespacesMachinesCalls() []struct {
|
||||
Ctx context.Context
|
||||
RepoID int
|
||||
RepoID int64
|
||||
Branch string
|
||||
Location string
|
||||
DevcontainerPath string
|
||||
} {
|
||||
var calls []struct {
|
||||
Ctx context.Context
|
||||
RepoID int
|
||||
RepoID int64
|
||||
Branch string
|
||||
Location string
|
||||
DevcontainerPath string
|
||||
|
|
@ -630,13 +630,13 @@ func (mock *apiClientMock) GetCodespacesMachinesCalls() []struct {
|
|||
}
|
||||
|
||||
// GetCodespacesPermissionsCheck calls GetCodespacesPermissionsCheckFunc.
|
||||
func (mock *apiClientMock) GetCodespacesPermissionsCheck(ctx context.Context, repoID int, branch string, devcontainerPath string) (bool, error) {
|
||||
func (mock *apiClientMock) GetCodespacesPermissionsCheck(ctx context.Context, repoID int64, branch string, devcontainerPath string) (bool, error) {
|
||||
if mock.GetCodespacesPermissionsCheckFunc == nil {
|
||||
panic("apiClientMock.GetCodespacesPermissionsCheckFunc: method is nil but apiClient.GetCodespacesPermissionsCheck was just called")
|
||||
}
|
||||
callInfo := struct {
|
||||
Ctx context.Context
|
||||
RepoID int
|
||||
RepoID int64
|
||||
Branch string
|
||||
DevcontainerPath string
|
||||
}{
|
||||
|
|
@ -657,13 +657,13 @@ func (mock *apiClientMock) GetCodespacesPermissionsCheck(ctx context.Context, re
|
|||
// len(mockedapiClient.GetCodespacesPermissionsCheckCalls())
|
||||
func (mock *apiClientMock) GetCodespacesPermissionsCheckCalls() []struct {
|
||||
Ctx context.Context
|
||||
RepoID int
|
||||
RepoID int64
|
||||
Branch string
|
||||
DevcontainerPath string
|
||||
} {
|
||||
var calls []struct {
|
||||
Ctx context.Context
|
||||
RepoID int
|
||||
RepoID int64
|
||||
Branch string
|
||||
DevcontainerPath string
|
||||
}
|
||||
|
|
@ -849,13 +849,13 @@ func (mock *apiClientMock) ListCodespacesCalls() []struct {
|
|||
}
|
||||
|
||||
// ListDevContainers calls ListDevContainersFunc.
|
||||
func (mock *apiClientMock) ListDevContainers(ctx context.Context, repoID int, branch string, limit int) ([]codespacesAPI.DevContainerEntry, error) {
|
||||
func (mock *apiClientMock) ListDevContainers(ctx context.Context, repoID int64, branch string, limit int) ([]codespacesAPI.DevContainerEntry, error) {
|
||||
if mock.ListDevContainersFunc == nil {
|
||||
panic("apiClientMock.ListDevContainersFunc: method is nil but apiClient.ListDevContainers was just called")
|
||||
}
|
||||
callInfo := struct {
|
||||
Ctx context.Context
|
||||
RepoID int
|
||||
RepoID int64
|
||||
Branch string
|
||||
Limit int
|
||||
}{
|
||||
|
|
@ -876,13 +876,13 @@ func (mock *apiClientMock) ListDevContainers(ctx context.Context, repoID int, br
|
|||
// len(mockedapiClient.ListDevContainersCalls())
|
||||
func (mock *apiClientMock) ListDevContainersCalls() []struct {
|
||||
Ctx context.Context
|
||||
RepoID int
|
||||
RepoID int64
|
||||
Branch string
|
||||
Limit int
|
||||
} {
|
||||
var calls []struct {
|
||||
Ctx context.Context
|
||||
RepoID int
|
||||
RepoID int64
|
||||
Branch string
|
||||
Limit int
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type gpgKey struct {
|
||||
ID int
|
||||
ID int64
|
||||
KeyID string `json:"key_id"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func listRun(opts *ListOptions) error {
|
|||
now := time.Now()
|
||||
|
||||
for _, deployKey := range deployKeys {
|
||||
sshID := strconv.Itoa(deployKey.ID)
|
||||
sshID := strconv.FormatInt(deployKey.ID, 10)
|
||||
t.AddField(sshID)
|
||||
t.AddField(deployKey.Title)
|
||||
sshType := "read-only"
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ func listRun(opts *ListOptions) error {
|
|||
tp := tableprinter.New(opts.IO, tableprinter.WithHeader("ID", "NAME", "SOURCE", "STATUS", "RULES"))
|
||||
|
||||
for _, rs := range result.Rulesets {
|
||||
tp.AddField(strconv.Itoa(rs.DatabaseId), tableprinter.WithColor(cs.Cyan))
|
||||
tp.AddField(strconv.FormatInt(rs.DatabaseId, 10), tableprinter.WithColor(cs.Cyan))
|
||||
tp.AddField(rs.Name, tableprinter.WithColor(cs.Bold))
|
||||
tp.AddField(shared.RulesetSource(rs))
|
||||
tp.AddField(strings.ToLower(rs.Enforcement))
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
type RulesetGraphQL struct {
|
||||
DatabaseId int
|
||||
DatabaseId int64
|
||||
Name string
|
||||
Target string
|
||||
Enforcement string
|
||||
|
|
@ -24,13 +24,13 @@ type RulesetGraphQL struct {
|
|||
}
|
||||
|
||||
type RulesetREST struct {
|
||||
Id int
|
||||
Id int64
|
||||
Name string
|
||||
Target string
|
||||
Enforcement string
|
||||
CurrentUserCanBypass string `json:"current_user_can_bypass"`
|
||||
BypassActors []struct {
|
||||
ActorId int `json:"actor_id"`
|
||||
ActorId int64 `json:"actor_id"`
|
||||
ActorType string `json:"actor_type"`
|
||||
BypassMode string `json:"bypass_mode"`
|
||||
} `json:"bypass_actors"`
|
||||
|
|
@ -50,7 +50,7 @@ type RulesetRule struct {
|
|||
Parameters map[string]interface{}
|
||||
RulesetSourceType string `json:"ruleset_source_type"`
|
||||
RulesetSource string `json:"ruleset_source"`
|
||||
RulesetId int `json:"ruleset_id"`
|
||||
RulesetId int64 `json:"ruleset_id"`
|
||||
}
|
||||
|
||||
// Returns the source of the ruleset in the format "owner/name (repo)" or "owner (org)"
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ func viewRun(opts *ViewOptions) error {
|
|||
}
|
||||
|
||||
if rs != nil {
|
||||
opts.ID = strconv.Itoa(rs.DatabaseId)
|
||||
opts.ID = strconv.FormatInt(rs.DatabaseId, 10)
|
||||
|
||||
// can't get a ruleset lower in the chain than what was queried, so no need to handle repos here
|
||||
if rs.Source.TypeName == "Organization" {
|
||||
|
|
@ -185,7 +185,7 @@ func viewRun(opts *ViewOptions) error {
|
|||
}
|
||||
|
||||
fmt.Fprintf(w, "\n%s\n", cs.Bold(rs.Name))
|
||||
fmt.Fprintf(w, "ID: %s\n", cs.Cyan(strconv.Itoa(rs.Id)))
|
||||
fmt.Fprintf(w, "ID: %s\n", cs.Cyan(strconv.FormatInt(rs.Id, 10)))
|
||||
fmt.Fprintf(w, "Source: %s (%s)\n", rs.Source, rs.SourceType)
|
||||
|
||||
fmt.Fprint(w, "Enforcement: ")
|
||||
|
|
@ -262,7 +262,7 @@ func selectRulesetID(rsList *shared.RulesetList, p prompter.Prompter, cs *iostre
|
|||
for i, rs := range rsList.Rulesets {
|
||||
s := fmt.Sprintf(
|
||||
"%s: %s | %s | contains %s | configured in %s",
|
||||
cs.Cyan(strconv.Itoa(rs.DatabaseId)),
|
||||
cs.Cyan(strconv.FormatInt(rs.DatabaseId, 10)),
|
||||
rs.Name,
|
||||
strings.ToLower(rs.Enforcement),
|
||||
text.Pluralize(rs.Rules.TotalCount, "rule"),
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ type tagEntry struct {
|
|||
|
||||
// rulesetsResponse is a single ruleset from the rulesets API.
|
||||
type rulesetsResponse struct {
|
||||
ID int `json:"id"`
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Target string `json:"target"`
|
||||
Enforcement string `json:"enforcement"`
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ func listRun(opts *ListOptions) error {
|
|||
now := time.Now()
|
||||
|
||||
for _, sshKey := range sshKeys {
|
||||
id := strconv.Itoa(sshKey.ID)
|
||||
id := strconv.FormatInt(sshKey.ID, 10)
|
||||
if t.IsTTY() {
|
||||
t.AddField(sshKey.Title)
|
||||
t.AddField(id)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ const (
|
|||
)
|
||||
|
||||
type sshKey struct {
|
||||
ID int
|
||||
ID int64
|
||||
Key string
|
||||
Title string
|
||||
Type string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue