Skip to content

Commit cb35876

Browse files
Flasher: download images from production
1 parent eb99828 commit cb35876

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

updater/flasher.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"log/slog"
77
"net/url"
8-
"os"
98
"runtime"
109
"strings"
1110

@@ -20,31 +19,14 @@ var assets embed.FS
2019

2120
func Flash(ctx context.Context, imagePath *paths.Path, version string, forceYes bool) error {
2221
if !imagePath.Exist() {
23-
updateURL := os.Getenv("UPDATE_URL")
24-
if updateURL == "" {
25-
// TODO: change to prod
26-
updateURL = "https://downloads.arduino.cc"
27-
}
22+
updateURL := "https://downloads.arduino.cc"
2823

2924
parsedURL, err := url.Parse(updateURL)
3025
if err != nil {
3126
return fmt.Errorf("invalid UPDATE_URL: %v", err)
3227
}
3328

34-
headers := map[string]string{}
35-
clientID := os.Getenv("CF_ACCESS_CLIENT_ID")
36-
clientSecret := os.Getenv("CF_ACCESS_CLIENT_SECRET")
37-
if clientID != "" && clientSecret != "" {
38-
headers["CF-Access-Client-Id"] = clientID
39-
headers["CF-Access-Client-Secret"] = clientSecret
40-
}
41-
42-
var client *Client
43-
if len(headers) == 2 {
44-
client = NewClient(parsedURL, "debian-im/Stable", WithHeaders(headers))
45-
} else {
46-
client = NewClient(parsedURL, "debian-im/Stable")
47-
}
29+
client := NewClient(parsedURL, "debian-im/Stable")
4830

4931
tempImagePath, err := DownloadAndExtract(client, version, func(target string) (bool, error) {
5032
feedback.Printf("Found Debian image version: %s", target)

updater/http_client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func (c *Client) GetInfoManifest() (Manifest, error) {
6969
return Manifest{}, fmt.Errorf("failed to create request: %w", err)
7070
}
7171
c.addHeaders(req)
72+
req.SetBasicAuth("arduino", "changeme")
7273
// #nosec G107 -- manifestURL is constructed from trusted config and parameters
7374
resp, err := c.HTTPClient.Do(req)
7475
if err != nil {
@@ -98,6 +99,7 @@ func (c *Client) FetchZip(zipURL string) (io.ReadCloser, int64, error) {
9899
return nil, 0, fmt.Errorf("failed to create request: %w", err)
99100
}
100101
c.addHeaders(req)
102+
req.SetBasicAuth("arduino", "changeme")
101103
// #nosec G107 -- zipURL is constructed from trusted config and parameters
102104
resp, err := c.HTTPClient.Do(req)
103105
if err != nil {

0 commit comments

Comments
 (0)