Skip to content

Commit 49e3f9c

Browse files
committed
Merge remote-tracking branch 'origin/main' into transforms-system-tests
2 parents 559e15f + c9b1920 commit 49e3f9c

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ test-stack-command-86:
7373
./scripts/test-stack-command.sh 8.6.2
7474

7575
test-stack-command-8x:
76-
./scripts/test-stack-command.sh 8.17.0-af3fc043-SNAPSHOT
76+
./scripts/test-stack-command.sh 8.17.0-8ac6e7f5-SNAPSHOT
7777

7878
test-stack-command-9x:
79-
./scripts/test-stack-command.sh 9.0.0-54984c5a-SNAPSHOT
79+
./scripts/test-stack-command.sh 9.0.0-2a832de0-SNAPSHOT
8080

8181
test-stack-command-with-apm-server:
8282
APM_SERVER_ENABLED=true ./scripts/test-stack-command.sh

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.23.1
66

77
require (
88
github.com/AlecAivazis/survey/v2 v2.3.7
9-
github.com/Masterminds/semver/v3 v3.3.0
9+
github.com/Masterminds/semver/v3 v3.3.1
1010
github.com/ProtonMail/gopenpgp/v2 v2.8.0
1111
github.com/aymerick/raymond v2.0.2+incompatible
1212
github.com/boumenot/gocover-cobertura v1.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ
1212
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
1313
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
1414
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
15-
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
16-
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
15+
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
16+
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
1717
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
1818
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
1919
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=

internal/agentdeployer/kubernetes.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,12 @@ func readCACertBase64(profile *profile.Profile) (string, error) {
221221
return base64.StdEncoding.EncodeToString(d), nil
222222
}
223223

224-
// getTokenPolicyName function returns the policy name for the 8.x Elastic stack. The agent's policy
225-
// is predefined in the Kibana configuration file. The logic is not present in older stacks.
224+
// getTokenPolicyName function returns the policy name for the >= 8.x Elastic stacks. The agent's policy
225+
// is predefined in the Kibana configuration file. The logic is not present in older stacks and it uses
226+
// the default policy in Kibana (empty string).
226227
func getTokenPolicyName(stackVersion, policyName string) string {
227-
if strings.HasPrefix(stackVersion, "8.") {
228-
return policyName
228+
if strings.HasPrefix(stackVersion, "7.") {
229+
return ""
229230
}
230-
return ""
231+
return policyName
231232
}

internal/kibana/agents.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,36 @@ func (c *Client) ListAgents(ctx context.Context) ([]Agent, error) {
5959
}
6060

6161
var resp struct {
62-
List []Agent `json:"list"`
62+
List []Agent `json:"list"`
63+
Items []Agent `json:"items"`
6364
}
6465

6566
if err := json.Unmarshal(respBody, &resp); err != nil {
6667
return nil, fmt.Errorf("could not convert list agents (response) to JSON: %w", err)
6768
}
6869

69-
return resp.List, nil
70+
switch {
71+
case c.semver.Major() < 9:
72+
return resp.List, nil
73+
default:
74+
return resp.Items, nil
75+
}
7076
}
7177

7278
// AssignPolicyToAgent assigns the given Policy to the given Agent.
7379
func (c *Client) AssignPolicyToAgent(ctx context.Context, a Agent, p Policy) error {
7480
reqBody := `{ "policy_id": "` + p.ID + `" }`
75-
7681
path := fmt.Sprintf("%s/agents/%s/reassign", FleetAPI, a.ID)
77-
statusCode, respBody, err := c.put(ctx, path, []byte(reqBody))
82+
83+
var statusCode int
84+
var err error
85+
var respBody []byte
86+
switch {
87+
case c.semver.Major() < 9:
88+
statusCode, respBody, err = c.put(ctx, path, []byte(reqBody))
89+
default:
90+
statusCode, respBody, err = c.post(ctx, path, []byte(reqBody))
91+
}
7892
if err != nil {
7993
return fmt.Errorf("could not assign policy to agent: %w", err)
8094
}

0 commit comments

Comments
 (0)