Skip to content

fix: simplify config get to read directly from viper#974

Open
smarthall wants to merge 2 commits into
mainfrom
simplify-config-get
Open

fix: simplify config get to read directly from viper#974
smarthall wants to merge 2 commits into
mainfrom
simplify-config-get

Conversation

@smarthall

@smarthall smarthall commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces the GetBackplaneConfiguration() call in config get with direct viper reads from the config file
  • Avoids pulling in the OCM connection logic and proxy-testing side effects that are unnecessary for simply displaying config values
  • Handles both string and string-slice formats for proxy-url

Test plan

  • Run ocm backplane config get url and verify it prints the configured URL
  • Run ocm backplane config get proxy-url with both string and array formats in config
  • Run ocm backplane config get all and verify all values display correctly
  • Run ocm backplane config get with no config file present (should print empty values)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Configuration values can now be retrieved directly from the saved JSON configuration file (when present).
    • The get command output now includes the proxy URL and the GovCloud setting.
    • The all option now displays all supported configuration values from the saved JSON configuration.

Replace the heavyweight GetBackplaneConfiguration() call with direct
viper reads from the config file, avoiding unnecessary OCM connection
logic and proxy-testing side effects for a simple config display command.

Signed-off-by: Daniel Hall <danhall@redhat.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci
openshift-ci Bot requested review from typeid and wanghaoran1988 July 24, 2026 00:21
@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: smarthall

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bea4e8a6-f626-40f9-ad83-c0f6754060d1

📥 Commits

Reviewing files that changed from the base of the PR and between b8e6319 and 8814ed7.

📒 Files selected for processing (1)
  • cmd/ocm-backplane/config/get.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/ocm-backplane/config/get.go

Walkthrough

The get command reads configuration values from the configured JSON file through Viper. Proxy URLs are joined for output, GovCloud is printed as a boolean, and the all option uses Viper-backed values.

Changes

Configuration retrieval

Layer / File(s) Summary
Load and print configuration values
cmd/ocm-backplane/config/get.go
The command locates and reads the JSON configuration file with Viper, then prints requested or all supported variables from Viper values. Proxy URLs are joined for output, and GovCloud is printed as a boolean.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: wanghaoran1988, typeid

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: config get now reads values directly from Viper.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch simplify-config-get

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

@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 `@cmd/ocm-backplane/config/get.go`:
- Around line 32-38: Update the config-path handling around os.Stat to
distinguish a missing file from other filesystem errors: retain the fallback
only for os.IsNotExist(err), and return a wrapped, user-contextual error for
permission, invalid-path, and other failures. Preserve the existing
viper.ReadInConfig behavior when the file exists.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4d69f168-d4d0-4bcf-b135-5c6941ad67c4

📥 Commits

Reviewing files that changed from the base of the PR and between f456799 and b8e6319.

📒 Files selected for processing (1)
  • cmd/ocm-backplane/config/get.go

Comment thread cmd/ocm-backplane/config/get.go Outdated
Return a user-contextual error for permission, invalid-path, and other
filesystem failures instead of silently falling through to viper
defaults. A missing file still falls through as before.

Signed-off-by: Daniel Hall <danhall@redhat.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@smarthall: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.53%. Comparing base (f456799) to head (8814ed7).

Files with missing lines Patch % Lines
cmd/ocm-backplane/config/get.go 0.00% 19 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #974      +/-   ##
==========================================
- Coverage   54.58%   54.53%   -0.05%     
==========================================
  Files          82       82              
  Lines        6308     6313       +5     
==========================================
  Hits         3443     3443              
- Misses       2416     2421       +5     
  Partials      449      449              
Files with missing lines Coverage Δ
cmd/ocm-backplane/config/get.go 21.95% <0.00%> (-3.05%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@smarthall

Copy link
Copy Markdown
Member Author

Okay I've written some Ansible modules for setting up your machine for SREP access, one of the things it does is configure the backplane proxy-url. At the moment this command requires ocm to be logged in, this change means we can set that up unattended before the user logs into ocm.


func getConfig(cmd *cobra.Command, args []string) error {
config, err := config.GetBackplaneConfiguration()
configPath, err := config.GetConfigFilePath()

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.

This may overwrite environment configuration settings. For example : GitHub - backplane-cli config.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants