Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d947a4e

Browse files
committedSep 2, 2022
Take credentials as command argument (#102)
allow to specify credentials when using the 'command' package as a go dependency - remove the config retrieval from the command package - the retrieval of the config is now done in the cli package - each command will take credentials as argument
1 parent a634ea3 commit d947a4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+216
-142
lines changed
 

‎cli/dashboard/create.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/arduino/arduino-cli/cli/errorcodes"
2626
"github.com/arduino/arduino-cli/cli/feedback"
2727
"github.com/arduino/arduino-cloud-cli/command/dashboard"
28+
"github.com/arduino/arduino-cloud-cli/internal/config"
2829
"github.com/sirupsen/logrus"
2930
"github.com/spf13/cobra"
3031
)
@@ -56,6 +57,12 @@ func initCreateCommand() *cobra.Command {
5657
func runCreateCommand(cmd *cobra.Command, args []string) {
5758
logrus.Infof("Creating dashboard from template %s", createFlags.template)
5859

60+
cred, err := config.RetrieveCredentials()
61+
if err != nil {
62+
feedback.Errorf("Error during dashboard create: retrieving credentials: %v", err)
63+
os.Exit(errorcodes.ErrGeneric)
64+
}
65+
5966
params := &dashboard.CreateParams{
6067
Template: createFlags.template,
6168
Override: createFlags.override,
@@ -64,7 +71,7 @@ func runCreateCommand(cmd *cobra.Command, args []string) {
6471
params.Name = &createFlags.name
6572
}
6673

67-
dashboard, err := dashboard.Create(params)
74+
dashboard, err := dashboard.Create(params, cred)
6875
if err != nil {
6976
feedback.Errorf("Error during dashboard create: %v", err)
7077
os.Exit(errorcodes.ErrGeneric)

‎cli/dashboard/delete.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/arduino/arduino-cli/cli/errorcodes"
2424
"github.com/arduino/arduino-cli/cli/feedback"
2525
"github.com/arduino/arduino-cloud-cli/command/dashboard"
26+
"github.com/arduino/arduino-cloud-cli/internal/config"
2627
"github.com/sirupsen/logrus"
2728
"github.com/spf13/cobra"
2829
)
@@ -46,8 +47,14 @@ func initDeleteCommand() *cobra.Command {
4647
func runDeleteCommand(cmd *cobra.Command, args []string) {
4748
logrus.Infof("Deleting dashboard %s", deleteFlags.id)
4849

50+
cred, err := config.RetrieveCredentials()
51+
if err != nil {
52+
feedback.Errorf("Error during dashboard delete: retrieving credentials: %v", err)
53+
os.Exit(errorcodes.ErrGeneric)
54+
}
55+
4956
params := &dashboard.DeleteParams{ID: deleteFlags.id}
50-
err := dashboard.Delete(params)
57+
err = dashboard.Delete(params, cred)
5158
if err != nil {
5259
feedback.Errorf("Error during dashboard delete: %v", err)
5360
os.Exit(errorcodes.ErrGeneric)

0 commit comments

Comments
 (0)
Please sign in to comment.