Skip to content

Commit 59ba859

Browse files
committed
Merge branch 'main' into r4-provisioning-scripts
2 parents 0dd62f4 + 0229c3f commit 59ba859

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

.github/workflows/check-dependencies-task.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ jobs:
6969
# Some might find it convenient to have CI generate the cache rather than setting up for it locally
7070
- name: Upload cache to workflow artifact
7171
if: failure() && steps.diff.outcome == 'failure'
72-
uses: actions/upload-artifact@v2
72+
uses: actions/upload-artifact@v4
7373
with:
7474
if-no-files-found: error
75+
include-hidden-files: true
7576
name: dep-licenses-cache
7677
path: .licenses/
7778

.github/workflows/release-go-task.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: task dist:all
4444

4545
- name: Upload artifacts
46-
uses: actions/upload-artifact@v2
46+
uses: actions/upload-artifact@v4
4747
with:
4848
if-no-files-found: error
4949
name: ${{ env.ARTIFACT_NAME }}
@@ -58,7 +58,7 @@ jobs:
5858
uses: actions/checkout@v3
5959

6060
- name: Download artifacts
61-
uses: actions/download-artifact@v2
61+
uses: actions/download-artifact@v4
6262
with:
6363
name: ${{ env.ARTIFACT_NAME }}
6464
path: ${{ env.DIST_DIR }}
@@ -104,7 +104,7 @@ jobs:
104104
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
105105
# 2. Recalculate package checksum and replace it in the nnnnnn-checksums.txt file
106106
run: |
107-
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
107+
# GitHub's upload/download-artifact@v4 actions don't preserve file permissions,
108108
# so we need to add execution permission back until the action is made to do this.
109109
chmod +x ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_darwin_amd64/${{ env.PROJECT_NAME }}
110110
TAG="${GITHUB_REF/refs\/tags\//}"
@@ -119,9 +119,10 @@ jobs:
119119
${{ env.DIST_DIR }}/*-checksums.txt
120120
121121
- name: Upload artifacts
122-
uses: actions/upload-artifact@v2
122+
uses: actions/upload-artifact@v4
123123
with:
124124
if-no-files-found: error
125+
overwrite: true
125126
name: ${{ env.ARTIFACT_NAME }}
126127
path: ${{ env.DIST_DIR }}
127128

@@ -131,7 +132,7 @@ jobs:
131132

132133
steps:
133134
- name: Download artifact
134-
uses: actions/download-artifact@v2
135+
uses: actions/download-artifact@v4
135136
with:
136137
name: ${{ env.ARTIFACT_NAME }}
137138
path: ${{ env.DIST_DIR }}

cli/device/list.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func (r listResult) Data() interface{} {
9292
return r.devices
9393
}
9494

95+
func cleanStrings(serial string) string {
96+
serial = strings.Trim(serial, "\n")
97+
return strings.Trim(serial, " ")
98+
}
99+
95100
func (r listResult) String() string {
96101
if len(r.devices) == 0 {
97102
return "No devices found."
@@ -100,11 +105,11 @@ func (r listResult) String() string {
100105
t.SetHeader("Name", "ID", "Board", "FQBN", "SerialNumber", "Status", "Tags")
101106
for _, device := range r.devices {
102107
t.AddRow(
103-
device.Name,
108+
cleanStrings(device.Name),
104109
device.ID,
105110
device.Board,
106111
device.FQBN,
107-
device.Serial,
112+
cleanStrings(device.Serial),
108113
dereferenceString(device.Status),
109114
strings.Join(device.Tags, ","),
110115
)

internal/iot/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,15 @@ func (cl *Client) TemplateApply(ctx context.Context, id, thingId, prefix, device
560560
return dev, nil
561561
}
562562

563-
func (cl *Client) setup(client, secret, organization string) error {
563+
func (cl *Client) setup(client, secret, organizationId string) error {
564564
baseURL := GetArduinoAPIBaseURL()
565565

566566
// Configure a token source given the user's credentials.
567-
cl.token = NewUserTokenSource(client, secret, baseURL)
567+
cl.token = NewUserTokenSource(client, secret, baseURL, organizationId)
568568

569569
config := iotclient.NewConfiguration()
570-
if organization != "" {
571-
config.AddDefaultHeader("X-Organization", organization)
570+
if organizationId != "" {
571+
config.AddDefaultHeader("X-Organization", organizationId)
572572
}
573573
config.Servers = iotclient.ServerConfigurations{
574574
{

internal/iot/token.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ func GetArduinoAPIBaseURL() string {
3939
}
4040

4141
// Build a new token source to forge api JWT tokens based on provided credentials
42-
func NewUserTokenSource(client, secret, baseURL string) oauth2.TokenSource {
42+
func NewUserTokenSource(client, secret, baseURL, organizationId string) oauth2.TokenSource {
4343
// We need to pass the additional "audience" var to request an access token.
4444
additionalValues := url.Values{}
4545
additionalValues.Add("audience", "https://api2.arduino.cc/iot")
46+
if organizationId != "" {
47+
additionalValues.Add("organization_id", organizationId)
48+
}
4649
// Set up OAuth2 configuration.
4750
config := cc.Config{
4851
ClientID: client,

internal/ota-api/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type OtaApiClient struct {
4949

5050
func NewClient(credentials *config.Credentials) *OtaApiClient {
5151
host := iot.GetArduinoAPIBaseURL()
52-
tokenSource := iot.NewUserTokenSource(credentials.Client, credentials.Secret, host)
52+
tokenSource := iot.NewUserTokenSource(credentials.Client, credentials.Secret, host, credentials.Organization)
5353
return &OtaApiClient{
5454
client: &http.Client{},
5555
src: tokenSource,

internal/storage-api/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func getArduinoAPIBaseURL() string {
5757
func NewClient(credentials *config.Credentials) *StorageApiClient {
5858
host := getArduinoAPIBaseURL()
5959
iothost := iot.GetArduinoAPIBaseURL()
60-
tokenSource := iot.NewUserTokenSource(credentials.Client, credentials.Secret, iothost)
60+
tokenSource := iot.NewUserTokenSource(credentials.Client, credentials.Secret, iothost, credentials.Organization)
6161
return &StorageApiClient{
6262
client: &http.Client{},
6363
src: tokenSource,

0 commit comments

Comments
 (0)