-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from Tinyblargon/CLI-Overhaul
Cli overhaul: storage
- Loading branch information
Showing
55 changed files
with
2,448 additions
and
279 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,33 @@ | ||
package create | ||
|
||
import ( | ||
"github.com/Telmate/proxmox-api-go/cli" | ||
"github.com/Telmate/proxmox-api-go/proxmox" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var create_storageCmd = &cobra.Command{ | ||
Use: "storage STORAGEID", | ||
Short: "Creates a new Storage Backend", | ||
Long: `Creates a new Storage Backend. | ||
The config can be set with the --file flag or piped from stdin. | ||
For config examples see "example storage"`, | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
id := cli.ValidateIDset(args, 0, "StorageID") | ||
config, err := proxmox.NewConfigStorageFromJson(cli.NewConfig()) | ||
if err != nil { | ||
return | ||
} | ||
c := cli.NewClient() | ||
err = config.CreateWithValidate(id, c) | ||
if err != nil { | ||
return | ||
} | ||
cli.PrintItemCreated(createCmd.OutOrStdout(), id, "Storage") | ||
return | ||
}, | ||
} | ||
|
||
func init() { | ||
createCmd.AddCommand(create_storageCmd) | ||
} |
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,17 @@ | ||
package delete | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var delete_storageCmd = &cobra.Command{ | ||
Use: "storage STORAGEID", | ||
Short: "Deletes the speciefied Storage", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return DeleteID(args, "Storage") | ||
}, | ||
} | ||
|
||
func init() { | ||
deleteCmd.AddCommand(delete_storageCmd) | ||
} |
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,17 @@ | ||
package get | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var get_storageCmd = &cobra.Command{ | ||
Use: "storage", | ||
Short: "Gets the configuration of the specified Storage backend", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return GetConfig(args, "Storage") | ||
}, | ||
} | ||
|
||
func init() { | ||
getCmd.AddCommand(get_storageCmd) | ||
} |
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,33 @@ | ||
package update | ||
|
||
import ( | ||
"github.com/Telmate/proxmox-api-go/cli" | ||
"github.com/Telmate/proxmox-api-go/proxmox" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var update_storageCmd = &cobra.Command{ | ||
Use: "storage STORAGEID", | ||
Short: "Updates the configuration of the speciefied Storage Backend.", | ||
Long: `Updates the configuration of the speciefied Storage Backend. | ||
The config can be set with the --file flag or piped from stdin. | ||
For config examples see "example storage"`, | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
id := cli.ValidateIDset(args, 0, "StorageID") | ||
config, err := proxmox.NewConfigStorageFromJson(cli.NewConfig()) | ||
if err != nil { | ||
return | ||
} | ||
c := cli.NewClient() | ||
err = config.UpdateWithValidate(id, c) | ||
if err != nil { | ||
return | ||
} | ||
cli.PrintItemUpdated(updateCmd.OutOrStdout(), id, "Storage") | ||
return | ||
}, | ||
} | ||
|
||
func init() { | ||
updateCmd.AddCommand(update_storageCmd) | ||
} |
Oops, something went wrong.