Skip to content

Make directory for CloudConfig templates configurable - #65

Draft
aramprice wants to merge 1 commit into
masterfrom
make-cc-templates-dir-configurable
Draft

Make directory for CloudConfig templates configurable#65
aramprice wants to merge 1 commit into
masterfrom
make-cc-templates-dir-configurable

Conversation

@aramprice

@aramprice aramprice commented Jul 16, 2026

Copy link
Copy Markdown
Member

See #64

@aramprice
aramprice requested a review from Copilot July 16, 2026 22:29
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 16, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: aramprice / name: aram price (701aea5)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@aramprice

Copy link
Copy Markdown
Member Author

/easycla

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@aramprice

Copy link
Copy Markdown
Member Author

/easycla

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread lib/bat/cloud_config.rb
Comment thread lib/bat/requirements.rb
@aramprice
aramprice force-pushed the make-cc-templates-dir-configurable branch from 701aea5 to bedfbc8 Compare July 17, 2026 00:41
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 85357f69-e5c7-4e04-b399-62f7fe7f087f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch make-cc-templates-dir-configurable

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

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread lib/bat/cloud_config.rb Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread lib/bat/env.rb
Comment on lines 11 to 14
OPTIONAL_VARS = {
debug_mode: 'BAT_DEBUG_MODE',
cc_templates_dir: 'BAT_CC_TEMPLATES_DIR',
}.freeze
@a2geek

a2geek commented Jul 17, 2026

Copy link
Copy Markdown

An update, for my part -- I've got it running against the LXD CPI with the BAT_CC_TEMPLATES_DIR environment variable and it seems to be running just fine!

Note that the README should also be updated as well.

@aramprice
aramprice force-pushed the make-cc-templates-dir-configurable branch from 78e0f55 to e64e438 Compare July 17, 2026 04:28
@aramprice
aramprice requested a review from Copilot July 17, 2026 04:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@aramprice
aramprice requested a review from rkoster July 17, 2026 04:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/bat/cloud_config.rb`:
- Around line 71-80: Update cc_templates_dir to stop checking Dir.exist? for an
explicitly configured `@env.cc_templates_dir`. Preserve the existing non-empty
configuration check, return the configured path as-is, and retain
DEFAULT_TEMPLATES_DIR only when no path is configured.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2dbb0c82-2133-47eb-be5a-70d3d341ddfb

📥 Commits

Reviewing files that changed from the base of the PR and between 31057b3 and e64e438.

📒 Files selected for processing (6)
  • README.md
  • lib/bat/cloud_config.rb
  • lib/bat/env.rb
  • lib/bat/requirements.rb
  • spec/bat/requirements_spec.rb
  • spec/system/spec_helper.rb

Comment thread lib/bat/cloud_config.rb
Comment on lines +71 to +80

def cc_templates_dir
if @env.cc_templates_dir &&
@env.cc_templates_dir != "" &&
Dir.exist?(@env.cc_templates_dir)
@env.cc_templates_dir
else
DEFAULT_TEMPLATES_DIR
end
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid silent fallbacks for explicit configurations.

If BAT_CC_TEMPLATES_DIR is explicitly set to a non-existent path, Dir.exist? evaluates to false and the code silently falls back to DEFAULT_TEMPLATES_DIR. This can lead to confusing test behavior where the default templates are used instead of custom ones, without warning the user.

Removing the Dir.exist? check allows File.read downstream to fail loudly with an Errno::ENOENT error indicating the exact path it attempted to read from, making misconfigurations much easier to debug.

♻️ Proposed fix
    def cc_templates_dir
-      if `@env.cc_templates_dir` &&
-         `@env.cc_templates_dir` != "" &&
-         Dir.exist?(`@env.cc_templates_dir`)
+      if `@env.cc_templates_dir` && !`@env.cc_templates_dir.empty`?
        `@env.cc_templates_dir`
      else
        DEFAULT_TEMPLATES_DIR
      end
    end
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def cc_templates_dir
if @env.cc_templates_dir &&
@env.cc_templates_dir != "" &&
Dir.exist?(@env.cc_templates_dir)
@env.cc_templates_dir
else
DEFAULT_TEMPLATES_DIR
end
end
def cc_templates_dir
if `@env.cc_templates_dir` && !`@env.cc_templates_dir.empty`?
`@env.cc_templates_dir`
else
DEFAULT_TEMPLATES_DIR
end
end
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/bat/cloud_config.rb` around lines 71 - 80, Update cc_templates_dir to
stop checking Dir.exist? for an explicitly configured `@env.cc_templates_dir`.
Preserve the existing non-empty configuration check, return the configured path
as-is, and retain DEFAULT_TEMPLATES_DIR only when no path is configured.

@github-project-automation github-project-automation Bot moved this from Pending Merge | Prioritized to Waiting for Changes | Open for Contribution in Foundational Infrastructure Working Group Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting for Changes | Open for Contribution

Development

Successfully merging this pull request may close these issues.

3 participants