As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit b9462594 authored by Archish's avatar Archish
Browse files

Lint fixes for authorized keys and principal packages

parent cffe8fc0
No related branches found
No related tags found
No related merge requests found
// Package authorizedkeys handles fetching and printing authorized SSH keys.
package authorizedkeys
import (
Loading
Loading
@@ -12,12 +13,14 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/keyline"
)
// Command contains the configuration, arguments, and I/O interfaces.
type Command struct {
Config *config.Config
Args *commandargs.AuthorizedKeys
ReadWriter *readwriter.ReadWriter
}
// Execute runs the command to fetch and print the authorized SSH key.
func (c *Command) Execute(ctx context.Context) (context.Context, error) {
// Do and return nothing when the expected and actual user don't match.
// This can happen when the user in sshd_config doesn't match the user
Loading
Loading
@@ -38,7 +41,7 @@ func (c *Command) Execute(ctx context.Context) (context.Context, error) {
func (c *Command) printKeyLine(ctx context.Context) error {
response, err := c.getAuthorizedKey(ctx)
if err != nil {
fmt.Fprintln(c.ReadWriter.Out, fmt.Sprintf("# No key was found for %s", c.Args.Key))
_, _ = fmt.Fprintf(c.ReadWriter.Out, "# No key was found for %s\n", c.Args.Key)
return nil
}
Loading
Loading
@@ -47,7 +50,7 @@ func (c *Command) printKeyLine(ctx context.Context) error {
return err
}
fmt.Fprintln(c.ReadWriter.Out, keyLine.ToString())
_, _ = fmt.Fprintln(c.ReadWriter.Out, keyLine.ToString())
return nil
}
Loading
Loading
// Package authorizedprincipals handles printing authorized principals in GitLab Shell.
package authorizedprincipals
import (
Loading
Loading
@@ -10,12 +11,14 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/keyline"
)
// Command contains the configuration, arguments, and I/O interfaces.
type Command struct {
Config *config.Config
Args *commandargs.AuthorizedPrincipals
ReadWriter *readwriter.ReadWriter
}
// Execute runs the command to print authorized principals.
func (c *Command) Execute(ctx context.Context) (context.Context, error) {
if err := c.printPrincipalLines(); err != nil {
return ctx, err
Loading
Loading
@@ -42,7 +45,7 @@ func (c *Command) printPrincipalLine(principal string) error {
return err
}
fmt.Fprintln(c.ReadWriter.Out, principalKeyLine.ToString())
_, _ = fmt.Fprintln(c.ReadWriter.Out, principalKeyLine.ToString())
return nil
}
Loading
Loading
@@ -78,16 +78,7 @@ cmd/gitlab-sshd/main.go:30:5: var-naming: var gitlabUrl should be gitlabURL (rev
cmd/gitlab-sshd/main.go:44: Function 'main' is too long (73 > 60) (funlen)
cmd/gitlab-sshd/main.go:70:23: Error return value of `logCloser.Close` is not checked (errcheck)
cmd/gitlab-sshd/main.go:108:18: Error return value of `server.Shutdown` is not checked (errcheck)
internal/command/authorizedkeys/authorized_keys.go:1:1: package-comments: should have a package comment (revive)
internal/command/authorizedkeys/authorized_keys.go:15:6: exported: exported type Command should have comment or be unexported (revive)
internal/command/authorizedkeys/authorized_keys.go:21:1: exported: exported method Command.Execute should have comment or be unexported (revive)
internal/command/authorizedkeys/authorized_keys.go:26: internal/command/authorizedkeys/authorized_keys.go:26: Line contains TODO/BUG/FIXME/NOTE/OPTIMIZE/HACK: "TODO: Log this event once we have a cons..." (godox)
internal/command/authorizedkeys/authorized_keys.go:41:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
internal/command/authorizedkeys/authorized_keys.go:50:14: Error return value of `fmt.Fprintln` is not checked (errcheck)
internal/command/authorizedprincipals/authorized_principals.go:1:1: package-comments: should have a package comment (revive)
internal/command/authorizedprincipals/authorized_principals.go:13:6: exported: exported type Command should have comment or be unexported (revive)
internal/command/authorizedprincipals/authorized_principals.go:19:1: exported: exported method Command.Execute should have comment or be unexported (revive)
internal/command/authorizedprincipals/authorized_principals.go:45:14: Error return value of `fmt.Fprintln` is not checked (errcheck)
internal/command/authorizedkeys/authorized_keys.go:29: internal/command/authorizedkeys/authorized_keys.go:29: Line contains TODO/BUG/FIXME/NOTE/OPTIMIZE/HACK: "TODO: Log this event once we have a cons..." (godox)
internal/command/command.go:1:1: package-comments: should have a package comment (revive)
internal/command/command.go:15:6: exported: exported type Command should have comment or be unexported (revive)
internal/command/command.go:19:6: exported: exported type LogMetadata should have comment or be unexported (revive)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment