-
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 #188 from Tinyblargon/CLI-Overhaul
Cli overhaul: acmeaccount
- Loading branch information
Showing
8 changed files
with
216 additions
and
15 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_acmeaccountCmd = &cobra.Command{ | ||
Use: "acmeaccount ACMEACCOUNTID", | ||
Short: "Creates a new AcmeAccount", | ||
Long: `Creates a new AcmeAccount. | ||
The config can be set with the --file flag or piped from stdin. | ||
For config examples see "example acmeaccount"`, | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
id := cli.ValidateIDset(args, 0, "AcmeAccountID") | ||
config, err := proxmox.NewConfigAcmeAccountFromJson(cli.NewConfig()) | ||
if err != nil { | ||
return | ||
} | ||
c := cli.NewClient() | ||
err = config.CreateAcmeAccount(id, c) | ||
if err != nil { | ||
return | ||
} | ||
cli.PrintItemCreated(createCmd.OutOrStdout(), id, "AcmeAccount") | ||
return | ||
}, | ||
} | ||
|
||
func init() { | ||
createCmd.AddCommand(create_acmeaccountCmd) | ||
} |
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_acmeaccountCmd = &cobra.Command{ | ||
Use: "acmeaccount ACMEACCOUNTID", | ||
Short: "Deletes the Speciefied AcmeAccount", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return DeleteID(args, "AcmeAccount") | ||
}, | ||
} | ||
|
||
func init() { | ||
deleteCmd.AddCommand(delete_acmeaccountCmd) | ||
} |
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_acmeaccountCmd = &cobra.Command{ | ||
Use: "acmeaccount ACMEACCOUNTID", | ||
Short: "Gets the configuration of the specified AcmeAccount", | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
return GetConfig(args, "AcmeAccount") | ||
}, | ||
} | ||
|
||
func init() { | ||
getCmd.AddCommand(get_acmeaccountCmd) | ||
} |
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
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,65 @@ | ||
package cli_acmeaccount_test | ||
|
||
import ( | ||
"testing" | ||
|
||
_ "github.com/Telmate/proxmox-api-go/cli/command/commands" | ||
cliTest "github.com/Telmate/proxmox-api-go/test/cli" | ||
) | ||
|
||
func Test_AcmeAccount_0_Cleanup(t *testing.T) { | ||
Test := cliTest.Test{ | ||
ReqErr: true, | ||
ErrContains: "test-0", | ||
Args: []string{"-i", "delete", "acmeaccount", "test-0"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_AcmeAccount_0_Set(t *testing.T) { | ||
Test := cliTest.Test{ | ||
InputJson: ` | ||
{ | ||
"contact": [ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]" | ||
], | ||
"directory": "https://acme-staging-v02.api.letsencrypt.org/directory", | ||
"tos": true | ||
}`, | ||
Expected: "(test-0)", | ||
Contains: true, | ||
Args: []string{"-i", "create", "acmeaccount", "test-0"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_AcmeAccount_0_Get(t *testing.T) { | ||
Test := cliTest.Test{ | ||
OutputJson: ` | ||
{ | ||
"name": "test-0", | ||
"contact": [ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]" | ||
], | ||
"directory": "https://acme-staging-v02.api.letsencrypt.org/directory", | ||
"tos": true | ||
}`, | ||
Args: []string{"-i", "get", "acmeaccount", "test-0"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_AcmeAccount_0_Delete(t *testing.T) { | ||
Test := cliTest.Test{ | ||
Expected: "", | ||
ReqErr: false, | ||
Args: []string{"-i", "delete", "acmeaccount", "test-0"}, | ||
} | ||
Test.StandardTest(t) | ||
} |
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,59 @@ | ||
package cli_acmeaccount_test | ||
|
||
import ( | ||
"testing" | ||
|
||
_ "github.com/Telmate/proxmox-api-go/cli/command/commands" | ||
cliTest "github.com/Telmate/proxmox-api-go/test/cli" | ||
) | ||
|
||
func Test_AcmeAccount_1_Cleanup(t *testing.T) { | ||
Test := cliTest.Test{ | ||
ReqErr: true, | ||
ErrContains: "test-1", | ||
Args: []string{"-i", "delete", "acmeaccount", "test-1"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_AcmeAccount_1_Set(t *testing.T) { | ||
Test := cliTest.Test{ | ||
InputJson: ` | ||
{ | ||
"contact": [ | ||
"[email protected]" | ||
], | ||
"directory": "https://acme-staging-v02.api.letsencrypt.org/directory", | ||
"tos": true | ||
}`, | ||
Expected: "(test-1)", | ||
Contains: true, | ||
Args: []string{"-i", "create", "acmeaccount", "test-1"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_AcmeAccount_1_Get(t *testing.T) { | ||
Test := cliTest.Test{ | ||
OutputJson: ` | ||
{ | ||
"name": "test-1", | ||
"contact": [ | ||
"[email protected]" | ||
], | ||
"directory": "https://acme-staging-v02.api.letsencrypt.org/directory", | ||
"tos": true | ||
}`, | ||
Args: []string{"-i", "get", "acmeaccount", "test-1"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_AcmeAccount_1_Delete(t *testing.T) { | ||
Test := cliTest.Test{ | ||
Expected: "", | ||
ReqErr: false, | ||
Args: []string{"-i", "delete", "acmeaccount", "test-1"}, | ||
} | ||
Test.StandardTest(t) | ||
} |