-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added 'delete' command in 'tink hardware' cli
- Loading branch information
parauliya
committed
Jun 4, 2020
1 parent
28fe0aa
commit 5f6521f
Showing
6 changed files
with
198 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright © 2018 packet.net | ||
|
||
package hardware | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/tinkerbell/tink/client" | ||
"github.com/tinkerbell/tink/protos/hardware" | ||
) | ||
|
||
// idCmd represents the id command | ||
var deleteCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete hardware by id", | ||
Example: "tink hardware delete 224ee6ab-ad62-4070-a900-ed816444cec0 cb76ae54-93e9-401c-a5b2-d455bb3800b1", | ||
Args: func(_ *cobra.Command, args []string) error { | ||
return verifyUUIDs(args) | ||
}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
for _, id := range args { | ||
_, err := client.HardwareClient.Delete(context.Background(), &hardware.DeleteRequest{ID: id}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Println("Hardware data with id", id, "deleted successfully") | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
SubCommands = append(SubCommands, deleteCmd) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.