-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into vc/list-server
- Loading branch information
Showing
7 changed files
with
120 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package cmd | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/google/uuid" | ||
"github.com/metal-toolbox/conditionorc/pkg/api/v1/conditions/types" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/metal-toolbox/mctl/internal/app" | ||
) | ||
|
||
type validationFlags struct { | ||
srvIDStr, fwSetIDStr, output string | ||
} | ||
|
||
var ( | ||
// incoming command line parameters | ||
fwvFlags = &validationFlags{} | ||
) | ||
|
||
var validateFirmwareCmd = &cobra.Command{ | ||
Use: "validate-firmware", | ||
Short: "validate a firmware set", | ||
Run: func(c *cobra.Command, _ []string) { | ||
theApp := MustCreateApp(c.Context()) | ||
|
||
client, err := app.NewConditionsClient(c.Context(), theApp.Config.Conditions, theApp.Reauth) | ||
if err != nil { | ||
log.Fatalf("creating app structure: %s", err.Error()) | ||
} | ||
|
||
srvID, err := uuid.Parse(fwvFlags.srvIDStr) | ||
if err != nil { | ||
log.Fatalf("parsing server id: %s", err.Error()) | ||
} | ||
|
||
fwSetID, err := uuid.Parse(fwvFlags.fwSetIDStr) | ||
if err != nil { | ||
log.Fatalf("parsing firmware set id: %s", err.Error()) | ||
} | ||
|
||
fvr := &types.FirmwareValidationRequest{ | ||
ServerID: srvID, | ||
FirmwareSetID: fwSetID, | ||
} | ||
|
||
resp, err := client.ValidateFirmwareSet(c.Context(), fvr) | ||
if err != nil { | ||
log.Fatalf("making validate firmware call: %s", err.Error()) | ||
} | ||
|
||
PrintResults(fwvFlags.output, resp) | ||
}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(validateFirmwareCmd) | ||
|
||
AddOutputFlag(validateFirmwareCmd, &fwvFlags.output) | ||
AddFirmwareSetFlag(validateFirmwareCmd, &fwvFlags.fwSetIDStr) | ||
AddServerFlag(validateFirmwareCmd, &fwvFlags.srvIDStr) | ||
RequireFlag(validateFirmwareCmd, ServerFlag) | ||
RequireFlag(validateFirmwareCmd, FirmwareSetFlag) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[Auto generated by spf13/cobra]: <> | ||
|
||
## mctl validate-firmware | ||
|
||
validate a firmware set | ||
|
||
``` | ||
mctl validate-firmware -s SERVER --set-id SETID [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for validate-firmware | ||
-o, --output outputType {json|text} (default json) | ||
-s, --server string [required] ID of the server | ||
--set-id string [required] ID of the firmware set | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
-c, --config string config file (default is $XDG_CONFIG_HOME/mctl/config.yml) | ||
--reauth re-authenticate with oauth services | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [mctl](mctl.md) - mctl is a CLI utility to interact with metal toolbox services | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters