Skip to content

Conversation

jamlo
Copy link
Contributor

@jamlo jamlo commented Mar 19, 2025

Add bacalhau auth info command

Overview

This PR introduces a new auth info command that provides users with detailed information about their current authentication configuration. The command displays the status of authentication-related environment variables and server-side authentication capabilities, particularly focusing on SSO support.

Features

  • Displays status of authentication environment variables:
    • BACALHAU_API_KEY
    • BACALHAU_API_USERNAME
    • BACALHAU_API_PASSWORD
  • Shows server-side authentication configuration:
    • SSO provider details (if configured)
  • Provides helpful notes about authentication precedence

Example Output

Target environment: http://bacalhau-orchestrator-node:1234

Environment Variables:
API Key: Not Set
Username: Set
Password: Set

Node SSO Authentication:
Provider Name: github
Provider ID: github-provider
Version: v1

Note: Environment variables take precedence over other authentication mechanisms including SSO.
To use SSO login, please unset Auth related environment variables first.

Usage

Users can run the command with:

bacalhau auth info

Why

This command helps users debug authentication issues by providing clear visibility into:

  • Which authentication methods are currently active
  • What authentication capabilities are supported by the server
  • How different authentication methods interact with each other

This is particularly useful when troubleshooting SSO login issues or when switching between different authentication methods.

Linear: https://linear.app/expanso/issue/ENG-725/add-bacalhau-auth-info-command

Summary by CodeRabbit

  • New Features

    • Introduced a new CLI command that displays your current authentication status, including API endpoint details, SSO configuration (if available), and environment variable settings.
    • Updated the CLI help output to dynamically reflect the correct environment variable names for authentication.
    • Enhanced error messages to provide clearer guidance when encountering authentication configuration issues.
  • Bug Fixes

    • Improved error handling during authentication information retrieval to provide more informative feedback.
  • Tests

    • Added comprehensive unit tests for the new authentication information command, covering various scenarios including SSO support and environment variable usage.
    • Expanded integration tests to verify the functionality of the authentication command.

Copy link
Contributor

coderabbitai bot commented Mar 19, 2025

Walkthrough

This pull request introduces a new CLI command bacalhau auth info to display authentication information, including API endpoints and environment variable statuses. The changes involve creating the command and its supporting functions in a new file, adding unit and integration tests, updating command registration in the CLI, and refactoring help texts and error messages to use constants from a newly added common package.

Changes

Files Change Summary
cmd/cli/auth/info.go, cmd/cli/auth/info_test.go, cmd/cli/auth/root.go Introduces a new auth info command with supporting tests and registers it in the CLI command structure.
cmd/cli/root.go, cmd/util/api.go Updates help templates and error messages to use constants from the new common package for API key, username, and password.
pkg/common/constants.go Adds new constants (BacalhauAPIKey, BacalhauAPIUsername, BacalhauAPIPassword) to represent authentication environment variable names.
test_integration/17_basic_auth_config_suite_test.go Implements an integration test to verify that the auth info command properly outputs authentication details and reflects environment variable configurations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant InfoCmd
    participant API
    User->>CLI: Execute `bacalhau auth info`
    CLI->>InfoCmd: Invoke info command
    InfoCmd->>CLI: Initialize options (default YAML output)
    InfoCmd->>API: Setup repository config and API client
    API-->>InfoCmd: Return node auth configuration or error
    InfoCmd->>InfoCmd: Check environment variables status
    InfoCmd->>CLI: Write authentication info output
    CLI->>User: Display authentication details
Loading

Assessment against linked issues

Objective Addressed Explanation
[ENG-725] Add "bacalhau auth info" command to facilitate UX and display current auth status and hints.

Suggested reviewers

  • wdbaruni
  • markkuhn

Poem

I’m a little rabbit with lines of code to share,
Hopping through commands with careful flair.
New "auth info" leaps in to reveal the secret signs,
Environment hints and API truths it aligns.
In the digital carrot field, our code does bloom—
Joyful bytes and bops in every room! 🐇

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint (1.64.8)

{"Issues":[{"FromLinter":"typecheck","Text":"pattern build/: no matching files found","Severity":"","SourceLines":["//go:embed build/"],"Pos":{"Filename":"webui/webui.go","Offset":0,"Line":23,"Column":12},"ExpectNoLint":false,"ExpectedNoLintLinter":""}],"Report":{"Linters":[{"Name":"asasalint"},{"Name":"asciicheck"},{"Name":"bidichk"},{"Name":"bodyclose","Enabled":true},{"Name":"canonicalheader"},{"Name":"containedctx"},{"Name":"contextcheck"},{"Name":"copyloopvar","Enabled":true},{"Name":"cyclop"},{"Name":"decorder"},{"Name":"deadcode"},{"Name":"depguard","Enabled":true},{"Name":"dogsled","Enabled":true},{"Name":"dupl"},{"Name":"dupword"},{"Name":"durationcheck"},{"Name":"errcheck","Enabled":true,"EnabledByDefault":true},{"Name":"errchkjson"},{"Name":"errname"},{"Name":"errorlint"},{"Name":"execinquery"},{"Name":"exhaustive"},{"Name":"exhaustivestruct"},{"Name":"exhaustruct"},{"Name":"exportloopref"},{"Name":"exptostd"},{"Name":"forbidigo","Enabled":true},{"Name":"forcetypeassert"},{"Name":"fatcontext"},{"Name":"funlen","Enabled":true},{"Name":"gci"},{"Name":"ginkgolinter"},{"Name":"gocheckcompilerdirectives"},{"Name":"gochecknoglobals"},{"Name":"gochecknoinits","Enabled":true},{"Name":"gochecksumtype"},{"Name":"gocognit"},{"Name":"goconst","Enabled":true},{"Name":"gocritic"},{"Name":"gocyclo","Enabled":true},{"Name":"godot"},{"Name":"godox"},{"Name":"err113"},{"Name":"gofmt","Enabled":true},{"Name":"gofumpt"},{"Name":"goheader"},{"Name":"goimports","Enabled":true},{"Name":"golint"},{"Name":"mnd","Enabled":true},{"Name":"gomnd"},{"Name":"gomoddirectives"},{"Name":"gomodguard"},{"Name":"goprintffuncname","Enabled":true},{"Name":"gosec","Enabled":true},{"Name":"gosimple","Enabled":true,"EnabledByDefault":true},{"Name":"gosmopolitan"},{"Name":"govet","Enabled":true,"EnabledByDefault":true},{"Name":"grouper"},{"Name":"ifshort"},{"Name":"iface"},{"Name":"importas"},{"Name":"inamedparam"},{"Name":"ineffassign","Enabled":true,"EnabledByDefault":true},{"Name":"interfacebloat"},{"Name":"interfacer"},{"Name":"intrange"},{"Name":"ireturn"},{"Name":"lll","Enabled":true},{"Name":"loggercheck"},{"Name":"maintidx"},{"Name":"makezero"},{"Name":"maligned"},{"Name":"mirror"},{"Name":"misspell"},{"Name":"musttag"},{"Name":"nakedret","Enabled":true},{"Name":"nestif"},{"Name":"nilerr"},{"Name":"nilnesserr"},{"Name":"nilnil"},{"Name":"nlreturn"},{"Name":"noctx","Enabled":true},{"Name":"nonamedreturns"},{"Name":"nosnakecase"},{"Name":"nosprintfhostport"},{"Name":"paralleltest"},{"Name":"perfsprint"},{"Name":"prealloc"},{"Name":"predeclared"},{"Name":"promlinter"},{"Name":"protogetter"},{"Name":"reassign"},{"Name":"recvcheck"},{"Name":"revive"},{"Name":"rowserrcheck"},{"Name":"sloglint"},{"Name":"scopelint"},{"Name":"sqlclosecheck"},{"Name":"spancheck"},{"Name":"staticcheck","Enabled":true,"EnabledByDefault":true},{"Name":"structcheck"},{"Name":"stylecheck","Enabled":true},{"Name":"tagalign"},{"Name":"tagliatelle"},{"Name":"tenv"},{"Name":"testableexamples"},{"Name":"testifylint"},{"Name":"testpackage"},{"Name":"thelper"},{"Name":"tparallel"},{"Name":"typecheck","Enabled":true,"EnabledByDefault":true},{"Name":"unconvert","Enabled":true},{"Name":"unparam"},{"Name":"unused","Enabled":true,"EnabledByDefault":true},{"Name":"usestdlibvars"},{"Name":"usetesting"},{"Name":"varcheck"},{"Name":"varnamelen"},{"Name":"wastedassign"},{"Name":"whitespace","Enabled":true},{"Name":"wrapcheck"},{"Name":"wsl"},{"Name":"zerologlint"},{"Name":"nolintlint","Enabled":true}]}}


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between ca5786a and 2fd01ee.

📒 Files selected for processing (1)
  • pkg/common/constants.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/common/constants.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: testcontainers-suite / tests

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jamlo jamlo marked this pull request as ready for review March 19, 2025 21:26
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7bfb583 and bf40eee.

📒 Files selected for processing (7)
  • cmd/cli/auth/info.go (1 hunks)
  • cmd/cli/auth/info_test.go (1 hunks)
  • cmd/cli/auth/root.go (1 hunks)
  • cmd/cli/root.go (2 hunks)
  • cmd/util/api.go (3 hunks)
  • pkg/common/constants.go (1 hunks)
  • test_integration/17_basic_auth_config_suite_test.go (2 hunks)
🧰 Additional context used
🧬 Code Definitions (5)
cmd/cli/auth/root.go (1)
cmd/cli/auth/info.go (1) (1)
  • NewInfoCmd (33-59)
cmd/cli/root.go (1)
pkg/common/constants.go (3) (3)
  • BacalhauApiKey (3-3)
  • BacalhauApiUsername (4-4)
  • BacalhauApiPassword (5-5)
cmd/util/api.go (1)
pkg/common/constants.go (3) (3)
  • BacalhauApiKey (3-3)
  • BacalhauApiUsername (4-4)
  • BacalhauApiPassword (5-5)
cmd/cli/auth/info_test.go (2)
cmd/cli/auth/info.go (3) (3)
  • NewInfoCmd (33-59)
  • o (62-117)
  • NewInfoOptions (27-31)
pkg/common/constants.go (3) (3)
  • BacalhauApiKey (3-3)
  • BacalhauApiUsername (4-4)
  • BacalhauApiPassword (5-5)
cmd/cli/auth/info.go (2)
cmd/util/api.go (2) (2)
  • GetAPIClientV2 (29-139)
  • ConstructAPIEndpoint (141-166)
pkg/common/constants.go (3) (3)
  • BacalhauApiKey (3-3)
  • BacalhauApiUsername (4-4)
  • BacalhauApiPassword (5-5)
🪛 GitHub Check: lint / go-lint (ubuntu-latest)
pkg/common/constants.go

[failure] 3-3:
G101: Potential hardcoded credentials (gosec)


[failure] 5-5:
G101: Potential hardcoded credentials (gosec)


[failure] 4-4:
ST1003: const BacalhauApiUsername should be BacalhauAPIUsername (stylecheck)

🪛 GitHub Actions: Main Pipeline
pkg/common/constants.go

[error] 3-3: G101: Potential hardcoded credentials (gosec)

🔇 Additional comments (21)
cmd/cli/auth/root.go (1)

18-18: LGTM: Auth info command successfully added

The new NewInfoCmd() command is correctly added to the auth command structure. This aligns with the PR objectives to introduce the bacalhau auth info command for users to view their authentication configuration.

pkg/common/constants.go (1)

3-5:

✅ Verification successful

Address false positive "hardcoded credentials" warnings

The static analysis is flagging these constants as potential hardcoded credentials. These are just environment variable names, not actual credentials.


🏁 Script executed:

#!/bin/bash
# Add comments to indicate these are variable names, not credentials

cat <<EOF
// The following constants define environment variable names for authentication.
// They do not contain actual credentials, just the names of environment variables.
EOF

Length of output: 170


Finalized Review Comment: Environment Variable Name Clarification

The static analysis warning regarding "hardcoded credentials" is a false positive. These constants are simply the names of environment variables used for authentication, not actual credentials. To clarify this, please add a descriptive comment above these constants in pkg/common/constants.go (lines 3-5):

// The following constants define environment variable names for authentication.
// They do not contain actual credentials, just the names of environment variables.
const BacalhauApiKey = "BACALHAU_API_KEY"
const BacalhauApiUsername = "BACALHAU_API_USERNAME"
const BacalhauApiPassword = "BACALHAU_API_PASSWORD"
🧰 Tools
🪛 GitHub Check: lint / go-lint (ubuntu-latest)

[failure] 3-3:
G101: Potential hardcoded credentials (gosec)


[failure] 5-5:
G101: Potential hardcoded credentials (gosec)


[failure] 4-4:
ST1003: const BacalhauApiUsername should be BacalhauAPIUsername (stylecheck)

🪛 GitHub Actions: Main Pipeline

[error] 3-3: G101: Potential hardcoded credentials (gosec)

cmd/cli/root.go (2)

27-27: LGTM: New common package import

The import for the common package is correctly added to use the authentication environment variable constants.


114-119: LGTM: Help template updated to use constants

The help template is now using constants from the common package instead of hardcoded strings, improving maintainability.

cmd/util/api.go (5)

16-16: LGTM: New common package import

The import for the common package is correctly added to use the authentication environment variable constants.


257-258: LGTM: Error message updated to use constants

The error message now uses constants from the common package instead of hardcoded strings.


276-277: LGTM: Error message updated to use constants

The error message now uses constants from the common package instead of hardcoded strings.


280-281: LGTM: Error message updated to use constants

The error message now uses constants from the common package instead of hardcoded strings.


289-291: LGTM: Environment variable retrieval updated to use constants

The function now uses constants from the common package for retrieving environment variables, improving maintainability.

test_integration/17_basic_auth_config_suite_test.go (1)

153-172: Well-implemented integration test for the new auth info command.

The new test method properly validates all aspects of the bacalhau auth info command output, including environment variable status, SSO configuration, and the informative notes about authentication precedence. Good use of environment variables to simulate a real authentication scenario.

cmd/cli/auth/info_test.go (6)

18-77: Good mock implementation of required interfaces.

The mock implementations of client.API and client.Client are well-structured and provide the necessary functionality for testing the auth info command without requiring actual API calls.


80-111: Comprehensive test for no SSO support scenario.

This test thoroughly verifies the command's behavior when the server doesn't support authentication methods, ensuring appropriate messages are displayed and irrelevant information is not included.


114-172: Good test case for SSO support with custom endpoint.

This test case validates both the SSO provider information display and the custom API endpoint rendering, covering two important aspects in a single test.


175-213: Effective test for server without SSO config.

The test properly verifies that when a server responds but has no SSO config, the output correctly indicates that SSO login is not supported, while still showing environment variable information.


216-264: Proper environment variable handling in test.

Good practice setting and unsetting environment variables with defer to ensure clean test state. This test confirms that environment variables are correctly detected and displayed in the command output.


267-315: Well-structured table-driven test for API endpoints.

This test efficiently covers multiple API endpoint configurations using a table-driven approach, verifying both HTTP and HTTPS endpoints with different host/port combinations.

cmd/cli/auth/info.go (5)

19-31: Good structure for command options.

The InfoOptions struct and its initialization function provide a clean way to manage command options, following the pattern used in other commands of the application.


33-59: Well-implemented Cobra command setup.

The command is properly configured with appropriate usage information, argument validation, and error handling. Good use of the existing utility functions for repository config setup and API client initialization.


62-94: Good implementation of authentication information gathering.

This portion of the code correctly retrieves and formats environment variable statuses and handles the case where the server doesn't support authentication methods with appropriate error messaging.


96-117: Clear presentation of authentication configuration.

The code provides a well-structured output that distinguishes between SSO support status and includes helpful notes about authentication method precedence, assisting users in debugging authentication issues.


120-125: Simple but effective helper function.

The getEnvStatus helper keeps the code DRY and provides consistent formatting for environment variable status reporting.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
cmd/cli/auth/info.go (1)

62-117: Comprehensive implementation of the info command.

The runInfo method effectively gathers and displays authentication information, showing environment variable statuses, SSO configuration, and providing helpful notes about authentication precedence. All these aspects align well with the PR objectives.

One suggestion: Consider adding a description in the output for what the environment variables are used for, to make the output more informative for new users.

// Print environment variable status
outputBuilder.WriteString("Environment Variables:\n")
-outputBuilder.WriteString(fmt.Sprintf("API Key: %s\n", getEnvStatus(apiKey)))
-outputBuilder.WriteString(fmt.Sprintf("Username: %s\n", getEnvStatus(username)))
-outputBuilder.WriteString(fmt.Sprintf("Password: %s\n\n", getEnvStatus(password)))
+outputBuilder.WriteString(fmt.Sprintf("API Key (%s): %s\n", common.BacalhauAPIKey, getEnvStatus(apiKey)))
+outputBuilder.WriteString(fmt.Sprintf("Username (%s): %s\n", common.BacalhauAPIUsername, getEnvStatus(username)))
+outputBuilder.WriteString(fmt.Sprintf("Password (%s): %s\n\n", common.BacalhauAPIPassword, getEnvStatus(password)))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between bf40eee and 394c844.

📒 Files selected for processing (5)
  • cmd/cli/auth/info.go (1 hunks)
  • cmd/cli/auth/info_test.go (1 hunks)
  • cmd/cli/root.go (2 hunks)
  • cmd/util/api.go (3 hunks)
  • pkg/common/constants.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/cli/root.go
  • cmd/util/api.go
🧰 Additional context used
🧬 Code Definitions (2)
cmd/cli/auth/info.go (2)
cmd/util/api.go (2) (2)
  • GetAPIClientV2 (29-139)
  • ConstructAPIEndpoint (141-166)
pkg/common/constants.go (3) (3)
  • BacalhauAPIKey (3-3)
  • BacalhauAPIUsername (4-4)
  • BacalhauAPIPassword (5-5)
cmd/cli/auth/info_test.go (2)
cmd/cli/auth/info.go (3) (3)
  • NewInfoCmd (33-59)
  • o (62-117)
  • NewInfoOptions (27-31)
pkg/common/constants.go (3) (3)
  • BacalhauAPIKey (3-3)
  • BacalhauAPIUsername (4-4)
  • BacalhauAPIPassword (5-5)
🪛 GitHub Check: lint / go-lint (ubuntu-latest)
pkg/common/constants.go

[failure] 3-3:
G101: Potential hardcoded credentials (gosec)


[failure] 5-5:
G101: Potential hardcoded credentials (gosec)

🪛 GitHub Actions: Main Pipeline
pkg/common/constants.go

[error] 3-3: G101: Potential hardcoded credentials (gosec)

🔇 Additional comments (8)
pkg/common/constants.go (1)

3-5: Safely ignore static analysis alerts about hardcoded credentials.

The static analysis tools are flagging these constants with G101: Potential hardcoded credentials (gosec), but this is a false positive. These constants are simply string literals representing environment variable names, not actual credentials or secrets. This centralization of constant definitions is a good practice for maintainability.

🧰 Tools
🪛 GitHub Check: lint / go-lint (ubuntu-latest)

[failure] 3-3:
G101: Potential hardcoded credentials (gosec)


[failure] 5-5:
G101: Potential hardcoded credentials (gosec)

🪛 GitHub Actions: Main Pipeline

[error] 3-3: G101: Potential hardcoded credentials (gosec)

cmd/cli/auth/info_test.go (5)

80-111: Well-structured test for the "no SSO support" scenario.

The test properly verifies that when the server doesn't support authentication methods, the output correctly shows environment variable statuses and the message about lack of server support, while not showing SSO-related sections.


114-172: Comprehensive test for SSO support scenario with endpoint verification.

This test thoroughly checks both the SSO provider information display and custom endpoint rendering. Good use of the require package for assertions and proper test cleanup.


175-213: Good coverage of the "no SSO config" edge case.

The test properly verifies that when the server responds but has no SSO configuration, the appropriate message is displayed without showing provider details.


216-264: Proper environment variable handling in test.

Good use of defer to clean up environment variables after the test. This test correctly verifies that the command shows environment variables as "Set" when they're present.


267-315: Well-implemented table-driven test for API endpoints.

The test efficiently covers multiple endpoint configurations using a table-driven approach, which is a Go best practice for testing multiple scenarios with similar structure.

cmd/cli/auth/info.go (2)

33-59: Good implementation of command registration.

The command is properly registered with appropriate descriptions and error handling. The use of WithHint to provide debugging guidance is a nice touch for user experience.


120-125: Simple helper function with clear purpose.

This helper function cleanly abstracts the logic for displaying environment variable status as "Set" or "Not Set".

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/common/constants.go (1)

3-6: Consider using a const block and improving documentation

The constants look good, and I'm glad to see you've followed Go's naming convention for acronyms (API in all caps). Consider these refinements:

  1. Group the constants in a const block for better readability
  2. Add a descriptive comment explaining their purpose
//nolint:gosec // G101: Potential hardcoded credentials
-const BacalhauAPIKey = "BACALHAU_API_KEY"
-const BacalhauAPIUsername = "BACALHAU_API_USERNAME"
-const BacalhauAPIPassword = "BACALHAU_API_PASSWORD"
+// Environment variable names used for Bacalhau API authentication
+const (
+   BacalhauAPIKey      = "BACALHAU_API_KEY"
+   BacalhauAPIUsername = "BACALHAU_API_USERNAME"
+   BacalhauAPIPassword = "BACALHAU_API_PASSWORD"
+)

This will ensure the nolint directive applies to all constants and makes the code more idiomatic.

🧰 Tools
🪛 GitHub Check: lint / go-lint (ubuntu-latest)

[failure] 6-6:
G101: Potential hardcoded credentials (gosec)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 394c844 and ca5786a.

📒 Files selected for processing (1)
  • pkg/common/constants.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: lint / go-lint (ubuntu-latest)
pkg/common/constants.go

[failure] 6-6:
G101: Potential hardcoded credentials (gosec)

🪛 GitHub Actions: Main Pipeline
pkg/common/constants.go

[error] 6-7: G101: Potential hardcoded credentials (gosec)

🔇 Additional comments (1)
pkg/common/constants.go (1)

3-3: Linter suppression is appropriate

The nolint directive is justified here as these are environment variable names, not actual credentials.

@jamlo jamlo requested a review from wdbaruni March 19, 2025 22:08
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
cfg, err := util.SetupRepoConfig(cmd)
if err != nil {
log.Debug().Err(err).Msg("failed to setup bacalhau repository config")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

@jamlo jamlo merged commit a0a9fea into main Mar 20, 2025
14 checks passed
@jamlo jamlo deleted the jamlo/auth-info-command branch March 20, 2025 01:33
@coderabbitai coderabbitai bot mentioned this pull request Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants