Skip to content

Commit d5e7ef9

Browse files
committed
Merge branch 'main' into proj/aclp-linode-alerts
2 parents 1325f81 + dc00ea0 commit d5e7ef9

71 files changed

Lines changed: 3705 additions & 1097 deletions

File tree

Some content is hidden

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

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@
77
**What are the steps to reproduce the issue or verify the changes?**
88

99
**How do I run the relevant unit/integration tests?**
10-
11-
## 📷 Preview
12-
13-
**If applicable, include a screenshot or code snippet of this change. Otherwise, please remove this section.**

.github/workflows/ci.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
name: Continuous Integration
22

33
on:
4-
workflow_dispatch: null
4+
workflow_dispatch:
5+
inputs:
6+
test_report_upload:
7+
description: 'Indicates whether to upload the test report to object storage. Defaults to "false"'
8+
type: choice
9+
required: false
10+
default: 'false'
11+
options:
12+
- 'true'
13+
- 'false'
514
push:
615
branches:
716
- main
@@ -10,7 +19,35 @@ on:
1019
jobs:
1120
lint-tidy:
1221
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
pull-requests: read
1325
steps:
26+
# Enforce TPT-1234: prefix on PR titles, with the following exemptions:
27+
# - PRs labeled 'dependencies' (e.g. Dependabot PRs)
28+
# - PRs labeled 'hotfix' (urgent fixes that may not have a ticket)
29+
# - PRs labeled 'community-contribution' (external contributors without TPT tickets)
30+
# - PRs labeled 'ignore-for-release' (release PRs that don't need a ticket prefix)
31+
- name: Validate PR Title
32+
if: github.event_name == 'pull_request'
33+
uses: amannn/action-semantic-pull-request@v6
34+
with:
35+
types: |
36+
TPT-\d+
37+
requireScope: false
38+
# Override the default header pattern to allow hyphens and digits in the type
39+
# (e.g. "TPT-4298: Description"). The default pattern only matches word
40+
# characters (\w) which excludes hyphens.
41+
headerPattern: '^([\w-]+):\s?(.*)$'
42+
headerPatternCorrespondence: type, subject
43+
ignoreLabels: |
44+
dependencies
45+
hotfix
46+
community-contribution
47+
ignore-for-release
48+
env:
49+
GITHUB_TOKEN: ${{ github.token }}
50+
1451
- uses: actions/checkout@v6
1552
- uses: actions/setup-go@v6
1653
with:
@@ -70,7 +107,7 @@ jobs:
70107
SKIP_LINT: 1
71108

72109
- name: Upload test results to bucket
73-
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && always()
110+
if: always() && github.repository == 'linode/linodego' && github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.test_report_upload == 'true'))
74111
run: |
75112
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \
76113
--branch_name "${GITHUB_REF#refs/*/}" \
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Clean Release Notes
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
clean-release-notes:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
13+
steps:
14+
- name: Remove ticket prefixes from release notes
15+
uses: actions/github-script@v7
16+
with:
17+
script: |
18+
const release = context.payload.release;
19+
20+
let body = release.body;
21+
22+
if (!body) {
23+
console.log("Release body empty, nothing to clean.");
24+
return;
25+
}
26+
27+
// Remove ticket prefixes like "TPT-1234: " or "TPT-1234:"
28+
body = body.replace(/TPT-\d+:\s*/g, '');
29+
30+
await github.rest.repos.updateRelease({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
release_id: release.id,
34+
body: body
35+
});
36+
37+
console.log("Release notes cleaned.");

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@v6
2222
-
2323
name: Run Labeler
24-
uses: crazy-max/ghaction-github-labeler@24d110aa46a59976b8a7f35518cb7f14f434c916
24+
uses: crazy-max/ghaction-github-labeler@548a7c3603594ec17c819e1239f281a3b801ab4d
2525
with:
2626
github-token: ${{ secrets.GITHUB_TOKEN }}
2727
yaml-file: .github/labels.yml

.github/workflows/security_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
with:
3030
# We need to temporarily exclude this as gosec doesn't
3131
# support using module files from subdirectories.
32-
args: -exclude-dir=k8s ./...
32+
args: -exclude-dir=k8s -exclude=G117 ./...

.golangci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ linters:
1818
- gochecknoglobals
1919
- gochecknoinits
2020
- godot
21+
- godox
2122
- inamedparam
2223
- lll
2324
- musttag
@@ -51,6 +52,12 @@ linters:
5152
disable-all: false
5253
exclusions:
5354
generated: lax
55+
rules:
56+
- linters:
57+
- gosec
58+
# "matches secret pattern" linodego necessarily serializes and
59+
# deserializes API structs that contain secrets
60+
text: G117
5461
presets:
5562
- comments
5663
- common-false-positives

account_events.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ type Event struct {
5454
Duration float64 `json:"duration"`
5555

5656
// The maintenance policy configured by the user for the event.
57-
// NOTE: MaintenancePolicySet can only be used with v4beta.
5857
MaintenancePolicySet string `json:"maintenance_policy_set"`
5958

6059
// Describes the nature of the event (e.g., whether it is scheduled or emergency).
@@ -258,6 +257,8 @@ const (
258257
EntityImage EntityType = "image"
259258
EntityIPAddress EntityType = "ipaddress"
260259
EntityLinode EntityType = "linode"
260+
EntityLKECluster EntityType = "lkecluster"
261+
EntityLKENodePool EntityType = "lkenodepool"
261262
EntityLongview EntityType = "longview"
262263
EntityManagedService EntityType = "managed_service"
263264
EntityNodebalancer EntityType = "nodebalancer"

account_maintenance.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type AccountMaintenance struct {
1515
Status string `json:"status"`
1616
Type string `json:"type"`
1717

18-
// NOTE: MaintenancePolicySet can only be used with v4beta.
1918
MaintenancePolicySet string `json:"maintenance_policy_set"`
2019

2120
Description string `json:"description"`

account_settings.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type AccountSettings struct {
3535
InterfacesForNewLinodes InterfacesForNewLinodes `json:"interfaces_for_new_linodes"`
3636

3737
// The slug of the maintenance policy associated with the account.
38-
// NOTE: MaintenancePolicy can only be used with v4beta.
3938
MaintenancePolicy string `json:"maintenance_policy"`
4039
}
4140

@@ -52,7 +51,6 @@ type AccountSettingsUpdateOptions struct {
5251
InterfacesForNewLinodes *InterfacesForNewLinodes `json:"interfaces_for_new_linodes"`
5352

5453
// The slug of the maintenance policy to set the account to.
55-
// NOTE: MaintenancePolicy can only be used with v4beta.
5654
MaintenancePolicy *string `json:"maintenance_policy,omitempty"`
5755
}
5856

client.go

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ Body: {{.Body}}`))
6666

6767
var envDebug = false
6868

69+
// redactHeadersMap is a map of headers that should be redacted in logs,
70+
// mapping the header name to its redacted value.
71+
var redactHeadersMap = map[string]string{
72+
"Authorization": "Bearer *******************************",
73+
}
74+
6975
// Client is a wrapper around the Resty client
7076
type Client struct {
7177
resty *resty.Client
@@ -394,6 +400,19 @@ func (c *httpClient) applyAfterResponse(resp *http.Response) error {
394400
return nil
395401
}
396402

403+
// nolint:unused
404+
func redactHeaders(headers http.Header) http.Header {
405+
redacted := headers.Clone()
406+
407+
for header, redactedValue := range redactHeadersMap {
408+
if headers.Get(header) != "" {
409+
redacted.Set(header, redactedValue)
410+
}
411+
}
412+
413+
return redacted
414+
}
415+
397416
// nolint:unused
398417
func (c *httpClient) logRequest(req *http.Request, method, url string, bodyBuffer *bytes.Buffer) {
399418
var reqBody string
@@ -408,7 +427,7 @@ func (c *httpClient) logRequest(req *http.Request, method, url string, bodyBuffe
408427
err := reqLogTemplate.Execute(&logBuf, map[string]any{
409428
"Method": method,
410429
"URL": url,
411-
"Headers": req.Header,
430+
"Headers": redactHeaders(req.Header),
412431
"Body": reqBody,
413432
})
414433
if err == nil {
@@ -418,6 +437,7 @@ func (c *httpClient) logRequest(req *http.Request, method, url string, bodyBuffe
418437

419438
// nolint:unused
420439
func (c *httpClient) sendRequest(req *http.Request) (*http.Response, error) {
440+
// #nosec G704
421441
resp, err := c.httpClient.Do(req)
422442
if err != nil {
423443
if c.debug && c.logger != nil {
@@ -455,7 +475,7 @@ func (c *httpClient) logResponse(resp *http.Response) (*http.Response, error) {
455475

456476
err := respLogTemplate.Execute(&logBuf, map[string]any{
457477
"Status": resp.Status,
458-
"Headers": resp.Header,
478+
"Headers": redactHeaders(resp.Header),
459479
"Body": respBody.String(),
460480
})
461481
if err == nil {
@@ -826,10 +846,22 @@ func (c *Client) updateHostURL() {
826846
)
827847
}
828848

849+
func redactLogHeaders(header http.Header) {
850+
for h, redactedValue := range redactHeadersMap {
851+
if header.Get(h) != "" {
852+
header.Set(h, redactedValue)
853+
}
854+
}
855+
}
856+
829857
func (c *Client) enableLogSanitization() *Client {
830858
c.resty.OnRequestLog(func(r *resty.RequestLog) error {
831-
// masking authorization header
832-
r.Header.Set("Authorization", "Bearer *******************************")
859+
redactLogHeaders(r.Header)
860+
return nil
861+
})
862+
863+
c.resty.OnResponseLog(func(r *resty.ResponseLog) error {
864+
redactLogHeaders(r.Header)
833865
return nil
834866
})
835867

0 commit comments

Comments
 (0)