Skip to content

Commit 4378359

Browse files
committed
πŸ› fix: resolve lint errors β€” named returns and struct alignment
1 parent a1d5f82 commit 4378359

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

β€Žinternal/cmd/auth/login.goβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func init() {
4141
}
4242

4343
// resolveRegistration returns a client ID and scopes, registering dynamically if needed.
44-
func resolveRegistration(ctx context.Context, authBaseURL string, cmd *cobra.Command) (string, []string, error) {
44+
func resolveRegistration(ctx context.Context, authBaseURL string, cmd *cobra.Command) (clientID string, scopes []string, err error) {
4545
if clientID, _ := cmd.Flags().GetString("client-id"); clientID != "" {
4646
return clientID, nil, nil
4747
}
@@ -52,14 +52,14 @@ func resolveRegistration(ctx context.Context, authBaseURL string, cmd *cobra.Com
5252
}
5353

5454
// registerAndCache calls POST /oauth/register and saves the client_id and scopes.
55-
func registerAndCache(ctx context.Context, authBaseURL string, cmd *cobra.Command) (string, []string, error) {
55+
func registerAndCache(ctx context.Context, authBaseURL string, cmd *cobra.Command) (clientID string, scopes []string, err error) {
5656
_, _ = fmt.Fprintf(cmd.OutOrStderr(), "Registering OAuth client...\n")
57-
clientID, scopes, err := xoauth.RegisterClient(ctx, authBaseURL)
57+
clientID, scopes, err = xoauth.RegisterClient(ctx, authBaseURL)
5858
if err != nil {
5959
return "", nil, err
6060
}
61-
if err := xoauth.SaveRegistration(clientID, scopes); err != nil {
62-
return "", nil, fmt.Errorf("failed to cache registration: %w", err)
61+
if saveErr := xoauth.SaveRegistration(clientID, scopes); saveErr != nil {
62+
return "", nil, fmt.Errorf("failed to cache registration: %w", saveErr)
6363
}
6464
return clientID, scopes, nil
6565
}

β€Žinternal/config/config.goβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ type Config struct {
2424
Language string `yaml:"language"` // TUI-specific
2525
Layout string `yaml:"layout"` // TUI-specific
2626
OAuth *OAuthData `yaml:"oauth,omitempty"`
27-
ClientID string `yaml:"client_id,omitempty"` // Dynamically registered OAuth client ID
28-
Scopes []string `yaml:"scopes,omitempty,flow"` // Granted OAuth scopes from registration
29-
Debug bool `yaml:"-"` // Runtime only, not persisted
27+
ClientID string `yaml:"client_id,omitempty"` // Dynamically registered OAuth client ID
28+
Scopes []string `yaml:"scopes,omitempty,flow"` // Granted OAuth scopes from registration
29+
Debug bool `yaml:"-"` // Runtime only, not persisted
3030
}
3131

3232
// OAuthData holds OAuth2 token data within the config file.

β€Žinternal/oauth/oauth.goβ€Ž

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type registrationResponse struct {
5050
}
5151

5252
// RegisterClient dynamically registers an OAuth client and returns the client_id and granted scopes.
53-
func RegisterClient(ctx context.Context, authBaseURL string) (string, []string, error) {
53+
func RegisterClient(ctx context.Context, authBaseURL string) (clientID string, scopes []string, err error) {
5454
reqBody := registrationRequest{
5555
ClientName: "Rootly CLI",
5656
RedirectURIs: []string{RedirectURI},
@@ -89,8 +89,9 @@ func RegisterClient(ctx context.Context, authBaseURL string) (string, []string,
8989
return "", nil, fmt.Errorf("registration response missing client_id")
9090
}
9191

92-
scopes := strings.Fields(regResp.Scope)
93-
return regResp.ClientID, scopes, nil
92+
clientID = regResp.ClientID
93+
scopes = strings.Fields(regResp.Scope)
94+
return clientID, scopes, nil
9495
}
9596

9697
// LoadCachedRegistration reads the cached client_id and scopes from config.

0 commit comments

Comments
Β (0)