Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# REQUIRED
# Kind can be one of:
# - breaking-change: a change to previously-documented behavior
# - deprecation: functionality that is being removed in a later release
# - bug-fix: fixes a problem in a previous version
# - enhancement: extends functionality but does not break or fix existing behavior
# - feature: new functionality
# - known-issue: problems that we are aware of in a given version
# - security: impacts on the security of a product or a user’s deployment.
# - upgrade: important information for someone upgrading from a prior version
# - other: does not fit into any of the other categories
kind: feature

# REQUIRED for all kinds
# Change summary; a 80ish characters long description of the change.
summary: Add support for multiple upgrade artifact source URIs.

# REQUIRED for breaking-change, deprecation, known-issue
# Long description; in case the summary is not enough to describe the change
# this field accommodate a description without length limits.
description: Adds an ordered sources field to upgrade actions for multiple upgrade artifact source URIs. The existing source_uri setting is deprecated but remains supported for backward compatibility.

# REQUIRED for breaking-change, deprecation, known-issue
# impact:

# REQUIRED for breaking-change, deprecation, known-issue
# action:

# REQUIRED for all kinds
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
component: fleet-server

# AUTOMATED
# OPTIONAL to manually add other PR URLs
# PR URL: A link the PR that added the changeset.
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
# Please provide it if you are adding a fragment for a different PR.
# pr: https://github.com/owner/repo/1234

# AUTOMATED
# OPTIONAL to manually add other issue URLs
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# If not present is automatically filled by the tooling with the issue linked to the PR number.
# issue: https://github.com/owner/repo/1234
14 changes: 14 additions & 0 deletions internal/pkg/api/handleCheckin.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,20 @@ func convertActionData(aType ActionType, raw json.RawMessage) (ad Action_Data, e
if err != nil {
return
}
if d.Sources != nil {
if len(*d.Sources) > 0 {
sourceURI := (*d.Sources)[0]
d.SourceUri = &sourceURI
} else {
d.SourceUri = nil
}
} else if d.SourceUri != nil {
sources := []string{}
if *d.SourceUri != "" {
sources = append(sources, *d.SourceUri)
}
d.Sources = &sources
Comment thread
lorienhu marked this conversation as resolved.
}
err = ad.FromActionUpgrade(d)
return
case REQUESTDIAGNOSTICS:
Expand Down
44 changes: 42 additions & 2 deletions internal/pkg/api/handleCheckin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,38 @@ func TestConvertActionData(t *testing.T) {
}, {
name: "upgrade action",
aType: UPGRADE,
raw: json.RawMessage(`{"source_uri":"https://localhost:8080","version":"1.2.3"}`),
expect: Action_Data{json.RawMessage(`{"source_uri":"https://localhost:8080","version":"1.2.3"}`)},
raw: json.RawMessage(`{"sources":["https://localhost:8080"],"version":"1.2.3"}`),
expect: Action_Data{json.RawMessage(`{"source_uri":"https://localhost:8080","sources":["https://localhost:8080"],"version":"1.2.3"}`)},
hasErr: false,
}, {
name: "upgrade action populates source uri from sources",
aType: UPGRADE,
raw: json.RawMessage(`{"sources":["https://first.example.com","https://second.example.com"],"version":"1.2.3"}`),
expect: Action_Data{json.RawMessage(`{"source_uri":"https://first.example.com","sources":["https://first.example.com","https://second.example.com"],"version":"1.2.3"}`)},
hasErr: false,
}, {
name: "upgrade action populates sources from source uri",
aType: UPGRADE,
raw: json.RawMessage(`{"source_uri":"https://legacy.example.com","version":"1.2.3"}`),
expect: Action_Data{json.RawMessage(`{"source_uri":"https://legacy.example.com","sources":["https://legacy.example.com"],"version":"1.2.3"}`)},
hasErr: false,
}, {
Comment thread
lorienhu marked this conversation as resolved.
name: "upgrade action uses sources over source uri",
aType: UPGRADE,
raw: json.RawMessage(`{"source_uri":"https://legacy.example.com","sources":["https://new.example.com"],"version":"1.2.3"}`),
expect: Action_Data{json.RawMessage(`{"source_uri":"https://new.example.com","sources":["https://new.example.com"],"version":"1.2.3"}`)},
hasErr: false,
}, {
name: "upgrade action uses empty sources over source uri",
aType: UPGRADE,
raw: json.RawMessage(`{"source_uri":"https://legacy.example.com","sources":[],"version":"1.2.3"}`),
expect: Action_Data{json.RawMessage(`{"sources":[],"version":"1.2.3"}`)},
hasErr: false,
}, {
name: "upgrade action does not populate sources from empty source uri",
aType: UPGRADE,
raw: json.RawMessage(`{"source_uri":"","version":"1.2.3"}`),
expect: Action_Data{json.RawMessage(`{"source_uri":"","sources":[],"version":"1.2.3"}`)},
hasErr: false,
}, {
name: "request diagnostics action",
Expand Down Expand Up @@ -231,6 +261,16 @@ func TestConvertActions(t *testing.T) {
Data: Action_Data{json.RawMessage(`{}`)},
}},
token: "",
}, {
name: "upgrade action",
actions: []model.Action{{ActionID: "1234", Type: "UPGRADE", Data: json.RawMessage(`{"sources":["https://first.example.com","https://second.example.com"],"version":"9.6.0"}`)}},
resp: []Action{{
AgentId: "agent-id",
Id: "1234",
Type: UPGRADE,
Data: Action_Data{json.RawMessage(`{"source_uri":"https://first.example.com","sources":["https://first.example.com","https://second.example.com"],"version":"9.6.0"}`)},
}},
token: "",
}, {name: "multiple actions",
actions: []model.Action{
{
Expand Down
4 changes: 4 additions & 0 deletions internal/pkg/api/openapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions model/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,13 @@ components:
source_uri:
description: The source of the upgrade artifact.
type: string
deprecated: true
x-deprecated-reason: Replaced by sources.
sources:
description: An ordered list of sources for the upgrade artifact.
type: array
items:
type: string
rollback:
description: Indicates if this version change should be performed as a rollback to a previous version.
type: boolean
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading