feat: added cacerts and some tidying
This commit is contained in:
parent
2112e7eefd
commit
bdd85b01ff
8 changed files with 279 additions and 59 deletions
|
|
@ -24,17 +24,29 @@ var deleteCmd = &cobra.Command{
|
|||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
setenv(cmd, "host", "MAKESHIFT_HOST")
|
||||
setenv(cmd, "path", "MAKESHIFT_PATH")
|
||||
setenv(cmd, "cacert", "MAKESHIFT_CACERT")
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var (
|
||||
host, _ = cmd.Flags().GetString("host")
|
||||
paths, _ = cmd.Flags().GetStringSlice("path")
|
||||
host, _ = cmd.Flags().GetString("host")
|
||||
paths, _ = cmd.Flags().GetStringSlice("path")
|
||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
||||
|
||||
c = client.New(host)
|
||||
res *http.Response
|
||||
query string
|
||||
err error
|
||||
)
|
||||
|
||||
log.Debug().
|
||||
Str("host", host).
|
||||
Str("cacert", cacertPath).
|
||||
Send()
|
||||
|
||||
if cacertPath != "" {
|
||||
c.LoadCertificateFromPath(cacertPath)
|
||||
}
|
||||
|
||||
for _, path := range paths {
|
||||
if path == "" {
|
||||
log.Warn().Msg("skipping empty path")
|
||||
|
|
@ -61,7 +73,8 @@ var deleteProfilesCmd = &cobra.Command{
|
|||
Short: "Delete profile(s)",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var (
|
||||
host, _ = cmd.Flags().GetString("host")
|
||||
host, _ = cmd.Flags().GetString("host")
|
||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
||||
|
||||
c = client.New(host)
|
||||
res *http.Response
|
||||
|
|
@ -69,6 +82,14 @@ var deleteProfilesCmd = &cobra.Command{
|
|||
err error
|
||||
)
|
||||
|
||||
log.Debug().
|
||||
Str("host", host).
|
||||
Str("cacert", cacertPath).
|
||||
Send()
|
||||
|
||||
if cacertPath != "" {
|
||||
c.LoadCertificateFromPath(cacertPath)
|
||||
}
|
||||
for _, profileID := range args {
|
||||
if profileID == "default" {
|
||||
log.Warn().Msg("cannot delete the default profile")
|
||||
|
|
@ -95,7 +116,8 @@ var deletePluginsCmd = &cobra.Command{
|
|||
Short: "Delete plugin(s)",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var (
|
||||
host, _ = cmd.Flags().GetString("host")
|
||||
host, _ = cmd.Flags().GetString("host")
|
||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
||||
|
||||
c = client.New(host)
|
||||
res *http.Response
|
||||
|
|
@ -103,6 +125,15 @@ var deletePluginsCmd = &cobra.Command{
|
|||
err error
|
||||
)
|
||||
|
||||
log.Debug().
|
||||
Str("host", host).
|
||||
Str("cacert", cacertPath).
|
||||
Send()
|
||||
|
||||
if cacertPath != "" {
|
||||
c.LoadCertificateFromPath(cacertPath)
|
||||
}
|
||||
|
||||
for _, pluginName := range args {
|
||||
query = fmt.Sprintf("/plugins/%s", pluginName)
|
||||
res, _, err = c.MakeRequest(client.HTTPEnvelope{
|
||||
|
|
@ -116,6 +147,7 @@ var deletePluginsCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
deleteCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the makeshift server host (can be set with MAKESHIFT_HOST)")
|
||||
deleteCmd.PersistentFlags().String("cacert", "", "Set the CA certificate path to load")
|
||||
deleteCmd.Flags().StringSliceP("path", "p", []string{}, "Set the paths to delete files and directories")
|
||||
deleteCmd.AddCommand(deleteProfilesCmd, deletePluginsCmd)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue