Skip to content

Commit

Permalink
Add 'rm' alias to delete command
Browse files Browse the repository at this point in the history
  • Loading branch information
royroyee committed Apr 13, 2024
1 parent 5aee853 commit 686e207
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 28 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ $ alpacon server create
# Delete server
$ alpacon server delete [SERVER NAME]
$ alpacon server rm [SERVER NAME]
Server Name:
Platform(debian, rhel):
Expand Down Expand Up @@ -173,6 +174,18 @@ $ alpacon websh -u [USER NAME] -g [GROUP NAME] [COMMAND]
$ alpacon websh --username=[USER NAME] --groupname=[GROUP NAME] [COMMAND]
```

#### Share your terminal
You can share the current terminal to others via a temporary link:
```bash
# Open a websh terminal and share the current terminal
$ alpacon websh [SERVER NAME] --share
$ alpacon websh [SERVER NAME] --share --read-only true
# Join an existing shared session
$ alpacon websh join --url [SHARED_URL] --password [PASSWORD]
```



#### Identity and Access Management (IAM)
Efficiently manage user and group resources:
Expand All @@ -193,6 +206,7 @@ $ alpacon user update [USER NAME]
# Delete user
$ alpacon user delete [USER NAME]
$ alpacon user rm [USER NAME]
# Managing Groups
Expand All @@ -204,13 +218,15 @@ $ alpacon group describe [GROUP NAME]
# Delete group
$ alpacon group delete [GROUP NAME]
$ alpacon group rm [GROUP NAME]
# Add a member to a group with a specific role
$ alpacon group member add
$ alpacon group member add --group=[GROUP NAME] --member=[MEMBER NAME] --role=[ROLE]
$ alpacon group member add --group [GROUP NAME] --member [MEMBER NAME] --role [ROLE]
# Remove a member from a group
$ alpacon group member delete --group=[GROUP NAME] --member=[MEMBER NAME]
$ alpacon group member delete --group [GROUP NAME] --member[MEMBER NAME]
$ alpacon group member rm --group [GROUP NAME] --member [MEMBER NAME]
```

#### API tokens
Expand All @@ -226,6 +242,7 @@ $ alpacon token ls
# Delete API token
$ alpacon token delete [TOKEN_ID_OR_NAME]
$ alpacon token rm [TOKEN_ID_OR_NAME]
# Log in via API token
$ alpacon login -s [SERVER URL] -t [TOKEN KEY]
Expand All @@ -243,6 +260,7 @@ $ alpacon token acl ls [TOKEN_ID_OR_NAME]
# Delete the specified command ACL from an API token.
$ alpacon token acl delete [COMMAND_ACL_ID]
$ alpacon token acl rm [COMMAND_ACL_ID]
$ alpacon token acl delete --token=[TOKEN_ID_OR_NAME] --command=[COMMAND]
```

Expand Down Expand Up @@ -271,7 +289,7 @@ $ alpacon package python upload alpamon-1.1.0-py3-none-any.whl
$ alpacon package python download alpamon-1.1.0-py3-none-any.whl .
# system
$ alpacon package system ls / list /all
$ alpacon package system ls / list / all
$ alpacon package system upload osquery-5.10.2-1.linux.x86_64.rpm
$ alpacon package system download osquery-5.10.2-1.linux.x86_64.rpm .
```
Expand Down Expand Up @@ -318,6 +336,7 @@ $ alpacon note create -s [SERVER NAME] -c [CONTENT] -p [PRIVATE(true or false)]
# Delete a specified note
$ alpacon note delete [NOTE ID]
$ alpacon note rm [NOTE ID]
```

#### Private CA, Certificate Commands
Expand All @@ -337,6 +356,7 @@ $ alpacon authority download-crt [AUTHOIRY ID] --out=/path/to/root.crt
# Delete a CA along with its certificate and CSR
$ alpacon authority delete [AUTHORITY ID]
$ alpacon authority rm [AUTHORITY ID]
# Generate a new Certificate Signing Request (CSR)
$ alpacon csr create
Expand All @@ -353,6 +373,7 @@ $ alpacon csr deny [CSR ID]
# Delete a Certificate Signing Request
$ alpacon csr delete [CSR ID]
$ alpacon csr rm [CSR ID]
# Get detailed information about a specific Signing Request.
$ alpacon csr describe [CSR ID]
Expand Down
6 changes: 4 additions & 2 deletions cmd/authority/authority_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import (
)

var authorityDeleteCmd = &cobra.Command{
Use: "delete [CSR ID]",
Short: "Delete a CA along with its certificate and CSR",
Use: "delete [CSR ID]",
Aliases: []string{"rm"},
Short: "Delete a CA along with its certificate and CSR",
Long: `
This command removes a Certificate Authority (CA) from the system, including its certificate and CSR.
Note that this action requires manual configuration adjustments to alpamon-cert-authority.
`,
Example: `
alpacon authority delete [AUTHORITY ID]
alpacon authority rm [AUTHORITY_ID]
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 4 additions & 2 deletions cmd/csr/csr_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import (
)

var csrDeleteCmd = &cobra.Command{
Use: "delete [CSR ID]",
Short: "Delete a CSR",
Use: "delete [CSR ID]",
Aliases: []string{"rm"},
Short: "Delete a CSR",
Long: `
Removes a Certificate Signing Request from the system,
effectively canceling the request and any associated processing.
`,
Example: `
alpacon csr delete [CSR ID]
alpacon csr rm [CSR ID]
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
8 changes: 5 additions & 3 deletions cmd/iam/group_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import (
)

var groupDeleteCmd = &cobra.Command{
Use: "delete [GROUP NAME]",
Short: "Delete a specified group",
Use: "delete [GROUP NAME]",
Aliases: []string{"rm"},
Short: "Delete a specified group",
Long: `
This command is used to permanently delete a specified group from the Alpacon.
The command requires the exact username as an argument.
NOTE : alpacon(Alpacon users) group cannot delete or update memberships
`,
Example: `
alpacon group delete [GROUP NAME]
alpacon group delete [GROUP NAME]
alpacon group rm [GROUP NAME]
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
5 changes: 3 additions & 2 deletions cmd/iam/member_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
var memberDeleteRequest iam.MemberDeleteRequest

var memberDeleteCmd = &cobra.Command{
Use: "delete",
Short: "Remove a member from a group",
Use: "delete",
Aliases: []string{"rm"},
Short: "Remove a member from a group",
Long: `
This command removes an existing member from the specified group.
It's useful for managing group membership and ensuring only current members have access.
Expand Down
6 changes: 4 additions & 2 deletions cmd/iam/user_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import (
)

var userDeleteCmd = &cobra.Command{
Use: "delete [USER NAME]",
Short: "Delete a specified user",
Use: "delete [USER NAME]",
Aliases: []string{"rm"},
Short: "Delete a specified user",
Long: `
This command is used to permanently delete a specified user account from the Alpacon.
The command requires the exact username as an argument.
`,
Example: `
alpacon user delete [USER NAME]
alpacon user rm [USER NAME]
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 4 additions & 2 deletions cmd/note/note_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import (
)

var noteDeleteCmd = &cobra.Command{
Use: "delete [NOTE ID]",
Short: "Delete a specified note",
Use: "delete [NOTE ID]",
Aliases: []string{"rm"},
Short: "Delete a specified note",
Long: `
This command permanently deletes a specified note from the Alpacon server.
It's important to verify that you have the necessary permissions to delete a note before using this command.
The command requires an exact note ID as its argument.
`,
Example: `
alpacon server delete [NOTE ID]
alpacon server rm [NOTE ID]
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 4 additions & 2 deletions cmd/server/server_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import (
)

var serverDeleteCmd = &cobra.Command{
Use: "delete [SERVER NAME]",
Short: "Delete a specified server",
Use: "delete [SERVER NAME]",
Aliases: []string{"rm"},
Short: "Delete a specified server",
Long: `
This command is used to permanently delete a specified server from the Alpacon.
It is crucial to ensure that you have the appropriate permissions to delete a server before attempting this operation.
The command requires the exact server name as an argument.
`,
Example: `
alpacon server delete [SERVER NAME]
alpacon server rm [SERVER NAME]
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
8 changes: 5 additions & 3 deletions cmd/token/acl_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import (
)

var aclDeleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete the specified command ACL from an API token.",
Use: "delete",
Aliases: []string{"rm"},
Short: "Delete the specified command ACL from an API token.",
Long: `
Removes an existing command acl from the API token
This command requires the command acl id to identify the command acl to be deleted.
`,
Example: `
alpacon token acl delete [COMMAND_ACL_ID]
alpacon token acl delete --token=[TOKEN_ID_OR_NAME] --command=[COMMAND]
alpacon token acl rm [COMMAND_ACL_ID]
alpacon token acl rm --token=[TOKEN_ID_OR_NAME] --command=[COMMAND]
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
8 changes: 5 additions & 3 deletions cmd/token/token_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import (
)

var tokenDeleteCmd = &cobra.Command{
Use: "delete [tok NAME]",
Short: "Delete a specified api token",
Use: "delete [TOKEN NAME]",
Aliases: []string{"rm"},
Short: "Delete a specified api token",
Long: `
Removes an existing API token from the system.
This command requires the token name to identify the token to be deleted.
`,
Example: `
alpacon token delete [TOKEN_ID_OR_NAME]
alpacon token delete [TOKEN_ID_OR_NAME]
alpacon token rm [TOKEN_ID_OR_NAME]
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ require (
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
golang.org/x/net v0.17.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -22,7 +21,6 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
Expand Down

0 comments on commit 686e207

Please sign in to comment.