Skip to content

Strip nonadmin oadp 1.4#212

Merged
NicholasYancey merged 6 commits into
migtools:oadp-1.4from
NicholasYancey:strip-nonadmin-oadp-1.4
Jul 1, 2026
Merged

Strip nonadmin oadp 1.4#212
NicholasYancey merged 6 commits into
migtools:oadp-1.4from
NicholasYancey:strip-nonadmin-oadp-1.4

Conversation

@NicholasYancey

Copy link
Copy Markdown
Contributor

Why the changes were made

The OADP 1.4 operator does not ship the non-admin controller (RELATED_IMAGE_NON_ADMIN_CONTROLLER is absent from config/manager/manager.yaml on the oadp-1.4 branch, present on oadp-1.5). All non admin commands have been removed, along with the self service doc due to non admin not being supported in oadp-1.4. README and docs/OADP-1.4.md doc changes are handled separately in PR #210

How to test the changes made

  1. Build the binary: make build
  2. Verify non-admin commands are gone: ./kubectl-oadp --help should show no nonadmin or nabsl-request subcommands
  3. Verify admin commands still work: oc oadp backup --help, oc oadp restore --help, oc oadp schedule --help
  4. Run unit tests: make test

@NicholasYancey NicholasYancey self-assigned this Jun 30, 2026
@openshift-ci openshift-ci Bot requested a review from mpryc June 30, 2026 19:40
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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

Review profile: CHILL

Plan: Pro

Run ID: c3160185-7257-4544-bab3-3f64d43a2fe9

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:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Comment thread cmd/setup/detector.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we even need admin detection?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do not believe so, will edit files to align with no admin detection

@Joeavaikath

Copy link
Copy Markdown
Contributor

What a -10k nuke!
I really hope I didn't wire it in a way that makes this hard, sorry @NicholasYancey

@NicholasYancey NicholasYancey requested a review from kaovilai June 30, 2026 23:28

@Joeavaikath Joeavaikath 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.

Don't forget to add the oadp-cli tests to the oadp-operator 1.4 version

@openshift-ci openshift-ci Bot added the approved label Jul 1, 2026
Comment thread integration_test.go

t.Run("all major commands exist", func(t *testing.T) {
majorCommands := []string{"backup", "restore", "nabsl-request", "nonadmin", "client", "version"}
majorCommands := []string{"backup", "restore", "schedule", "backup-location", "client", "version", "must-gather", "setup"}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are these not in main/oadp-1.6/oadp-1.5?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@coderabbitai Please check and if confirmed create issue track fix for other branches for missing schedule etc.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# List branches
git branch -r | grep -E 'main|oadp-1\.[456]' || true

echo "---- Checking root command registrations per branch ----"
for br in origin/main origin/oadp-1.6 origin/oadp-1.5 origin/oadp-1.4; do
  echo "== Branch: $br =="
  git show "$br:integration_test.go" 2>/dev/null | grep -A3 'majorCommands :=' || echo "file/section not found"
  echo
done

echo "---- Search for root command registration files ----"
for br in origin/main origin/oadp-1.6 origin/oadp-1.5 origin/oadp-1.4; do
  echo "== Branch: $br =="
  git ls-tree -r "$br" --name-only | grep -iE 'root\.go|cmd\.go' | head -20
done

Length of output: 5225


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- remote branches ----"
git branch -r

echo "---- fetch all branches ----"
git fetch origin main oadp-1.6 oadp-1.5 oadp-1.4 2>&1 || true

for br in main oadp-1.6 oadp-1.5 oadp-1.4; do
  echo "== Branch: $br =="
  git show "origin/$br:integration_test.go" 2>/dev/null | grep -A3 'majorCommands :=' || echo "not found in integration_test.go"
  echo "-- cmd root files --"
  git ls-tree -r "origin/$br" --name-only 2>/dev/null | grep -iE '(^|/)(root|cmd)\.go$' | head -20
  echo
done

Length of output: 1044


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- List branches via gh api ----"
gh api repos/migtools/oadp-cli/branches --paginate --jq '.[].name'

echo "---- PR `#212` base branch ----"
gh pr view 212 --repo migtools/oadp-cli --json baseRefName,headRefName

Length of output: 785


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for br in oadp-dev oadp-1.6 oadp-1.5 oadp-1.4; do
  echo "======================== Branch: $br ========================"
  echo "-- integration_test.go majorCommands --"
  gh api "repos/migtools/oadp-cli/contents/integration_test.go?ref=$br" --jq '.content' 2>/dev/null | base64 -d 2>/dev/null | grep -A3 'majorCommands :=' || echo "not found"
  echo
done

Length of output: 1601


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for br in oadp-dev oadp-1.6 oadp-1.5 oadp-1.4; do
  echo "======================== Branch: $br ========================"
  echo "-- searching for AddCommand registrations of schedule/backup-location/must-gather/setup --"
  gh api "repos/migtools/oadp-cli/git/trees/$br?recursive=true" --jq '.tree[].path' 2>/dev/null | grep -iE 'root\.go$|cmd\.go$' 
done

Length of output: 1204


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for br in oadp-dev oadp-1.6 oadp-1.5 oadp-1.4; do
  echo "======================== Branch: $br ========================"
  gh api "repos/migtools/oadp-cli/contents/cmd/root.go?ref=$br" --jq '.content' 2>/dev/null | base64 -d 2>/dev/null | grep -nE 'AddCommand|schedule|backup-location|must-gather|setup' 
  echo
done

Length of output: 4007


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for br in oadp-dev oadp-1.6 oadp-1.5 oadp-1.4; do
  echo "======================== Branch: $br ========================"
  gh api "repos/migtools/oadp-cli/contents/cmd/root.go?ref=$br" --jq '.content' 2>/dev/null | base64 -d 2>/dev/null | grep -nE 'backup-location|backuplocation|NewBackupLocation|bsl' 
  echo
done

Length of output: 2721


🏁 Script executed:

#!/bin/bash
set -euo pipefail

body=$(cat <<'EOF'
### Summary
`integration_test.go`'s `TestCommandArchitecture` test (`majorCommands` list in the "all major commands exist" subtest) only checks for `backup`, `restore`, `nabsl-request`, `nonadmin`, `client`, `version`. It does not assert the presence of `schedule`, `backup-location`, `must-gather`, and `setup`, even though `cmd/root.go` registers all of these commands via `schedule.NewCommand(f)`, `backuplocation.NewCommand(f)`, `mustgather.NewMustGatherCommand(f)`, and `setup.NewSetupCommand(f)`.

This was confirmed on `main`/`oadp-dev`, `oadp-1.6`, and `oadp-1.5` — the commands exist in `cmd/root.go` on all of them, but the integration test's command list was never updated to cover them.

PR `#212` fixes this only for the `oadp-1.4` branch (see https://github.com/migtools/oadp-cli/pull/212, comment https://github.com/migtools/oadp-cli/pull/212#discussion_r3506819793).

### Affected branches
- `main` / `oadp-dev`
- `oadp-1.6`
- `oadp-1.5`

### Required change
In `integration_test.go`, update the `majorCommands` slice in `TestCommandArchitecture`'s "all major commands exist" subtest to include `schedule`, `backup-location`, `must-gather`, and `setup` (mirroring the fix applied to `oadp-1.4` in PR `#212`).

### Acceptance criteria
- [ ] `main`/`oadp-dev` integration test asserts `schedule`, `backup-location`, `must-gather`, `setup` in root `--help` output
- [ ] `oadp-1.6` integration test updated similarly
- [ ] `oadp-1.5` integration test updated similarly

Requested by `@kaovilai`
EOF
)

gh issue create \
  --repo migtools/oadp-cli \
  --title "integration_test.go: TestCommandArchitecture missing assertions for schedule, backup-location, must-gather, setup on main/oadp-1.6/oadp-1.5" \
  --body "$body" \
  --assignee kaovilai

Length of output: 2184


🏁 Script executed:

#!/bin/bash
set -euo pipefail

body=$(cat <<'EOF'
### Summary
`integration_test.go`'s `TestCommandArchitecture` test (`majorCommands` list in the "all major commands exist" subtest) only checks for `backup`, `restore`, `nabsl-request`, `nonadmin`, `client`, `version`. It does not assert the presence of `schedule`, `backup-location`, `must-gather`, and `setup`, even though `cmd/root.go` registers all of these commands via `schedule.NewCommand(f)`, `backuplocation.NewCommand(f)`, `mustgather.NewMustGatherCommand(f)`, and `setup.NewSetupCommand(f)`.

This was confirmed on `main`/`oadp-dev`, `oadp-1.6`, and `oadp-1.5` — the commands exist in `cmd/root.go` on all of them, but the integration test's command list was never updated to cover them.

PR `#212` fixes this only for the `oadp-1.4` branch (see https://github.com/migtools/oadp-cli/pull/212, comment https://github.com/migtools/oadp-cli/pull/212#discussion_r3506819793).

### Affected branches
- `main` / `oadp-dev`
- `oadp-1.6`
- `oadp-1.5`

### Required change
In `integration_test.go`, update the `majorCommands` slice in `TestCommandArchitecture`'s "all major commands exist" subtest to include `schedule`, `backup-location`, `must-gather`, and `setup` (mirroring the fix applied to `oadp-1.4` in PR `#212`).

### Acceptance criteria
- [ ] `main`/`oadp-dev` integration test asserts `schedule`, `backup-location`, `must-gather`, `setup` in root `--help` output
- [ ] `oadp-1.6` integration test updated similarly
- [ ] `oadp-1.5` integration test updated similarly

Requested by `@kaovilai`
EOF
)

gh issue create \
  --repo migtools/oadp-cli \
  --title "integration_test.go: TestCommandArchitecture missing assertions for schedule, backup-location, must-gather, setup on main/oadp-1.6/oadp-1.5" \
  --body "$body"

Length of output: 1962


@kaovilai Confirmed — checked cmd/root.go on oadp-dev/main, oadp-1.6, and oadp-1.5, and all of them already register schedule (schedule.NewCommand(f)), backup-location (backuplocation.NewCommand(f)), must-gather (mustgather.NewMustGatherCommand(f)), and setup (setup.NewSetupCommand(f)) as real commands. So the CLI functionality is present everywhere — it's integration_test.go's TestCommandArchitecture test that's out of date on those branches, since its majorCommands list only checks for backup, restore, nabsl-request, nonadmin, client, version and was never updated to cover the newer commands.

I opened a tracking issue: #215

Note: I wasn't able to assign it to you directly (the GitHub API returned a permissions error for assigning via the bot), so you may want to self-assign it manually.

(◕‿◕) all set — issue filed for the other branches


🧬 Code Graph Analysis Results

Relevant snippets for integration_test.go (user request about “missing schedule” across other branches)

internal/testutil/testutil.go

Lines 97-122RunCommand(t *testing.T, binaryPath string, args ...string) (string, error)

func RunCommand(t *testing.T, binaryPath string, args ...string) (string, error) {
	t.Helper()

	ctx, cancel := context.WithTimeout(context.Background(), TestTimeout)
	defer cancel()

	cmd := exec.CommandContext(ctx, binaryPath)
	cmd.Args = append(cmd.Args, args...)

	var stdout, stderr bytes.Buffer
	cmd.Stdout = &stdout
	cmd.Stderr = &stderr

	err := cmd.Run()

	// Log the command and output for debugging
	t.Logf("Command: %s %s", binaryPath, strings.Join(args, " "))
	if stdout.Len() > 0 {
		t.Logf("Stdout: %s", stdout.String())
	}
	if stderr.Len() > 0 {
		t.Logf("Stderr: %s", stderr.String())
	}

	return stdout.String(), err
}

Lines 40-62GetProjectRoot(t *testing.T) string

func GetProjectRoot(t *testing.T) string {
	t.Helper()

	// Get the directory of the current file
	_, filename, _, ok := runtime.Caller(0)
	if !ok {
		t.Fatal("Failed to get caller information")
	}

	// Navigate up to find the project root (where go.mod is)
	dir := filepath.Dir(filename)
	for {
		if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil {
			return dir
		}

		parent := filepath.Dir(dir)
		if parent == dir {
			t.Fatal("Could not find project root (go.mod not found)")
		}
		dir = parent
	}
}

Lines 65-94BuildCLIBinary(t *testing.T) string

func BuildCLIBinary(t *testing.T) string {
	t.Helper()

	projectRoot := GetProjectRoot(t)

	// Create temp directory for the binary
	tempDir := t.TempDir()
	binaryName := "oadp-test"
	if runtime.GOOS == "windows" {
		binaryName += ".exe"
	}
	binaryPath := filepath.Join(tempDir, binaryName)

	t.Logf("Building CLI binary: %s", binaryPath)
	t.Logf("Project root: %s", projectRoot)

	// Build the binary with a longer timeout for CI environments
	ctx, cancel := context.WithTimeout(context.Background(), BuildTimeout)
	defer cancel()

	cmd := exec.CommandContext(ctx, "go", "build", "-o", binaryPath, ".")
	cmd.Dir = projectRoot
	output, err := cmd.CombinedOutput()

	if err != nil {
		t.Fatalf("Failed to build CLI binary: %v\nOutput: %s", err, string(output))
	}

	return binaryPath
}

Lines 143-162SetupTempHome(t *testing.T) (string, func())

func SetupTempHome(t *testing.T) (string, func()) {
	t.Helper()

	tempHome := t.TempDir()
	configDir := filepath.Join(tempHome, ".config", "velero")
	if err := os.MkdirAll(configDir, 0755); err != nil {
		t.Fatalf("Failed to create config directory: %v", err)
	}

	// Save original HOME
	originalHome := os.Getenv("HOME")
	os.Setenv("HOME", tempHome)

	// Return cleanup function
	cleanup := func() {
		os.Setenv("HOME", originalHome)
	}

	return tempHome, cleanup
}

cmd/setup/setup.go

Lines 51-83(*SetupOptions) Run(c *cobra.Command, f client.Factory) error

func (o *SetupOptions) Run(c *cobra.Command, f client.Factory) error {
	c.SilenceUsage = true

	// Check if already configured (unless --force flag set)
	if !o.Force {
		existingConfig, err := shared.ReadVeleroClientConfig()
		if err != nil {
			return fmt.Errorf("failed to read existing config: %w", err)
		}

		if existingConfig.Namespace != "" {
			fmt.Println("OADP CLI is already configured.")
			fmt.Println()
			o.printCurrentConfig(existingConfig)
			fmt.Println()
			fmt.Println("To reconfigure, run: oc oadp setup --force")
			return nil
		}
	}

	config, err := shared.ReadVeleroClientConfig()
	if err != nil {
		return fmt.Errorf("failed to read existing config: %w", err)
	}

	if err := shared.WriteVeleroClientConfig(config); err != nil {
		return fmt.Errorf("failed to write config: %w", err)
	}

	o.printSetupSuccess()

	return nil
}

@openshift-ci

openshift-ci Bot commented Jul 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Joeavaikath, kaovilai, NicholasYancey

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:
  • OWNERS [Joeavaikath,kaovilai]

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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants