Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
63da3d8b
Commit
63da3d8b
authored
Oct 07, 2019
by
Cristian Maglie
Committed by
Roberto Sora
Oct 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed globals.HTTPClientHeader global (#438)
To increase thread-safery and allow adding extra headers if needed.
parent
39530c00
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
12 additions
and
14 deletions
+12
-14
cli/core/download.go
cli/core/download.go
+1
-1
cli/core/install.go
cli/core/install.go
+1
-1
cli/core/upgrade.go
cli/core/upgrade.go
+1
-1
cli/globals/globals.go
cli/globals/globals.go
+3
-5
cli/instance/instance.go
cli/instance/instance.go
+1
-1
cli/lib/download.go
cli/lib/download.go
+1
-1
cli/lib/install.go
cli/lib/install.go
+1
-1
cli/lib/upgrade.go
cli/lib/upgrade.go
+2
-2
commands/board/list.go
commands/board/list.go
+1
-1
No files found.
cli/core/download.go
View file @
63da3d8b
...
...
@@ -64,7 +64,7 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
Version
:
platformRef
.
Version
,
}
_
,
err
:=
core
.
PlatformDownload
(
context
.
Background
(),
platformDownloadreq
,
output
.
ProgressBar
(),
globals
.
HTTPClientHeader
)
globals
.
NewHTTPClientHeader
()
)
if
err
!=
nil
{
feedback
.
Errorf
(
"Error downloading %s: %v"
,
args
[
i
],
err
)
os
.
Exit
(
errorcodes
.
ErrNetwork
)
...
...
cli/core/install.go
View file @
63da3d8b
...
...
@@ -65,7 +65,7 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
Version
:
platformRef
.
Version
,
}
_
,
err
:=
core
.
PlatformInstall
(
context
.
Background
(),
plattformInstallReq
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
HTTPClientHeader
)
output
.
TaskProgress
(),
globals
.
NewHTTPClientHeader
()
)
if
err
!=
nil
{
feedback
.
Errorf
(
"Error during install: %v"
,
err
)
os
.
Exit
(
errorcodes
.
ErrGeneric
)
...
...
cli/core/upgrade.go
View file @
63da3d8b
...
...
@@ -90,7 +90,7 @@ func runUpgradeCommand(cmd *cobra.Command, args []string) {
Architecture
:
platformRef
.
Architecture
,
}
_
,
err
:=
core
.
PlatformUpgrade
(
context
.
Background
(),
r
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
HTTPClientHeader
)
_
,
err
:=
core
.
PlatformUpgrade
(
context
.
Background
(),
r
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
NewHTTPClientHeader
()
)
if
err
==
core
.
ErrAlreadyLatest
{
feedback
.
Printf
(
"Platform %s is already at the latest version"
,
platformRef
)
}
else
if
err
!=
nil
{
...
...
cli/globals/globals.go
View file @
63da3d8b
...
...
@@ -31,8 +31,6 @@ var (
Debug
bool
// OutputFormat can be "text" or "json"
OutputFormat
string
// HTTPClientHeader is the object that will be propagated to configure the clients inside the downloaders
HTTPClientHeader
=
getHTTPClientHeader
()
// VersionInfo contains all info injected during build
VersionInfo
=
version
.
NewInfo
(
filepath
.
Base
(
os
.
Args
[
0
]))
// Config FIXMEDOC
...
...
@@ -46,9 +44,9 @@ var (
LogLevel
string
)
func
getHTTPClientHeader
()
http
.
Header
{
// NewHTTPClientHeader returns the http.Header object that must be used by the clients inside the downloaders
func
NewHTTPClientHeader
()
http
.
Header
{
userAgentValue
:=
fmt
.
Sprintf
(
"%s/%s (%s; %s; %s) Commit:%s"
,
VersionInfo
.
Application
,
VersionInfo
.
VersionString
,
runtime
.
GOARCH
,
runtime
.
GOOS
,
runtime
.
Version
(),
VersionInfo
.
Commit
)
downloaderHeaders
:=
http
.
Header
{
"User-Agent"
:
[]
string
{
userAgentValue
}}
return
downloaderHeaders
return
http
.
Header
{
"User-Agent"
:
[]
string
{
userAgentValue
}}
}
cli/instance/instance.go
View file @
63da3d8b
...
...
@@ -36,7 +36,7 @@ func initInstance() *rpc.InitResp {
logrus
.
Info
(
"Initializing package manager"
)
req
:=
packageManagerInitReq
()
resp
,
err
:=
commands
.
Init
(
context
.
Background
(),
req
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
HTTPClientHeader
)
resp
,
err
:=
commands
.
Init
(
context
.
Background
(),
req
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
NewHTTPClientHeader
()
)
if
err
!=
nil
{
feedback
.
Errorf
(
"Error initializing package manager: %v"
,
err
)
os
.
Exit
(
errorcodes
.
ErrGeneric
)
...
...
cli/lib/download.go
View file @
63da3d8b
...
...
@@ -60,7 +60,7 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
Version
:
library
.
Version
,
}
_
,
err
:=
lib
.
LibraryDownload
(
context
.
Background
(),
libraryDownloadReq
,
output
.
ProgressBar
(),
globals
.
HTTPClientHeader
)
globals
.
NewHTTPClientHeader
()
)
if
err
!=
nil
{
feedback
.
Errorf
(
"Error downloading %s: %v"
,
library
,
err
)
os
.
Exit
(
errorcodes
.
ErrNetwork
)
...
...
cli/lib/install.go
View file @
63da3d8b
...
...
@@ -60,7 +60,7 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
Version
:
library
.
Version
,
}
err
:=
lib
.
LibraryInstall
(
context
.
Background
(),
libraryInstallReq
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
HTTPClientHeader
)
output
.
TaskProgress
(),
globals
.
NewHTTPClientHeader
()
)
if
err
!=
nil
{
feedback
.
Errorf
(
"Error installing %s: %v"
,
library
,
err
)
os
.
Exit
(
errorcodes
.
ErrGeneric
)
...
...
cli/lib/upgrade.go
View file @
63da3d8b
...
...
@@ -50,13 +50,13 @@ func runUpgradeCommand(cmd *cobra.Command, args []string) {
instance
:=
instance
.
CreateInstaceIgnorePlatformIndexErrors
()
if
len
(
args
)
==
0
{
err
:=
lib
.
LibraryUpgradeAll
(
instance
.
Id
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
HTTPClientHeader
)
err
:=
lib
.
LibraryUpgradeAll
(
instance
.
Id
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
NewHTTPClientHeader
()
)
if
err
!=
nil
{
feedback
.
Errorf
(
"Error upgrading libraries: %v"
,
err
)
os
.
Exit
(
errorcodes
.
ErrGeneric
)
}
}
else
{
err
:=
lib
.
LibraryUpgrade
(
instance
.
Id
,
args
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
HTTPClientHeader
)
err
:=
lib
.
LibraryUpgrade
(
instance
.
Id
,
args
,
output
.
ProgressBar
(),
output
.
TaskProgress
(),
globals
.
NewHTTPClientHeader
()
)
if
err
!=
nil
{
feedback
.
Errorf
(
"Error upgrading libraries: %v"
,
err
)
os
.
Exit
(
errorcodes
.
ErrGeneric
)
...
...
commands/board/list.go
View file @
63da3d8b
...
...
@@ -40,7 +40,7 @@ var (
func
apiByVidPid
(
url
string
)
([]
*
rpc
.
BoardListItem
,
error
)
{
retVal
:=
[]
*
rpc
.
BoardListItem
{}
req
,
_
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
req
.
Header
=
globals
.
HTTPClientHeader
req
.
Header
=
globals
.
NewHTTPClientHeader
()
req
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
if
res
,
err
:=
http
.
DefaultClient
.
Do
(
req
);
err
==
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment