Skip to content
Draft
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
461 changes: 282 additions & 179 deletions cmd/power.go

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions cmd/power_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"bytes"
"testing"
)

// TestPowerCommandExecutes guards against shorthand-flag collisions between the
// power subcommand and the root command's persistent flags. pflag merges the
// root persistent flags into a subcommand's flagset at execution time and
// panics on a duplicate shorthand (e.g. the historical --list-reset-types/-l vs
// --log-level/-l clash). Executing `power --help` forces that merge without
// running the command body, so any reintroduced collision fails here instead of
// at runtime for every user.
func TestPowerCommandExecutes(t *testing.T) {
var out bytes.Buffer
rootCmd.SetOut(&out)
rootCmd.SetErr(&out)
rootCmd.SetArgs([]string{"power", "--help"})
t.Cleanup(func() { rootCmd.SetArgs(nil) })

// A shorthand collision surfaces as a panic during flag merge; the test
// fails (rather than the process aborting) if that regresses.
if err := rootCmd.Execute(); err != nil {
t.Fatalf("executing `power --help` returned an error: %v", err)
}
if out.Len() == 0 {
t.Fatal("expected help output for `power --help`, got none")
}
}
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (
"github.com/OpenCHAMI/magellan/internal/format"
logger "github.com/OpenCHAMI/magellan/internal/log"
"github.com/OpenCHAMI/magellan/internal/util"
// Register the in-tree BMC vendor plugins for their init() side effects so
// vendor detection can dispatch to them at runtime.
_ "github.com/OpenCHAMI/magellan/pkg/bmc/vendors"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
61 changes: 26 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,65 +1,56 @@
module github.com/OpenCHAMI/magellan

go 1.23

toolchain go1.24.5
go 1.26.0

require (
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548
github.com/go-chi/chi/v5 v5.1.0
github.com/go-chi/chi/v5 v5.3.0
github.com/jmoiron/sqlx v1.4.0
github.com/lestrrat-go/jwx v1.2.29
github.com/mattn/go-sqlite3 v1.14.22
github.com/lestrrat-go/jwx v1.2.31
github.com/mattn/go-sqlite3 v1.14.45
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stmcginnis/gofish v0.19.0
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
github.com/stmcginnis/gofish v0.22.0
golang.org/x/exp v0.0.0-20260611194520-c48552f49976
)

require (
github.com/Cray-HPE/hms-xname v1.4.0
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.9.0
golang.org/x/crypto v0.32.0
github.com/rs/zerolog v1.35.1
github.com/stretchr/testify v1.11.1
golang.org/x/crypto v0.53.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/google/go-cmp v0.6.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/goccy/go-json v0.10.6 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/blackmagic v1.0.4 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pelletier/go-toml/v2 v2.3.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/sys v0.46.0 // indirect
golang.org/x/text v0.38.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
Loading
Loading