Skip to content

Commit

Permalink
chore(device update): use Cobra to enforce exclusive fields and no ad…
Browse files Browse the repository at this point in the history
…dition args

Signed-off-by: Marques Johansson <[email protected]>
  • Loading branch information
displague committed Aug 26, 2024
1 parent 34ccdcd commit bef3873
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions internal/devices/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ func (c *Client) Update() *cobra.Command {
deviceUpdate.Description = &description
}

if userdata != "" && userdataFile != "" {
return fmt.Errorf("either userdata or userdata-file should be set")
}

if userdataFile != "" {
userdataRaw, readErr := os.ReadFile(userdataFile)
if readErr != nil {
Expand Down Expand Up @@ -135,5 +131,7 @@ func (c *Client) Update() *cobra.Command {
updateDeviceCmd.Flags().StringVarP(&ipxescripturl, "ipxe-script-url", "s", "", "Add or update the URL of the iPXE script.")
updateDeviceCmd.Flags().StringVarP(&customdata, "customdata", "c", "", "Adds or updates custom data to be included with your device's metadata.")
_ = updateDeviceCmd.MarkFlagRequired("id")
updateDeviceCmd.MarkFlagsMutuallyExclusive("userdata", "userdata-file")
updateDeviceCmd.Args = cobra.NoArgs
return updateDeviceCmd
}

0 comments on commit bef3873

Please sign in to comment.