Skip to content

feat(BRE2-810): sudo gating, brev upgrade#320

Merged
patelspratik merged 3 commits into
mainfrom
BRE2-810-sudogate
Mar 9, 2026
Merged

feat(BRE2-810): sudo gating, brev upgrade#320
patelspratik merged 3 commits into
mainfrom
BRE2-810-sudogate

Conversation

@patelspratik
Copy link
Copy Markdown
Contributor

@patelspratik patelspratik commented Mar 9, 2026

  • Adding user warning when sudo is required
  • Adding upgrade command
  • remove tmux remote install

@patelspratik patelspratik changed the title feat(BRE2-810): sudo gating. Remove tmux remote install feat(BRE2-810): sudo gating, brev upgrade Mar 9, 2026
@patelspratik patelspratik marked this pull request as ready for review March 9, 2026 18:27
@patelspratik patelspratik requested a review from a team as a code owner March 9, 2026 18:27
drewmalin
drewmalin previously approved these changes Mar 9, 2026
Comment thread pkg/sudo/sudo.go Outdated

const (
// StatusRoot means the process is already running as root.
StatusRoot Status = iota
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.

Personal nitpick but I don't love iota as it ties data to the syntax of the code (if we ever change the order of these values, the Status integer value will change).

Comment thread pkg/cmd/upgrade/detector.go Outdated

const (
// InstallMethodDirect means brev was installed via direct binary download.
InstallMethodDirect InstallMethod = iota
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.

Same comment about iota

Comment thread pkg/cmd/upgrade/runner.go Outdated
return fmt.Errorf("could not find release for %s/%s", osName, arch)
}
// Trim trailing newline
downloadURL = downloadURL[:len(downloadURL)-1]
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.

Is this newline guaranteed to be there?

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.

rewrote to use script instead

Comment thread pkg/cmd/upgrade/runner.go Outdated
downloadURL = downloadURL[:len(downloadURL)-1]

// Create temp directory
tmpDir, err := os.MkdirTemp("", "brev-upgrade-*")
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.

Why the *?

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.

apparently this controls where the random string goes. By default it gets appended, removing.

Comment thread pkg/cmd/upgrade/runner.go Outdated

// Install with sudo
brevPath := filepath.Join(tmpDir, "brev")
t.Vprint("Installing to /usr/local/bin/brev...")
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.

Nit: could throw /usr/local/bin/brev into a const

Comment thread pkg/cmd/register/register_test.go Outdated
if err != nil {
t.Fatalf("Exists error: %v", err)
exists, eerr := regStore.Exists()
if eerr != nil {
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.

Changing err to eerr seems unnecessary here

return upgradeViaDirect(t, deps)
default:
return fmt.Errorf("unknown install method")
}
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.

Can we also install the latest skill?

@patelspratik patelspratik merged commit e5ec5f1 into main Mar 9, 2026
9 checks passed
@patelspratik patelspratik deleted the BRE2-810-sudogate branch March 9, 2026 22:05
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.

3 participants