Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show metal-core version #199

Merged
merged 2 commits into from
Jul 5, 2023
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
4 changes: 4 additions & 0 deletions cmd/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ func machineResponseToCreate(r *models.V1MachineResponse) *models.V1MachineAlloc
}

func machineResponseToUpdate(r *models.V1MachineResponse) *models.V1MachineUpdateRequest {
// SSHPublicKeys should can not be updated by metalctl
// nolint:exhaustruct
return &models.V1MachineUpdateRequest{
Description: pointer.PointerOrNil(pointer.SafeDeref(r.Allocation).Description),
ID: r.ID,
Expand Down Expand Up @@ -746,6 +748,8 @@ func (c *machineCmd) updateRequestFromCLI(args []string) (*models.V1MachineUpdat
newTags = append(newTags, t)
}

// SSHPublicKeys should can not be updated by metalctl
// nolint:exhaustruct
return &models.V1MachineUpdateRequest{
ID: pointer.Pointer(id),
Description: pointer.Pointer(viper.GetString("description")),
Expand Down
19 changes: 10 additions & 9 deletions cmd/switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ var (
Partition: partition1,
RackID: pointer.Pointer("rack-1"),
Os: &models.V1SwitchOS{
Vendor: "SONiC",
Version: "1",
Vendor: "SONiC",
Version: "1",
MetalCoreVersion: "1.2.3",
},
ManagementIP: "1.2.3.4",
ManagementUser: "root",
Expand Down Expand Up @@ -144,9 +145,9 @@ ID PARTITION RACK OS STATUS
2 1 rack-1 🐢  ●
`),
wantWideTable: pointer.Pointer(`
ID PARTITION RACK OS IP MODE LAST SYNC SYNC DURATION LAST SYNC ERROR
1 1 rack-1 SONiC/1 1.2.3.4 operational 0s 1s 5m ago: error
2 1 rack-1 Cumulus/2 operational 0s 1s 5m ago: error
ID PARTITION RACK OS METALCORE IP MODE LAST SYNC SYNC DURATION LAST SYNC ERROR
1 1 rack-1 SONiC/1 1.2.3 1.2.3.4 operational 0s 1s 5m ago: error
2 1 rack-1 Cumulus/2 operational 0s 1s 5m ago: error
`),
template: pointer.Pointer("{{ .id }} {{ .name }}"),
wantTemplate: pointer.Pointer(`
Expand Down Expand Up @@ -191,8 +192,8 @@ ID PARTITION RACK OS STATUS
1 1 rack-1 🦔  ●
`),
wantWideTable: pointer.Pointer(`
ID PARTITION RACK OS IP MODE LAST SYNC SYNC DURATION LAST SYNC ERROR
1 1 rack-1 SONiC/1 1.2.3.4 operational 0s 1s 5m ago: error
ID PARTITION RACK OS METALCORE IP MODE LAST SYNC SYNC DURATION LAST SYNC ERROR
1 1 rack-1 SONiC/1 1.2.3 1.2.3.4 operational 0s 1s 5m ago: error
`),
template: pointer.Pointer("{{ .id }} {{ .name }}"),
wantTemplate: pointer.Pointer(`
Expand Down Expand Up @@ -355,8 +356,8 @@ ID PARTITION RACK OS STATUS
1 1 rack-1 🦔  ●
`),
wantWideTable: pointer.Pointer(`
ID PARTITION RACK OS IP MODE LAST SYNC SYNC DURATION LAST SYNC ERROR
1 1 rack-1 SONiC/1 1.2.3.4 operational 0s 1s 5m ago: error
ID PARTITION RACK OS METALCORE IP MODE LAST SYNC SYNC DURATION LAST SYNC ERROR
1 1 rack-1 SONiC/1 1.2.3 1.2.3.4 operational 0s 1s 5m ago: error
`),
template: pointer.Pointer("{{ .id }} {{ .name }}"),
wantTemplate: pointer.Pointer(`
Expand Down
6 changes: 4 additions & 2 deletions cmd/tableprinters/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (t *TablePrinter) SwitchTable(data []*models.V1SwitchResponse, wide bool) (

header := []string{"ID", "Partition", "Rack", "OS", "Status"}
if wide {
header = []string{"ID", "Partition", "Rack", "OS", "IP", "Mode", "Last Sync", "Sync Duration", "Last Sync Error"}
header = []string{"ID", "Partition", "Rack", "OS", "MetalCore", "IP", "Mode", "Last Sync", "Sync Duration", "Last Sync Error"}
}

for _, s := range data {
Expand Down Expand Up @@ -66,6 +66,7 @@ func (t *TablePrinter) SwitchTable(data []*models.V1SwitchResponse, wide bool) (

os := ""
osIcon := ""
metalCore := ""
if s.Os != nil {
switch strings.ToLower(s.Os.Vendor) {
case "cumulus":
Expand All @@ -80,10 +81,11 @@ func (t *TablePrinter) SwitchTable(data []*models.V1SwitchResponse, wide bool) (
if s.Os.Version != "" {
os = os + "/" + s.Os.Version
}
metalCore = s.Os.MetalCoreVersion
}

if wide {
rows = append(rows, []string{id, partition, rack, os, s.ManagementIP, mode, syncAgeStr, syncDurStr, syncError})
rows = append(rows, []string{id, partition, rack, os, metalCore, s.ManagementIP, mode, syncAgeStr, syncDurStr, syncError})
} else {
rows = append(rows, []string{id, partition, rack, osIcon, shortStatus})
}
Expand Down
24 changes: 13 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ require (
github.com/go-openapi/strfmt v0.21.7
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
github.com/metal-stack/metal-go v0.22.5
github.com/metal-stack/metal-lib v0.12.2
github.com/metal-stack/updater v1.1.4
github.com/metal-stack/metal-go v0.22.7
github.com/metal-stack/metal-lib v0.12.3
github.com/metal-stack/updater v1.1.5
github.com/metal-stack/v v1.0.3
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/afero v1.9.5
Expand All @@ -27,7 +27,7 @@ require (
golang.org/x/term v0.9.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.27.2
tailscale.com v1.42.0
tailscale.com v1.44.0
)

require (
Expand All @@ -36,6 +36,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230426101702-58e86b294756 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/akutz/memconn v0.1.0 // indirect
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 // indirect
Expand All @@ -56,6 +57,7 @@ require (
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cheggaaa/pb/v3 v3.1.2 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/coreos/go-iptables v0.6.0 // indirect
github.com/coreos/go-oidc/v3 v3.6.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
Expand All @@ -70,12 +72,12 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/goccy/go-yaml v1.11.0 // indirect
Expand All @@ -84,7 +86,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-github/v48 v48.2.0 // indirect
github.com/google/go-github/v53 v53.2.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand All @@ -94,20 +96,20 @@ require (
github.com/illarion/gonotify v1.0.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/insomniacslk/dhcp v0.0.0-20230516061539-49801966e6cb // indirect
github.com/insomniacslk/dhcp v0.0.0-20230612134759-b20c9ba983df // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86 // indirect
github.com/jsimonetti/rtnetlink v1.3.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/jszwec/csvutil v1.8.0 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/klauspost/compress v1.16.6 // indirect
github.com/kortschak/wol v0.0.0-20200729010619-da482cc4850a // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx v1.2.25 // indirect
github.com/lestrrat-go/jwx v1.2.26 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -128,7 +130,7 @@ require (
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
Expand Down
Loading
Loading