Fix lint errors and bump golangci-lint to v2/action v9
CI / Test (linux/amd64) (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Cross-build (darwin/amd64) (push) Waiting to run
CI / Cross-build (linux/amd64) (push) Waiting to run
CI / Cross-build (darwin/arm64) (push) Waiting to run
CI / Cross-build (linux/arm64) (push) Waiting to run
CI / Test (linux/amd64) (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Cross-build (darwin/amd64) (push) Waiting to run
CI / Cross-build (linux/amd64) (push) Waiting to run
CI / Cross-build (darwin/arm64) (push) Waiting to run
CI / Cross-build (linux/arm64) (push) Waiting to run
- Migrate .golangci.yml to golangci-lint v2 config format - Bump golangci-lint-action from v6 (Node 20, deprecated) to v9 (Node 24) - Fix errcheck: check fmt.Fscanln and fmt.Sscanf return values - Fix ineffassign: replace unused vars with _ in test files - Fix revive unused-parameter: rename unused cmd/args/r/c params to _ - Fix revive empty-block: invert if condition in push command - Fix revive redefines-builtin-id: rename 'clear' to 'clearsigned' - Fix revive blank-imports: add comment on modernc.org/sqlite import - Fix unused: remove unused 'suite' and 'gen' fields from cache entry
This commit is contained in:
@@ -44,7 +44,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: '1.26'
|
go-version: '1.26'
|
||||||
cache: true
|
cache: true
|
||||||
- uses: golangci/golangci-lint-action@v6
|
- uses: golangci/golangci-lint-action@v9
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
|
|||||||
+28
-13
@@ -1,21 +1,36 @@
|
|||||||
|
version: "2"
|
||||||
run:
|
run:
|
||||||
timeout: 5m
|
go: "1.26"
|
||||||
go: "1.22"
|
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
disable-all: true
|
default: none
|
||||||
enable:
|
enable:
|
||||||
- errcheck
|
- errcheck
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- staticcheck
|
|
||||||
- unused
|
|
||||||
- misspell
|
- misspell
|
||||||
- revive
|
- revive
|
||||||
|
- staticcheck
|
||||||
issues:
|
- unused
|
||||||
exclude-rules:
|
exclusions:
|
||||||
- path: _test\.go
|
generated: lax
|
||||||
linters:
|
presets:
|
||||||
- errcheck
|
- comments
|
||||||
- revive
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
|
rules:
|
||||||
|
- linters:
|
||||||
|
- errcheck
|
||||||
|
- revive
|
||||||
|
path: _test\.go
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
formatters:
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func (r *Root) aptConfigCmd() *cobra.Command {
|
|||||||
Use: "apt-config <repo> <distro>",
|
Use: "apt-config <repo> <distro>",
|
||||||
Short: "Print apt client configuration (sources.list, key, and auth) for a repository",
|
Short: "Print apt client configuration (sources.list, key, and auth) for a repository",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
repoName, dist := args[0], args[1]
|
repoName, dist := args[0], args[1]
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func (r *Root) loginCmd() *cobra.Command {
|
|||||||
Use: "login [server]",
|
Use: "login [server]",
|
||||||
Short: "Log in to a urapt server and save an API token",
|
Short: "Log in to a urapt server and save an API token",
|
||||||
Args: cobra.MaximumNArgs(1),
|
Args: cobra.MaximumNArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
server := r.flagServer
|
server := r.flagServer
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
server = args[0]
|
server = args[0]
|
||||||
@@ -65,7 +65,7 @@ func (r *Root) logoutCmd() *cobra.Command {
|
|||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "logout",
|
Use: "logout",
|
||||||
Short: "Revoke the current API token and clear the saved profile",
|
Short: "Revoke the current API token and clear the saved profile",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, _ []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -86,7 +86,7 @@ func (r *Root) whoamiCmd() *cobra.Command {
|
|||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "whoami",
|
Use: "whoami",
|
||||||
Short: "Show the currently authenticated user",
|
Short: "Show the currently authenticated user",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, _ []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -111,7 +111,7 @@ func (r *Root) registerCmd() *cobra.Command {
|
|||||||
Use: "register [server]",
|
Use: "register [server]",
|
||||||
Short: "Create a new account on a urapt server (first account becomes admin)",
|
Short: "Create a new account on a urapt server (first account becomes admin)",
|
||||||
Args: cobra.MaximumNArgs(1),
|
Args: cobra.MaximumNArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
server := r.flagServer
|
server := r.flagServer
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
server = args[0]
|
server = args[0]
|
||||||
@@ -175,7 +175,7 @@ func (r *Root) tokenCreateCmd() *cobra.Command {
|
|||||||
c := &cobra.Command{
|
c := &cobra.Command{
|
||||||
Use: "create",
|
Use: "create",
|
||||||
Short: "Create a new API token",
|
Short: "Create a new API token",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, _ []string) error {
|
||||||
client, err := r.client()
|
client, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -202,7 +202,7 @@ func (r *Root) tokenListCmd() *cobra.Command {
|
|||||||
c := &cobra.Command{
|
c := &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "List your API tokens",
|
Short: "List your API tokens",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, _ []string) error {
|
||||||
client, err := r.client()
|
client, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -238,7 +238,7 @@ func (r *Root) tokenRevokeCmd() *cobra.Command {
|
|||||||
Use: "revoke <id>",
|
Use: "revoke <id>",
|
||||||
Short: "Revoke an API token by id",
|
Short: "Revoke an API token by id",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
client, err := r.client()
|
client, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func (r *Root) pushCmd() *cobra.Command {
|
|||||||
Use: "push <repo> <distro> <component> <file.deb>",
|
Use: "push <repo> <distro> <component> <file.deb>",
|
||||||
Short: "Upload a .deb package to a repository",
|
Short: "Upload a .deb package to a repository",
|
||||||
Args: cobra.ExactArgs(4),
|
Args: cobra.ExactArgs(4),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
repo, dist, component, file := args[0], args[1], args[2], args[3]
|
repo, dist, component, file := args[0], args[1], args[2], args[3]
|
||||||
|
|
||||||
// Local pre-validation for early, clear errors.
|
// Local pre-validation for early, clear errors.
|
||||||
@@ -31,9 +31,7 @@ func (r *Root) pushCmd() *cobra.Command {
|
|||||||
if archOverride != "" {
|
if archOverride != "" {
|
||||||
arch = archOverride
|
arch = archOverride
|
||||||
}
|
}
|
||||||
if r.flagJSON {
|
if !r.flagJSON {
|
||||||
// no-op: keep flag accepted
|
|
||||||
} else {
|
|
||||||
fmt.Printf("Pushing %s_%s_%s (%d bytes)\n", pkgName, ver, arch, inspected.Size)
|
fmt.Printf("Pushing %s_%s_%s (%d bytes)\n", pkgName, ver, arch, inspected.Size)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ func (r *Root) lsCmd() *cobra.Command {
|
|||||||
Use: "ls <repo> <distro>",
|
Use: "ls <repo> <distro>",
|
||||||
Short: "List packages in a repository/distribution",
|
Short: "List packages in a repository/distribution",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -106,7 +104,7 @@ func (r *Root) showCmd() *cobra.Command {
|
|||||||
Use: "show <repo> <id|name[@version][:arch]>",
|
Use: "show <repo> <id|name[@version][:arch]>",
|
||||||
Short: "Show package metadata",
|
Short: "Show package metadata",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -137,7 +135,7 @@ func (r *Root) pullCmd() *cobra.Command {
|
|||||||
Use: "pull <repo> <id|name[@version][:arch]>",
|
Use: "pull <repo> <id|name[@version][:arch]>",
|
||||||
Short: "Download a package's .deb file",
|
Short: "Download a package's .deb file",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -174,7 +172,7 @@ func (r *Root) rmCmd() *cobra.Command {
|
|||||||
Use: "rm <repo> <id|name[@version][:arch]>",
|
Use: "rm <repo> <id|name[@version][:arch]>",
|
||||||
Short: "Delete a package",
|
Short: "Delete a package",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+10
-10
@@ -33,7 +33,7 @@ func (r *Root) repoCreateCmd() *cobra.Command {
|
|||||||
Use: "create <name>",
|
Use: "create <name>",
|
||||||
Short: "Create a new repository",
|
Short: "Create a new repository",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
vis := visibility
|
vis := visibility
|
||||||
if public {
|
if public {
|
||||||
vis = "public"
|
vis = "public"
|
||||||
@@ -70,7 +70,7 @@ func (r *Root) repoListCmd() *cobra.Command {
|
|||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "List repositories visible to you",
|
Short: "List repositories visible to you",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, _ []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -101,7 +101,7 @@ func (r *Root) repoInfoCmd() *cobra.Command {
|
|||||||
Use: "info <name>",
|
Use: "info <name>",
|
||||||
Short: "Show details of a repository",
|
Short: "Show details of a repository",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -129,7 +129,7 @@ func (r *Root) repoSetVisibilityCmd() *cobra.Command {
|
|||||||
Use: "set-visibility <name>",
|
Use: "set-visibility <name>",
|
||||||
Short: "Change a repository's visibility",
|
Short: "Change a repository's visibility",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
vis := ""
|
vis := ""
|
||||||
if public {
|
if public {
|
||||||
vis = "public"
|
vis = "public"
|
||||||
@@ -165,7 +165,7 @@ func (r *Root) repoDeleteCmd() *cobra.Command {
|
|||||||
Use: "delete <name>",
|
Use: "delete <name>",
|
||||||
Short: "Delete a repository and all its packages",
|
Short: "Delete a repository and all its packages",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -185,7 +185,7 @@ func (r *Root) repoPubkeyCmd() *cobra.Command {
|
|||||||
Use: "pubkey <name>",
|
Use: "pubkey <name>",
|
||||||
Short: "Print the server's armored public key for a repository",
|
Short: "Print the server's armored public key for a repository",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -224,7 +224,7 @@ func (r *Root) repoMembersListCmd() *cobra.Command {
|
|||||||
Use: "list <repo>",
|
Use: "list <repo>",
|
||||||
Short: "List members of a repository",
|
Short: "List members of a repository",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -252,7 +252,7 @@ func (r *Root) repoMembersAddCmd() *cobra.Command {
|
|||||||
Use: "add <repo> <username>",
|
Use: "add <repo> <username>",
|
||||||
Short: "Grant a user access to a repository",
|
Short: "Grant a user access to a repository",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -279,7 +279,7 @@ func (r *Root) repoMembersUpdateCmd() *cobra.Command {
|
|||||||
Use: "update <repo> <username>",
|
Use: "update <repo> <username>",
|
||||||
Short: "Change a member's access level",
|
Short: "Change a member's access level",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -305,7 +305,7 @@ func (r *Root) repoMembersRemoveCmd() *cobra.Command {
|
|||||||
Use: "remove <repo> <username>",
|
Use: "remove <repo> <username>",
|
||||||
Short: "Revoke a user's access to a repository",
|
Short: "Revoke a user's access to a repository",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func (r *Root) distroCreateCmd() *cobra.Command {
|
|||||||
Use: "create <repo> <distro>",
|
Use: "create <repo> <distro>",
|
||||||
Short: "Add a distribution to a repository",
|
Short: "Add a distribution to a repository",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -46,7 +46,7 @@ func (r *Root) distroListCmd() *cobra.Command {
|
|||||||
Use: "list <repo>",
|
Use: "list <repo>",
|
||||||
Short: "List distributions in a repository",
|
Short: "List distributions in a repository",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -72,7 +72,7 @@ func (r *Root) distroDeleteCmd() *cobra.Command {
|
|||||||
Use: "delete <repo> <distro>",
|
Use: "delete <repo> <distro>",
|
||||||
Short: "Delete a distribution and its packages",
|
Short: "Delete a distribution and its packages",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -100,7 +100,7 @@ func (r *Root) componentCreateCmd() *cobra.Command {
|
|||||||
Use: "create <repo> <distro> <component>",
|
Use: "create <repo> <distro> <component>",
|
||||||
Short: "Add a component to a distribution",
|
Short: "Add a component to a distribution",
|
||||||
Args: cobra.ExactArgs(3),
|
Args: cobra.ExactArgs(3),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -124,7 +124,7 @@ func (r *Root) componentListCmd() *cobra.Command {
|
|||||||
Use: "list <repo> <distro>",
|
Use: "list <repo> <distro>",
|
||||||
Short: "List components in a distribution",
|
Short: "List components in a distribution",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -150,7 +150,7 @@ func (r *Root) componentDeleteCmd() *cobra.Command {
|
|||||||
Use: "delete <repo> <distro> <component>",
|
Use: "delete <repo> <distro> <component>",
|
||||||
Short: "Delete a component",
|
Short: "Delete a component",
|
||||||
Args: cobra.ExactArgs(3),
|
Args: cobra.ExactArgs(3),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -178,7 +178,7 @@ func (r *Root) archAddCmd() *cobra.Command {
|
|||||||
Use: "add <repo> <distro> <arch>",
|
Use: "add <repo> <distro> <arch>",
|
||||||
Short: "Add an architecture to a distribution",
|
Short: "Add an architecture to a distribution",
|
||||||
Args: cobra.ExactArgs(3),
|
Args: cobra.ExactArgs(3),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -202,7 +202,7 @@ func (r *Root) archListCmd() *cobra.Command {
|
|||||||
Use: "list <repo> <distro>",
|
Use: "list <repo> <distro>",
|
||||||
Short: "List architectures in a distribution",
|
Short: "List architectures in a distribution",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -228,7 +228,7 @@ func (r *Root) archRemoveCmd() *cobra.Command {
|
|||||||
Use: "remove <repo> <distro> <arch>",
|
Use: "remove <repo> <distro> <arch>",
|
||||||
Short: "Remove an architecture from a distribution",
|
Short: "Remove an architecture from a distribution",
|
||||||
Args: cobra.ExactArgs(3),
|
Args: cobra.ExactArgs(3),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
c, err := r.client()
|
c, err := r.client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ func (r *Root) versionCmd() *cobra.Command {
|
|||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Print the urapt CLI version",
|
Short: "Print the urapt CLI version",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(_ *cobra.Command, _ []string) {
|
||||||
fmt.Println(r.version)
|
fmt.Println(r.version)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func ReadLine(prompt string) (string, error) {
|
|||||||
func Confirm(prompt string) bool {
|
func Confirm(prompt string) bool {
|
||||||
fmt.Fprintf(os.Stderr, "%s [y/N]: ", prompt)
|
fmt.Fprintf(os.Stderr, "%s [y/N]: ", prompt)
|
||||||
var s string
|
var s string
|
||||||
fmt.Fscanln(os.Stdin, &s)
|
_, _ = fmt.Fscanln(os.Stdin, &s)
|
||||||
s = strings.ToLower(strings.TrimSpace(s))
|
s = strings.ToLower(strings.TrimSpace(s))
|
||||||
return s == "y" || s == "yes"
|
return s == "y" || s == "yes"
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-2
@@ -19,8 +19,6 @@ type IndexCache struct {
|
|||||||
|
|
||||||
type entry struct {
|
type entry struct {
|
||||||
indices *apt.Indices
|
indices *apt.Indices
|
||||||
suite *apt.Suite
|
|
||||||
gen int64
|
|
||||||
dirty bool
|
dirty bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ func TestRegisterFirstUserIsAdmin(t *testing.T) {
|
|||||||
h.token = resp.Token
|
h.token = resp.Token
|
||||||
|
|
||||||
// /me with token
|
// /me with token
|
||||||
code, body = h.do("GET", "/api/v1/me", h.token, nil)
|
code, _ = h.do("GET", "/api/v1/me", h.token, nil)
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
t.Fatalf("me status %d", code)
|
t.Fatalf("me status %d", code)
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ func TestLoginAndAuthFlow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create token
|
// create token
|
||||||
code, body = h.do("POST", "/api/v1/me/tokens", resp.Token, map[string]string{"name": "laptop"})
|
code, _ = h.do("POST", "/api/v1/me/tokens", resp.Token, map[string]string{"name": "laptop"})
|
||||||
if code != 201 {
|
if code != 201 {
|
||||||
t.Fatalf("create token status %d", code)
|
t.Fatalf("create token status %d", code)
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ func TestUsersAdminOnly(t *testing.T) {
|
|||||||
t.Fatalf("non-admin list users should be 403, got %d", code)
|
t.Fatalf("non-admin list users should be 403, got %d", code)
|
||||||
}
|
}
|
||||||
// admin can list users
|
// admin can list users
|
||||||
code, body = h.do("GET", "/api/v1/users", admin.Token, nil)
|
code, _ = h.do("GET", "/api/v1/users", admin.Token, nil)
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
t.Fatalf("admin list users should be 200, got %d", code)
|
t.Fatalf("admin list users should be 200, got %d", code)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ func TestPushPullDeletePackage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// list
|
// list
|
||||||
code, body = h.do("GET", "/api/v1/repositories/pkgrepo/distributions/stable/packages", owner.Token, nil)
|
code, _ = h.do("GET", "/api/v1/repositories/pkgrepo/distributions/stable/packages", owner.Token, nil)
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
t.Fatalf("list packages status %d", code)
|
t.Fatalf("list packages status %d", code)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func TestRepoCreateAndPermissions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// bob cannot see it (private, not a member)
|
// bob cannot see it (private, not a member)
|
||||||
code, body = h.do("GET", "/api/v1/repositories/myrepo", bob.Token, nil)
|
code, _ = h.do("GET", "/api/v1/repositories/myrepo", bob.Token, nil)
|
||||||
if code != 403 {
|
if code != 403 {
|
||||||
t.Fatalf("bob should be forbidden from private repo, got %d", code)
|
t.Fatalf("bob should be forbidden from private repo, got %d", code)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func (api *API) ServerInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ServerPubkey returns the ASCII-armored default signing key.
|
// ServerPubkey returns the ASCII-armored default signing key.
|
||||||
func (api *API) ServerPubkey(w http.ResponseWriter, r *http.Request) {
|
func (api *API) ServerPubkey(w http.ResponseWriter, _ *http.Request) {
|
||||||
if api.Signer == nil {
|
if api.Signer == nil {
|
||||||
httputil.WriteError(w, http.StatusServiceUnavailable, httputil.CodeInternal, "no signing key configured")
|
httputil.WriteError(w, http.StatusServiceUnavailable, httputil.CodeInternal, "no signing key configured")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -136,11 +136,11 @@ func TestListPackages_FiltersAndPagination(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter by arch (matches arch OR 'all').
|
// Filter by arch (matches arch OR 'all').
|
||||||
list, total, _ = s.ListPackages(ctx, repo.ID, d.ID, PackageFilters{Arch: "amd64"}, 1, 100)
|
_, total, _ = s.ListPackages(ctx, repo.ID, d.ID, PackageFilters{Arch: "amd64"}, 1, 100)
|
||||||
if total != 3 { // alpha, beta, delta
|
if total != 3 { // alpha, beta, delta
|
||||||
t.Fatalf("amd64 filter: expected 3, got %d", total)
|
t.Fatalf("amd64 filter: expected 3, got %d", total)
|
||||||
}
|
}
|
||||||
list, total, _ = s.ListPackages(ctx, repo.ID, d.ID, PackageFilters{Arch: "arm64"}, 1, 100)
|
_, total, _ = s.ListPackages(ctx, repo.ID, d.ID, PackageFilters{Arch: "arm64"}, 1, 100)
|
||||||
if total != 2 { // gamma, epsilon
|
if total != 2 { // gamma, epsilon
|
||||||
t.Fatalf("arm64 filter: expected 2, got %d", total)
|
t.Fatalf("arm64 filter: expected 2, got %d", total)
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ func TestListPackages_FiltersAndPagination(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Query (LIKE on name/description).
|
// Query (LIKE on name/description).
|
||||||
list, total, _ = s.ListPackages(ctx, repo.ID, d.ID, PackageFilters{Query: "a test"}, 1, 100)
|
_, total, _ = s.ListPackages(ctx, repo.ID, d.ID, PackageFilters{Query: "a test"}, 1, 100)
|
||||||
if total != 5 {
|
if total != 5 {
|
||||||
t.Fatalf("query filter: expected all 5 to match description, got %d", total)
|
t.Fatalf("query filter: expected all 5 to match description, got %d", total)
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ func TestListPackages_FiltersAndPagination(t *testing.T) {
|
|||||||
t.Fatalf("page 1: total=%d len=%d", total, len(list))
|
t.Fatalf("page 1: total=%d len=%d", total, len(list))
|
||||||
}
|
}
|
||||||
// page 3 -> only 1 item.
|
// page 3 -> only 1 item.
|
||||||
list, total, _ = s.ListPackages(ctx, repo.ID, d.ID, PackageFilters{}, 3, 2)
|
list, _, _ = s.ListPackages(ctx, repo.ID, d.ID, PackageFilters{}, 3, 2)
|
||||||
if len(list) != 1 {
|
if len(list) != 1 {
|
||||||
t.Fatalf("page 3: expected 1 item, got %d", len(list))
|
t.Fatalf("page 3: expected 1 item, got %d", len(list))
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -115,11 +115,11 @@ func Generate(s *Suite, signer Signer) (*Indices, error) {
|
|||||||
idx.Release = release
|
idx.Release = release
|
||||||
|
|
||||||
if signer != nil {
|
if signer != nil {
|
||||||
clear, err := signer.ClearSign(release)
|
clearsigned, err := signer.ClearSign(release)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("clearsign: %w", err)
|
return nil, fmt.Errorf("clearsign: %w", err)
|
||||||
}
|
}
|
||||||
idx.InRelease = clear
|
idx.InRelease = clearsigned
|
||||||
det, err := signer.DetachedSign(release)
|
det, err := signer.DetachedSign(release)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("detach sign: %w", err)
|
return nil, fmt.Errorf("detach sign: %w", err)
|
||||||
|
|||||||
@@ -190,13 +190,13 @@ func (c *Config) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func set(c *Config, env string, dst *string) {
|
func set(_ *Config, env string, dst *string) {
|
||||||
if v, ok := os.LookupEnv(env); ok && v != "" {
|
if v, ok := os.LookupEnv(env); ok && v != "" {
|
||||||
*dst = v
|
*dst = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setInt(c *Config, env string, dst *int) {
|
func setInt(_ *Config, env string, dst *int) {
|
||||||
if v, ok := os.LookupEnv(env); ok && v != "" {
|
if v, ok := os.LookupEnv(env); ok && v != "" {
|
||||||
if n, err := strconv.Atoi(v); err == nil {
|
if n, err := strconv.Atoi(v); err == nil {
|
||||||
*dst = n
|
*dst = n
|
||||||
@@ -204,7 +204,7 @@ func setInt(c *Config, env string, dst *int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setInt64(c *Config, env string, dst *int64) {
|
func setInt64(_ *Config, env string, dst *int64) {
|
||||||
if v, ok := os.LookupEnv(env); ok && v != "" {
|
if v, ok := os.LookupEnv(env); ok && v != "" {
|
||||||
if n, err := strconv.ParseInt(v, 10, 64); err == nil {
|
if n, err := strconv.ParseInt(v, 10, 64); err == nil {
|
||||||
*dst = n
|
*dst = n
|
||||||
@@ -212,7 +212,7 @@ func setInt64(c *Config, env string, dst *int64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setBool(c *Config, env string, dst *bool) {
|
func setBool(_ *Config, env string, dst *bool) {
|
||||||
if v, ok := os.LookupEnv(env); ok && v != "" {
|
if v, ok := os.LookupEnv(env); ok && v != "" {
|
||||||
if b, err := strconv.ParseBool(v); err == nil {
|
if b, err := strconv.ParseBool(v); err == nil {
|
||||||
*dst = b
|
*dst = b
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite" // register the pure-Go SQLite driver
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed all:migrations
|
//go:embed all:migrations
|
||||||
|
|||||||
+3
-1
@@ -164,7 +164,9 @@ func readAR(r io.Reader) ([]arMember, error) {
|
|||||||
name = strings.TrimSuffix(name, "/")
|
name = strings.TrimSuffix(name, "/")
|
||||||
sizeStr := strings.TrimSpace(string(header[48:58]))
|
sizeStr := strings.TrimSpace(string(header[48:58]))
|
||||||
var size int64
|
var size int64
|
||||||
fmt.Sscanf(sizeStr, "%d", &size)
|
if _, err := fmt.Sscanf(sizeStr, "%d", &size); err != nil {
|
||||||
|
return nil, fmt.Errorf("parse ar member size %q: %w", sizeStr, err)
|
||||||
|
}
|
||||||
if size < 0 {
|
if size < 0 {
|
||||||
return nil, fmt.Errorf("negative ar member size")
|
return nil, fmt.Errorf("negative ar member size")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user