From 5b3806ff55fab742b22c0a2ff3b4d891d1c45704 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Fri, 16 May 2025 10:59:23 +0200 Subject: [PATCH] Fix linting issues. --- cmd/api/v1/methods.go | 2 +- cmd/api/v1/project.go | 8 ++++---- cmd/api/v1/tenant.go | 8 ++++---- cmd/api/v1/token.go | 8 ++++---- cmd/context.go | 14 +++++++------- cmd/login.go | 2 +- cmd/logout.go | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/cmd/api/v1/methods.go b/cmd/api/v1/methods.go index 3471bed..5fd8f3e 100644 --- a/cmd/api/v1/methods.go +++ b/cmd/api/v1/methods.go @@ -47,7 +47,7 @@ func newMethodsCmd(c *config.Config) *cobra.Command { sort.Strings(methods) for _, method := range methods { - fmt.Fprintln(c.Out, method) + _, _ = fmt.Fprintln(c.Out, method) } return nil diff --git a/cmd/api/v1/project.go b/cmd/api/v1/project.go index 37f1e4a..a4fc714 100644 --- a/cmd/api/v1/project.go +++ b/cmd/api/v1/project.go @@ -325,7 +325,7 @@ func (c *project) join(args []string) error { return fmt.Errorf("failed to join project: %w", err) } - fmt.Fprintf(c.c.Out, "%s successfully joined project \"%s\"\n", color.GreenString("✔"), color.GreenString(acceptResp.Msg.ProjectName)) + _, _ = fmt.Fprintf(c.c.Out, "%s successfully joined project \"%s\"\n", color.GreenString("✔"), color.GreenString(acceptResp.Msg.ProjectName)) return nil } @@ -347,8 +347,8 @@ func (c *project) generateInvite() error { return fmt.Errorf("failed to generate an invite: %w", err) } - fmt.Fprintf(c.c.Out, "You can share this secret with the member to join, it expires in %s:\n\n", humanize.Time(resp.Msg.Invite.ExpiresAt.AsTime())) - fmt.Fprintf(c.c.Out, "%s (https://console.metal-stack.io/project-invite/%s)\n", resp.Msg.Invite.Secret, resp.Msg.Invite.Secret) + _, _ = fmt.Fprintf(c.c.Out, "You can share this secret with the member to join, it expires in %s:\n\n", humanize.Time(resp.Msg.Invite.ExpiresAt.AsTime())) + _, _ = fmt.Fprintf(c.c.Out, "%s (https://console.metal-stack.io/project-invite/%s)\n", resp.Msg.Invite.Secret, resp.Msg.Invite.Secret) return nil } @@ -409,7 +409,7 @@ func (c *project) removeMember(args []string) error { return fmt.Errorf("failed to remove member from project: %w", err) } - fmt.Fprintf(c.c.Out, "%s successfully removed member %q\n", color.GreenString("✔"), member) + _, _ = fmt.Fprintf(c.c.Out, "%s successfully removed member %q\n", color.GreenString("✔"), member) return nil } diff --git a/cmd/api/v1/tenant.go b/cmd/api/v1/tenant.go index ea564db..d7bc015 100644 --- a/cmd/api/v1/tenant.go +++ b/cmd/api/v1/tenant.go @@ -306,7 +306,7 @@ func (c *tenant) join(args []string) error { return fmt.Errorf("failed to join tenant: %w", err) } - fmt.Fprintf(c.c.Out, "%s successfully joined tenant \"%s\"\n", color.GreenString("✔"), color.GreenString(acceptResp.Msg.TenantName)) + _, _ = fmt.Fprintf(c.c.Out, "%s successfully joined tenant \"%s\"\n", color.GreenString("✔"), color.GreenString(acceptResp.Msg.TenantName)) return nil } @@ -328,8 +328,8 @@ func (c *tenant) generateInvite() error { return fmt.Errorf("failed to generate an invite: %w", err) } - fmt.Fprintf(c.c.Out, "You can share this secret with the member to join, it expires in %s:\n\n", humanize.Time(resp.Msg.Invite.ExpiresAt.AsTime())) - fmt.Fprintf(c.c.Out, "%s (https://console.metal-stack.io/organization-invite/%s)\n", resp.Msg.Invite.Secret, resp.Msg.Invite.Secret) + _, _ = fmt.Fprintf(c.c.Out, "You can share this secret with the member to join, it expires in %s:\n\n", humanize.Time(resp.Msg.Invite.ExpiresAt.AsTime())) + _, _ = fmt.Fprintf(c.c.Out, "%s (https://console.metal-stack.io/organization-invite/%s)\n", resp.Msg.Invite.Secret, resp.Msg.Invite.Secret) return nil } @@ -405,7 +405,7 @@ func (c *tenant) removeMember(args []string) error { return fmt.Errorf("failed to remove member from tenant: %w", err) } - fmt.Fprintf(c.c.Out, "%s successfully removed member %q\n", color.GreenString("✔"), member) + _, _ = fmt.Fprintf(c.c.Out, "%s successfully removed member %q\n", color.GreenString("✔"), member) return nil } diff --git a/cmd/api/v1/token.go b/cmd/api/v1/token.go index 0ebc753..3925ff5 100644 --- a/cmd/api/v1/token.go +++ b/cmd/api/v1/token.go @@ -159,10 +159,10 @@ func (c *token) Create(rq *apiv2.TokenServiceCreateRequest) (*apiv2.Token, error return nil, err } - fmt.Fprintf(c.c.Out, "Make sure to copy your personal access token now as you will not be able to see this again.\n") - fmt.Fprintln(c.c.Out) - fmt.Fprintln(c.c.Out, resp.Msg.GetSecret()) - fmt.Fprintln(c.c.Out) + _, _ = fmt.Fprintf(c.c.Out, "Make sure to copy your personal access token now as you will not be able to see this again.\n") + _, _ = fmt.Fprintln(c.c.Out) + _, _ = fmt.Fprintln(c.c.Out, resp.Msg.GetSecret()) + _, _ = fmt.Fprintln(c.c.Out) // TODO: allow printer in metal-lib to be silenced diff --git a/cmd/context.go b/cmd/context.go index 2f0a8e4..b047571 100644 --- a/cmd/context.go +++ b/cmd/context.go @@ -144,7 +144,7 @@ func (c *ctx) short() error { return err } - fmt.Fprint(c.c.Out, ctxs.CurrentContext) + _, _ = fmt.Fprint(c.c.Out, ctxs.CurrentContext) return nil } @@ -185,7 +185,7 @@ func (c *ctx) add(args []string) error { return err } - fmt.Fprintf(c.c.Out, "%s added context \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.Name)) + _, _ = fmt.Fprintf(c.c.Out, "%s added context \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.Name)) return nil } @@ -228,7 +228,7 @@ func (c *ctx) update(args []string) error { return err } - fmt.Fprintf(c.c.Out, "%s updated context \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.Name)) + _, _ = fmt.Fprintf(c.c.Out, "%s updated context \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.Name)) return nil } @@ -256,7 +256,7 @@ func (c *ctx) remove(args []string) error { return err } - fmt.Fprintf(c.c.Out, "%s removed context \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.Name)) + _, _ = fmt.Fprintf(c.c.Out, "%s removed context \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.Name)) return nil } @@ -288,7 +288,7 @@ func (c *ctx) set(args []string) error { return fmt.Errorf("context %s not found", nextCtx) } if nextCtx == ctxs.CurrentContext { - fmt.Fprintf(c.c.Out, "%s context \"%s\" already active\n", color.GreenString("✔"), color.GreenString(ctxs.CurrentContext)) + _, _ = fmt.Fprintf(c.c.Out, "%s context \"%s\" already active\n", color.GreenString("✔"), color.GreenString(ctxs.CurrentContext)) return nil } ctxs.PreviousContext = ctxs.CurrentContext @@ -300,7 +300,7 @@ func (c *ctx) set(args []string) error { return err } - fmt.Fprintf(c.c.Out, "%s switched context to \"%s\"\n", color.GreenString("✔"), color.GreenString(ctxs.CurrentContext)) + _, _ = fmt.Fprintf(c.c.Out, "%s switched context to \"%s\"\n", color.GreenString("✔"), color.GreenString(ctxs.CurrentContext)) return nil } @@ -328,7 +328,7 @@ func (c *ctx) setProject(args []string) error { return err } - fmt.Fprintf(c.c.Out, "%s switched context default project to \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.DefaultProject)) + _, _ = fmt.Fprintf(c.c.Out, "%s switched context default project to \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.DefaultProject)) return nil } diff --git a/cmd/login.go b/cmd/login.go index c87ea81..8090102 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -134,7 +134,7 @@ func (l *login) login() error { return err } - fmt.Fprintf(l.c.Out, "%s login successful! Updated and activated context \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.Name)) + _, _ = fmt.Fprintf(l.c.Out, "%s login successful! Updated and activated context \"%s\"\n", color.GreenString("✔"), color.GreenString(ctx.Name)) return nil } diff --git a/cmd/logout.go b/cmd/logout.go index ac90bb6..19788e2 100644 --- a/cmd/logout.go +++ b/cmd/logout.go @@ -98,7 +98,7 @@ func (l *logout) logout() error { } _ = listener.Close() - fmt.Fprintf(l.c.Out, "%s logout successful! \n", color.GreenString("✔")) + _, _ = fmt.Fprintf(l.c.Out, "%s logout successful! \n", color.GreenString("✔")) return nil }