Skip to content

feat!: remove support for old profile name#5

Open
n-tucker wants to merge 4 commits into
mainfrom
nt/remove-old-profile-support
Open

feat!: remove support for old profile name#5
n-tucker wants to merge 4 commits into
mainfrom
nt/remove-old-profile-support

Conversation

@n-tucker
Copy link
Copy Markdown
Contributor

@n-tucker n-tucker commented Apr 24, 2025

Warning

This is a breaking change!

Purpose

  • To make the credential helper plugin compatible with the old profile name, we needed to hold off on implementing some checks
  • After rolling out profile support for Chimina, we can safely make this change since the new profile naming convention is being used

Context

  • Supporting profile names at the repo and org level is a breaking change, and requires a prefix to differentiate between them

Summary by CodeRabbit

  • Refactor

    • Simplified profile handling by removing legacy support for the "default" profile and narrowing conditions to "repo:default" only.
  • Bug Fixes

    • Improved profile validation: invalid profiles are now skipped with a warning instead of causing the script to exit.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2025

Walkthrough

The changes focus on refining the handling and validation of profile names in credential management scripts. In the credential helper, the logic for determining the credentials path was simplified by eliminating support for the legacy "default" profile, now only checking for "repo:default". In the environment hook, the script now validates each profile during iteration, skipping invalid profiles with a warning message instead of terminating the script. Corresponding tests were updated to reflect these changes, including renaming, removal, and addition of tests to verify the new validation behavior.

Changes

File(s) Change Summary
credential-helper/buildkite-connector-credential-helper Simplified the logic for determining the credentials path by removing support for the legacy "default" profile and only checking for "repo:default".
hooks/environment Updated profile validation: now checks each profile at runtime, prints a warning for invalid profiles, and skips them instead of exiting the script.
tests/environment.bats Renamed and removed tests to align with updated profile validation logic; added a new test verifying that invalid profiles emit warnings and are ignored.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EnvHook as Environment Hook
    participant CredentialHelper

    User->>EnvHook: Run environment setup
    EnvHook->>EnvHook: For each profile in profiles
    alt Profile starts with "org:" or "repo:"
        EnvHook->>CredentialHelper: Configure valid profile
    else Invalid profile
        EnvHook->>EnvHook: Print warning, skip profile
    end
    EnvHook-->>User: Environment setup continues

    User->>CredentialHelper: Request credentials with profile
    alt profile == "repo:default"
        CredentialHelper->>CredentialHelper: Set path to "git-credentials"
    else
        CredentialHelper->>CredentialHelper: Set path to "organization/git-credentials/${profile}"
    end
    CredentialHelper-->>User: Return credentials
Loading

Possibly related PRs

Poem

A hop through profiles, old and new,
The "default" path we now eschew.
If your name is wrong, don’t feel blue—
We’ll skip along and not blame you!
Cleaner scripts, credentials tight,
Rabbits code with pure delight.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

now we skip invalid profiles, failing early would cause subsequent credential helpers to never be configured. this limits the blast radius of invalid config
@n-tucker n-tucker force-pushed the nt/remove-old-profile-support branch from 09f5795 to 68359b8 Compare April 24, 2025 01:30
@n-tucker n-tucker requested a review from a team April 24, 2025 01:30
Copy link
Copy Markdown

@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 68359b8 and 1006693.

📒 Files selected for processing (2)
  • hooks/environment (1 hunks)
  • tests/environment.bats (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • hooks/environment
🔇 Additional comments (2)
tests/environment.bats (2)

48-59: Test name updated to reflect new profile naming requirement.

The test name has been updated to explicitly include the profile verification, which aligns with the PR objective of removing support for old profile names. The assertion now correctly verifies the presence of the "repo:default" profile argument, enforcing the new profile naming convention that requires explicit prefixes.


102-103: Warning message handling aligns with PR objectives.

The warning message handling correctly implements the PR's intention to validate profiles individually and continue execution even if some profiles are invalid. This is a more graceful approach than terminating the script entirely when encountering invalid profiles.

Comment thread tests/environment.bats
Comment on lines +93 to 109
@test "Ignores profiles without specified prefixes" {
export BUILDKITE_PLUGIN_GITHUB_APP_AUTH_VENDOR_URL=http://test-location
export BUILDKITE_PLUGIN_GITHUB_APP_AUTH_AUDIENCE=test-audience
export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_PROFILES_0="invalid-profile-name"
export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_PROFILES_1="org:read-packages"

run_environment "${PWD}/hooks/environment"

assert_success
assert_line --partial ":warning: Invalid profile"

assert_line "GIT_CONFIG_COUNT=2"
assert_line "GIT_CONFIG_KEY_0=credential.https://github.com.usehttppath"
assert_line "GIT_CONFIG_VALUE_0=true"
assert_line "GIT_CONFIG_KEY_1=credential.https://github.com.helper"
assert_line --regexp "GIT_CONFIG_VALUE_1=/.*/credential-helper/buildkite-connector-credential-helper http://test-location test-audience"
assert_line --regexp "GIT_CONFIG_VALUE_1=/.*/credential-helper/buildkite-connector-credential-helper http://test-location test-audience org:read-packages"
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Environment variable inconsistency in test setup.

The test correctly validates the new behavior of ignoring invalid profiles (without proper prefixes) while continuing with valid ones. However, the URL and audience environment variables use an inconsistent naming pattern:

-  export BUILDKITE_PLUGIN_GITHUB_APP_AUTH_VENDOR_URL=http://test-location
-  export BUILDKITE_PLUGIN_GITHUB_APP_AUTH_AUDIENCE=test-audience
+  export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_CHINMINA_URL=http://test-location
+  export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_AUDIENCE=test-audience

All other tests in this file use the CHINMINA_GIT_CREDENTIALS prefix for environment variables, not GITHUB_APP_AUTH.

Committable suggestion skipped: line range outside the PR's diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant