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

report created_at and updated_at from condition API #70

Merged
merged 2 commits into from
Nov 17, 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
11 changes: 11 additions & 0 deletions cmd/collect/collect.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package collect

import (
"log"

"github.com/metal-toolbox/mctl/cmd"
"github.com/spf13/cobra"
)

var serverIDStr string

var collect = &cobra.Command{
Use: "collect",
Short: "Collect current server firmware status and bios configuration",
Expand All @@ -16,4 +20,11 @@ var collect = &cobra.Command{

func init() {
cmd.RootCmd.AddCommand(collect)

pflags := collect.PersistentFlags()
pflags.StringVarP(&serverIDStr, "server", "s", "", "server id (typically a UUID)")

if err := collect.MarkPersistentFlagRequired("server"); err != nil {
log.Fatalf("marking server flag as required: %s", err.Error())
}
}
18 changes: 7 additions & 11 deletions cmd/collect/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
)

type collectInventoryFlags struct {
serverID string
skipFirmwareStatusCollect bool
skipBiosConfigCollect bool
}
Expand All @@ -27,9 +26,9 @@ var (
)

var collectInventoryCmd = &cobra.Command{
Use: "inventory",
Use: "inventory --server | -s <server uuid>",
Short: "Collect current server firmware status and bios configuration",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
collectInventory(cmd.Context())

},
Expand All @@ -38,7 +37,7 @@ var collectInventoryCmd = &cobra.Command{
func collectInventory(ctx context.Context) {
theApp := mctl.MustCreateApp(ctx)

serverID, err := uuid.Parse(flagsDefinedCollectInventory.serverID)
serverID, err := uuid.Parse(serverIDStr)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -81,11 +80,8 @@ func init() {
flagsDefinedCollectInventory = &collectInventoryFlags{}

collect.AddCommand(collectInventoryCmd)
collectInventoryCmd.PersistentFlags().StringVar(&flagsDefinedCollectInventory.serverID, "server", "", "server UUID")
collectInventoryCmd.PersistentFlags().BoolVar(&flagsDefinedCollectInventory.skipFirmwareStatusCollect, "skip-fw-status", false, "Skip firmware status data collection")
collectInventoryCmd.PersistentFlags().BoolVar(&flagsDefinedCollectInventory.skipBiosConfigCollect, "skip-bios-config", false, "Skip BIOS configuration data collection")

if err := collectInventoryCmd.MarkPersistentFlagRequired("server"); err != nil {
log.Fatal(err)
}
collectInventoryCmd.PersistentFlags().BoolVar(&flagsDefinedCollectInventory.skipFirmwareStatusCollect,
"skip-fw-status", false, "Skip firmware status data collection")
collectInventoryCmd.PersistentFlags().BoolVar(&flagsDefinedCollectInventory.skipBiosConfigCollect,
"skip-bios-config", false, "Skip BIOS configuration data collection")
}
9 changes: 0 additions & 9 deletions cmd/collect/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
rctypes "github.com/metal-toolbox/rivets/condition"
)

var serverIDStr string

var inventoryStatus = &cobra.Command{
Use: "status --server | -s <server uuid>",
Short: "check the progress of a inventory collection for a server",
Expand Down Expand Up @@ -53,12 +51,5 @@ func statusCheck(ctx context.Context) {
}

func init() {
flags := inventoryStatus.Flags()
flags.StringVarP(&serverIDStr, "server", "s", "", "server id (typically a UUID)")

if err := inventoryStatus.MarkFlagRequired("server"); err != nil {
log.Fatalf("marking server flag as required: %s", err.Error())
}

collect.AddCommand(inventoryStatus)
}
6 changes: 4 additions & 2 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ func FormatConditionResponse(response *coapiv1.ServerResponse) (string, error) {
Kind: rctypes.Kind(inc.Kind),
Parameters: inc.Parameters,
// type conversion until the Condition type is fully moved into the rivets lib
State: rctypes.State(inc.State),
Status: inc.Status,
State: rctypes.State(inc.State),
Status: inc.Status,
UpdatedAt: inc.UpdatedAt,
CreatedAt: inc.CreatedAt,
}

// XXX: seems highly unlikely that we get a response that deserializes cleanly and doesn't
Expand Down
3 changes: 2 additions & 1 deletion docs/mctl_collect.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ mctl collect [flags]
### Options

```
-h, --help help for collect
-h, --help help for collect
-s, --server string server id (typically a UUID)
```

### Options inherited from parent commands
Expand Down
4 changes: 2 additions & 2 deletions docs/mctl_collect_inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
Collect current server firmware status and bios configuration

```
mctl collect inventory [flags]
mctl collect inventory --server | -s <server uuid> [flags]
```

### Options

```
-h, --help help for inventory
--server string server UUID
--skip-bios-config Skip BIOS configuration data collection
--skip-fw-status Skip firmware status data collection
```
Expand All @@ -22,6 +21,7 @@ mctl collect inventory [flags]
```
--config string config file (default is $XDG_CONFIG_HOME/mctl/config.yml)
--reauth re-authenticate with oauth services
-s, --server string server id (typically a UUID)
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/mctl_collect_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ mctl collect status --server | -s <server uuid> [flags]
### Options

```
-h, --help help for status
-s, --server string server id (typically a UUID)
-h, --help help for status
```

### Options inherited from parent commands

```
--config string config file (default is $XDG_CONFIG_HOME/mctl/config.yml)
--reauth re-authenticate with oauth services
-s, --server string server id (typically a UUID)
```

### SEE ALSO
Expand Down
Loading