Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func newRootCmd() *cobra.Command {
Requires a configuration file (typically bloom.yaml). Use --playbook to specify which playbook to run.`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
checkRootPrivileges("ansible")
runAnsible(args[0])
},
}
Expand All @@ -145,6 +146,7 @@ This command performs the equivalent of Bloom v1 cleanup operations:

By default, this command requires confirmation before proceeding. Use --force to skip confirmation.`,
Run: func(cmd *cobra.Command, args []string) {
checkRootPrivileges("cleanup")
// Check if force flag is used to bypass confirmation
if !forceCleanup {
if !confirmCleanupOperation() {
Expand Down Expand Up @@ -293,6 +295,25 @@ func confirmCleanupOperation() bool {
return true
}

// checkRootPrivileges verifies that the current process is running with root privileges
func checkRootPrivileges(commandName string) {
if os.Getuid() != 0 {
fmt.Fprintf(os.Stderr, "❌ Error: %s requires root privileges\n\n", commandName)
fmt.Fprintf(os.Stderr, "Please run this command with root privileges:\n")
fmt.Fprintf(os.Stderr, " sudo bloom %s", commandName)

// Add the original arguments
if len(os.Args) > 2 {
for _, arg := range os.Args[2:] {
fmt.Fprintf(os.Stderr, " %s", arg)
}
}
fmt.Fprintf(os.Stderr, "\n\n")

os.Exit(1)
}
}

func runClusterCleanup() {
fmt.Println("🧹 Starting Bloom cluster cleanup...")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ data:
spec:
containers:
- name: helper-pod
image: busybox
image: ghcr.io/silogen/cluster-busybox:1.37.0
imagePullPolicy: IfNotPresent
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
app.kubernetes.io/name: local-path-provisioner
app.kubernetes.io/instance: local-path-provisioner
app.kubernetes.io/version: v0.0.29
app.kubernetes.io/version: v0.0.34
spec:
replicas: 1
strategy:
Expand All @@ -26,7 +26,7 @@ spec:
serviceAccountName: local-path-provisioner-service-account
containers:
- name: local-path-provisioner
image: rancher/local-path-provisioner:v0.0.29
image: ghcr.io/silogen/cluster-lpr:v0.0.34
imagePullPolicy: IfNotPresent
command:
- local-path-provisioner
Expand Down
2 changes: 1 addition & 1 deletion pkg/ansible/runtime/playbooks/tasks/setup_local_path.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
spec:
containers:
- name: test-container
image: busybox
image: ghcr.io/silogen/cluster-busybox:1.37.0
command:
- sh
- -c
Expand Down
Loading