Skip to content

Add config support default non-admin storage location#144

Merged
Joeavaikath merged 6 commits into
migtools:oadp-devfrom
Joeavaikath:default-storage-location
Mar 2, 2026
Merged

Add config support default non-admin storage location#144
Joeavaikath merged 6 commits into
migtools:oadp-devfrom
Joeavaikath:default-storage-location

Conversation

@Joeavaikath
Copy link
Copy Markdown
Contributor

@Joeavaikath Joeavaikath commented Feb 27, 2026

Why the changes were made

  • Adds a new config value nonadmin-default: this allows nonadmin users to specify a default NABSL, allowing them to not specify --storage-location for each nonadmin backup creation
  • Improve output formatting with line breaks and notification around the config value

How to test the changes made

  1. Create a NABSL (eg test-nabsl). A message around setting the config value should be visible.
  2. Set the config value: oc oadp nonadmin client config set default-nabsl=test-nabsl
  3. Run a nonadmin backup: oc oadp nonadmin backup create test-backup

The backup should be created successfully with a message stating that the config value was used for nonadmin backup storage location

Summary by CodeRabbit

  • New Features

    • Support for a configurable default non-admin backup storage location so you no longer must specify it each time.
  • Bug Fixes / UX

    • CLI help clarifies storage-location can be overridden by config.
    • Commands print a clear notice when the default storage location from config is used.
    • Minor wording tweak: references "created requests" and adds a hint to set a default via the client config.
  • Documentation

    • Examples and help text updated to show setting and using the default storage location.

for non-admin backups

Adds a config value to the Velero client config file to set the default storage location for non-admin backups.
Adds a command output on NABSL creation to inform the user about the default storage location config.

Signed-off-by: Joseph <jvaikath@redhat.com>
If default storage location is set in config, display a message that it is being used.

Signed-off-by: Joseph <jvaikath@redhat.com>
Add line breaks in create output for non-admin backup and NABSL creation.

Signed-off-by: Joseph <jvaikath@redhat.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

Adds support for a default non-admin backup storage location (NABSL) loaded from the Velero client config: new ClientConfig field and accessor, CreateOptions reads and uses the config default when --storage-location is not provided, and user-facing messages updated to reflect/configure the default.

Changes

Cohort / File(s) Summary
ClientConfig: default NABSL
cmd/shared/factories.go
Add DefaultNABSL string to ClientConfig (json:"default-nabsl,omitempty") and GetDefaultNABSL() string accessor; minor alignment/formatting adjustments.
Non-admin backup create
cmd/non-admin/backup/create.go
Add storageLocationFromConfig field to CreateOptions; if --storage-location is empty, load default NABSL from client config via getNABSLFromConfig() and mark it as from config; update flag help, validation message, and print notice when using config default.
BSL create output
cmd/non-admin/bsl/create.go
Switch from formatted Printf to Println calls, tweak wording to reference "created requests", add a hint to set a default NABSL via oc oadp client config, and append a blank line.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Bugfixes #138 — Overlaps non-admin backup/BSL command changes and may touch similar CreateOptions/BSL output logic.

Suggested reviewers

  • weshayutin
  • stillalearner

Poem

🐰 I sniffed the config, found a cozy nest,
A NABSL waiting, making setups less stressed.
I hopped through flags, nudged help text bright,
Now defaults hum softly through the night. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding configuration support for a default non-admin backup storage location, which is the primary purpose of the PR.
Description check ✅ Passed The description covers both required sections with appropriate detail: explains why the feature was added (convenience for non-admin users) and provides clear testing steps with expected behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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 and usage tips.

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: 2

🧹 Nitpick comments (1)
cmd/non-admin/bsl/create.go (1)

204-204: Clarify scope as “default non-admin” storage location.

Line 204 says “default” broadly; making it explicit helps avoid confusion with admin backup flows.

✏️ Suggested wording
-fmt.Printf("Use `oc oadp client config set default-nabsl=%s` to set this BSL as the default to avoid specifying the BSL name each time.\n", nabsl.Name)
+fmt.Printf("Use `oc oadp client config set default-nabsl=%s` to set this as the default non-admin BSL and avoid specifying --storage-location each time.\n", nabsl.Name)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/non-admin/bsl/create.go` at line 204, The user-facing message currently
prints a broad "default" which is ambiguous; update the fmt.Printf call that
references nabsl.Name (the line using fmt.Printf("Use `oc oadp client config set
default-nabsl=%s`...")) to explicitly say "default non-admin storage location"
or "default non-admin BSL" so it clarifies scope and avoids confusion with admin
backup flows—replace the wording in that fmt.Printf invocation to include
"non-admin" while preserving the command and nabsl.Name placeholder.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/non-admin/backup/create.go`:
- Around line 147-150: The code currently unconditionally sets o.StorageLocation
from getNABSLFromConfig() via defaultNABSL which overwrites an explicit
--storage-location flag; change the logic so you only assign o.StorageLocation =
defaultNABSL when the user did NOT provide a storage location flag (i.e., detect
whether the flag was set and only use getNABSLFromConfig() as a fallback).
Update the related reporting logic that mentions config usage (the message
around where o.StorageLocation is later reported) to only state "using
default-nabsl from config" when the config value was actually used; reference
the identifiers defaultNABSL, getNABSLFromConfig(), and o.StorageLocation to
locate and adjust the conditional assignment and the corresponding log/message.
- Around line 255-264: getNABSLFromConfig currently swallows errors from
shared.ReadVeleroClientConfig and returns "" which hides parse/read failures;
change getNABSLFromConfig to return (string, error), propagate and return any
error from shared.ReadVeleroClientConfig instead of returning an empty string,
and only return the default NABSL when clientConfig is non-nil and
GetDefaultNABSL() is non-empty; update callers of getNABSLFromConfig to handle
the error (e.g., validate and surface the error to the user) rather than relying
on an empty string.

---

Nitpick comments:
In `@cmd/non-admin/bsl/create.go`:
- Line 204: The user-facing message currently prints a broad "default" which is
ambiguous; update the fmt.Printf call that references nabsl.Name (the line using
fmt.Printf("Use `oc oadp client config set default-nabsl=%s`...")) to explicitly
say "default non-admin storage location" or "default non-admin BSL" so it
clarifies scope and avoids confusion with admin backup flows—replace the wording
in that fmt.Printf invocation to include "non-admin" while preserving the
command and nabsl.Name placeholder.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d66cd7 and d06aba6.

📒 Files selected for processing (3)
  • cmd/non-admin/backup/create.go
  • cmd/non-admin/bsl/create.go
  • cmd/shared/factories.go

Comment thread cmd/non-admin/backup/create.go Outdated
Comment thread cmd/non-admin/backup/create.go
Signed-off-by: Joseph <jvaikath@redhat.com>
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/non-admin/backup/create.go`:
- Around line 64-66: Update the example to use the non-admin command path and
remove the misleading “all backups” scope: replace the comment line "# Set
default storage location for all backups." with wording that indicates this is
for non-admin backup flows, and change the example command string "oc oadp
client config set default-nabsl=my-nabsl" to the non-admin variant (e.g. "oc
oadp non-admin client config set default-nabsl=my-nabsl") so the example
reflects the non-admin scope used by this feature.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d06aba6 and 4deb38e.

📒 Files selected for processing (1)
  • cmd/non-admin/backup/create.go

Comment thread cmd/non-admin/backup/create.go
Comment thread cmd/non-admin/backup/create.go Outdated
kaovilai
kaovilai previously approved these changes Feb 27, 2026
Signed-off-by: Joseph <jvaikath@redhat.com>
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.

♻️ Duplicate comments (1)
cmd/non-admin/backup/create.go (1)

64-66: ⚠️ Potential issue | 🟡 Minor

Use non-admin command path/scope in guidance text.

Line 64 and Line 141 still present this as global/all-backup guidance, but this flow is non-admin backup specific. Update both strings to avoid copy/paste confusion.

💡 Suggested text update
-  # Set default storage location for all backups.
-  oc oadp client config set default-nabsl=my-nabsl
+  # Set default storage location for non-admin backups.
+  oc oadp nonadmin client config set default-nabsl=my-nabsl
-		return fmt.Errorf("--storage-location is required\n" +
-			"To avoid specifying the storage location each time:\n" +
-			"run `oc oadp client config set default-nabsl=<NABSL_NAME>` to set the default storage location")
+		return fmt.Errorf("--storage-location is required\n" +
+			"To avoid specifying the storage location each time for non-admin backups:\n" +
+			"run `oc oadp nonadmin client config set default-nabsl=<NABSL_NAME>` to set the default storage location")

Also applies to: 139-142

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/non-admin/backup/create.go` around lines 64 - 66, The user-facing
guidance strings in create.go that currently read "Set default storage location
for all backups." and show the example "oc oadp client config set
default-nabsl=my-nabsl" are incorrect for this non-admin flow; update both
occurrences of those strings to reflect the non-admin scope (e.g., "Set default
storage location for non-admin backups." and adjust the example command text to
the non-admin command path) so the help text and example match the non-admin
backup context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@cmd/non-admin/backup/create.go`:
- Around line 64-66: The user-facing guidance strings in create.go that
currently read "Set default storage location for all backups." and show the
example "oc oadp client config set default-nabsl=my-nabsl" are incorrect for
this non-admin flow; update both occurrences of those strings to reflect the
non-admin scope (e.g., "Set default storage location for non-admin backups." and
adjust the example command text to the non-admin command path) so the help text
and example match the non-admin backup context.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4deb38e and 277ce5f.

📒 Files selected for processing (1)
  • cmd/non-admin/backup/create.go

@Joeavaikath Joeavaikath merged commit 424c16a into migtools:oadp-dev Mar 2, 2026
16 checks passed
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.

Allow non-admin users to set a default nabsl to avoid specifying --storage-location each time

2 participants