Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 62bbbba

Browse filesBrowse files
committed
Avoid globals arguemnts in flash-certificate
1 parent a1b45b5 commit 62bbbba
Copy full SHA for 62bbbba

File tree

Expand file treeCollapse file tree

1 file changed

+10
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-7
lines changed

‎cli/certificates/flash.go

Copy file name to clipboardExpand all lines: cli/certificates/flash.go
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@ import (
3333
"github.com/arduino/arduino-fwuploader/flasher"
3434
"github.com/arduino/arduino-fwuploader/indexes/download"
3535
"github.com/arduino/arduino-fwuploader/indexes/firmwareindex"
36+
"github.com/arduino/arduino-fwuploader/plugin"
3637
"github.com/arduino/go-paths-helper"
3738
"github.com/sirupsen/logrus"
3839
"github.com/spf13/cobra"
3940
)
4041

4142
var (
42-
commonFlags arguments.Flags
43-
certificateURLs []string
44-
certificatePaths []string
43+
commonFlags arguments.Flags
4544
)
4645

4746
// NewFlashCommand creates a new `flash` command
4847
func NewFlashCommand() *cobra.Command {
48+
var certificateURLs []string
49+
var certificatePaths []string
4950
command := &cobra.Command{
5051
Use: "flash",
5152
Short: "Flashes certificates to board.",
@@ -55,15 +56,17 @@ func NewFlashCommand() *cobra.Command {
5556
" " + os.Args[0] + " certificates flash -b arduino:samd:mkr1000 -a COM10 -u arduino.cc:443 -u google.com:443\n" +
5657
" " + os.Args[0] + " certificates flash -b arduino:samd:mkr1000 -a COM10 -f /home/me/VeriSign.cer -f /home/me/Digicert.cer\n",
5758
Args: cobra.NoArgs,
58-
Run: runFlash,
59+
Run: func(cmd *cobra.Command, args []string) {
60+
runFlash(certificateURLs, certificatePaths)
61+
},
5962
}
6063
commonFlags.AddToCommand(command)
6164
command.Flags().StringSliceVarP(&certificateURLs, "url", "u", []string{}, "List of urls to download root certificates, e.g.: arduino.cc:443")
6265
command.Flags().StringSliceVarP(&certificatePaths, "file", "f", []string{}, "List of paths to certificate file, e.g.: /home/me/Digicert.cer")
6366
return command
6467
}
6568

66-
func runFlash(cmd *cobra.Command, args []string) {
69+
func runFlash(certificateURLs, certificatePaths []string) {
6770
// at the end cleanup the fwuploader temp dir
6871
defer globals.FwUploaderPath.RemoveAll()
6972

@@ -79,7 +82,7 @@ func runFlash(cmd *cobra.Command, args []string) {
7982
var res *flasher.FlashResult
8083
var err error
8184
if !board.IsPlugin() {
82-
res, err = flashCertificates(board, uploadToolDir)
85+
res, err = flashCertificates(board, uploadToolDir, certificateURLs, certificatePaths)
8386
} else {
8487
// TODO
8588
}
@@ -90,7 +93,7 @@ func runFlash(cmd *cobra.Command, args []string) {
9093
}
9194
}
9295

93-
func flashCertificates(board *firmwareindex.IndexBoard, uploadToolDir *paths.Path) (*flasher.FlashResult, error) {
96+
func flashCertificates(board *firmwareindex.IndexBoard, uploadToolDir *paths.Path, certificateURLs, certificatePaths []string) (*flasher.FlashResult, error) {
9497
loaderSketchPath, err := download.DownloadSketch(board.LoaderSketch)
9598
if err != nil {
9699
feedback.Fatal(fmt.Sprintf("Error downloading loader sketch from %s: %s", board.LoaderSketch.URL, err), feedback.ErrGeneric)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.