Skip to content

Conversation

@Joeavaikath
Copy link
Contributor

@Joeavaikath Joeavaikath commented Feb 4, 2026

Why the changes were made

  1. Format (2ad9660)
  • Minor formatting fixes to cmd/non-admin/restore/create.go
  1. Add comprehensive documentation for nonadmin MVP implementation (3aa9ce3)

Major documentation addition (+921 lines):

  • backup/README.md: MVP flag reference (13 flags), restricted flags table, future enhancements, examples
  • restore/README.md: MVP flag reference (7 flags), restricted flags documentation, examples
  • docs/oadp-self-service.md: 639-line comprehensive guide covering architecture, workflows, admin setup, security, and CLI implementation
  1. Update nonadmin backup and restore tests for MVP flags (10eeefc)

Aligned tests with MVP implementation:

  • Removed --assume-yes from backup tests
  • Removed --namespace-mappings from restore tests (restricted for non-admin)
  • Added --selector and --or-selector flags to restore tests
  • Updated flag lists and examples
  1. Fix nonadmin delete hanging and standardize resource naming (fa09407)

Critical bug fixes (-302/+104 lines):

  • Fixed delete command hanging by excluding nonadmin commands from output wrapper
  • Made backup names required (cobra.ExactArgs(1))
  • Made restore names optional with auto-generation using "restore-" prefix
  1. Add lint-fix target (1e4164d)
  • Added lint-fix Makefile target for automated code linting
  1. Implement non-admin restore commands (Phase 2: describe, logs, delete) (c3b45c6)

Completed restore functionality (+1,181 lines):

  • describe: Display detailed restore info with optional --details flag
  • logs: Stream restore logs using NonAdminDownloadRequest
  • delete: Delete restores with --confirm and --all flags
  • Features: color-coded phase display, comprehensive test coverage (51 tests), support for both command orderings
  1. Implement non-admin restore commands (Phase 1: create and get) (5fe4d04)

Foundation for restore commands (+1,000 lines):

  • create: Create restores from backups with MVP flags
  • get: View restore status and list restores
  • nonadminrestore_builder.go: Builder pattern for NAR CR construction
  • Comprehensive test suite (332 lines)
  • Support for noun-verb and verb-noun syntax

Joeavaikath and others added 2 commits February 4, 2026 13:01
Add create and get subcommands for non-admin restores following the
established pattern from backup commands. Phase 1 provides core
functionality for creating restores from backups and viewing restore
status, enabling users to perform restore operations through both
noun-verb and verb-noun command syntax.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
Add three new commands to complete the non-admin restore functionality:

- describe: Display detailed restore information with optional --details flag
  for RestoreResults, RestoreItemOperations, and RestoreResourceList
- logs: Stream restore operation logs using NonAdminDownloadRequest
- delete: Delete restore CRs with --confirm and --all flags

All commands support both noun-verb (restore describe) and verb-noun
(describe restore) orderings, work with 'na' shorthand, and use the
'kubectl oadp' prefix in examples.

Key features:
- --details flag for additional restore information (describe only)
- --request-timeout flag for download operations (describe and logs)
- --confirm flag to skip confirmation prompts (delete only)
- --all flag to delete all restores in namespace (delete only)
- Color-coded phase display (green/yellow/red)
- Restore-specific fields: backup name, namespace mappings, restore PVs
- Comprehensive test coverage with 51 passing tests

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
@Joeavaikath Joeavaikath changed the title Nar phase1 Non-admin Restore for OADP CLI Feb 4, 2026
@Joeavaikath Joeavaikath linked an issue Feb 4, 2026 that may be closed by this pull request
Signed-off-by: Joseph <jvaikath@redhat.com>
Comment on lines 73 to 93
type CreateOptions struct {
Name string
BackupName string
IncludeNamespaces flag.StringArray
ExcludeNamespaces flag.StringArray
IncludeResources flag.StringArray
ExcludeResources flag.StringArray
NamespaceMappings flag.Map
Labels flag.Map
Annotations flag.Map
Selector flag.LabelSelector
OrSelector flag.OrLabelSelector
RestoreVolumes flag.OptionalBool
PreserveNodePorts flag.OptionalBool
IncludeClusterResources flag.OptionalBool
ExistingResourcePolicy string
ItemOperationTimeout time.Duration
ResourceModifierConfigMap string
client kbclient.WithWatch
currentNamespace string
}
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, I tried importing "github.com/vmware-tanzu/velero/pkg/cmd/cli/restore"

type CreateOptions struct {
	restore.CreateOptions
	Name                      string
	client                    kbclient.WithWatch
	currentNamespace          string
}

func NewCreateOptions() *CreateOptions {
	return &CreateOptions{
		CreateOptions: restore.CreateOptions{
			Labels: flag.NewMap(),
			Annotations:       flag.NewMap(),
			NamespaceMappings: flag.NewMap(),
		},
	}
}

Seems to compile. Could be anti-pattern tho..

Anyway this would add writesparsefiles and other settings which is in non-admin CRD. Thoughts on why some settings are missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems like a neater way to do it
The reason I was writing it up from scratch was to exclude stuff non-admin would not use

This approach seems nicer, let me see if I can piggyback w/ some control

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to only implement mvp flags, have READMEs around flags that are supported by nonadmin for backup and restore
If that looks fine can get this in

Joeavaikath and others added 5 commits February 6, 2026 10:06
Fixes three issues with nonadmin commands:

1. Delete command hanging: Excluded all nonadmin commands from the
   output wrapper in cmd/root.go. The wrapper was capturing stdout
   which prevented interactive prompts (like delete confirmation) from
   reaching the terminal. Since we have full control over nonadmin
   command output, wrapping is unnecessary.

2. Backup create naming: Changed to require a name (cobra.ExactArgs(1)).
   The controller requires backup names to be specified upfront.

3. Restore create naming: Made name optional (cobra.MaximumNArgs(1)).
   When no name is provided, uses GenerateName with "restore-" prefix
   for auto-generation by the API server. Updated examples and builder
   to support this pattern.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
Updated test expectations to match the MVP implementation:

Backup tests:
- Removed --assume-yes flag (no longer needed with simplified flow)
- Updated create flags test to reflect MVP flag list with correct order
- Added comment noting these are MVP-only flags

Restore tests:
- Removed --namespace-mappings (restricted for non-admin users)
- Added --selector and --or-selector (MVP label selection)
- Updated create flags test to reflect MVP implementation
- Updated examples to show selector usage instead of namespace-mappings

These changes ensure tests validate the actual MVP implementation
rather than the full Velero feature set.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
Added detailed documentation covering the OADP self-service feature
and the CLI MVP implementation:

1. cmd/non-admin/backup/README.md:
   - Complete MVP flag reference (13 flags)
   - Restricted flags table with API reasons
   - Future enhancement flags categorized by type
   - Architecture notes on struct embedding pattern
   - Examples for common backup scenarios

2. cmd/non-admin/restore/README.md:
   - Complete MVP flag reference (7 flags)
   - Restricted flags table with API reasons
   - Future enhancement flags categorized by type
   - Architecture notes matching backup pattern
   - Examples for common restore scenarios

3. docs/oadp-self-service.md:
   - Overview of OADP self-service architecture
   - NAB/NAR/NABSL/NADR glossary and workflows
   - Cluster administrator setup instructions
   - User permissions and workflow examples
   - Admin enforceable spec fields reference
   - Security considerations
   - CLI MVP approach and implementation details

The documentation provides clear guidance on:
- Which flags are available in MVP vs future enhancements
- Why certain flags are restricted (API limitations)
- How the struct embedding pattern enables future growth
- Complete alignment between CLI and API capabilities

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
Bind factory flags to expose -n/--namespace support for admin Velero
and NABSL commands. Nonadmin commands continue using kubeconfig context
for security isolation.

Changes:
- Add f.BindFlags() to enable namespace flag on admin commands
- Add namespace_flag_test.go to verify flag visibility
- Fix restore test that incorrectly checked for "required" keyword

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
flags.IntVar(&o.ParallelFilesUpload, "parallel-files-upload", 0, "Number of files uploads simultaneously when running a backup. This is only applicable for the kopia uploader")
// NAB-specific control flag
flags.BoolVarP(&o.Force, "force", "f", o.Force, "Force creation without specifying a storage location (uses admin defaults).")
flags.BoolVarP(&o.AssumeYes, "assume-yes", "y", o.AssumeYes, "Assume yes to all prompts and run non-interactively.")
Copy link
Member

Choose a reason for hiding this comment

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

what's happening to assumeyes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

was overkill
was used if you wanted to not explicitly answer yes after supplying --force with non-admin create commands
--force is used when you want to just use the default rather than supplying a storage-location (NABSL)

@Joeavaikath Joeavaikath merged commit 1d723f5 into migtools:oadp-dev Feb 6, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for setting namespace with -n flag when running velero commands NAR crud Support

2 participants