Skip to content

Commit 4ae51b3

Browse files
committed
nil check
1 parent df77bf7 commit 4ae51b3

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

internal/pkg/agent/application/coordinator/coordinator.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,8 +1612,10 @@ func (c *Coordinator) processConfigAgent(ctx context.Context, cfg *config.Config
16121612

16131613
// override retrieved config from Fleet with persisted config from AgentConfig file
16141614

1615-
if err := applyPersistedConfig(cfg, paths.ConfigFile(), c.caps.AllowFleetOverride); err != nil {
1616-
return fmt.Errorf("could not apply persisted configuration: %w", err)
1615+
if c.caps != nil {
1616+
if err := applyPersistedConfig(cfg, paths.ConfigFile(), c.caps.AllowFleetOverride); err != nil {
1617+
return fmt.Errorf("could not apply persisted configuration: %w", err)
1618+
}
16171619
}
16181620

16191621
// perform and verify ast translation

internal/pkg/agent/application/coordinator/testdata/overrides.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ agent:
33
enabled: true
44
use_output: default
55
logs: false
6-
metrics: true
6+
metrics: true
7+
http:
8+
port: 6774

internal/pkg/capabilities/fleet_override.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ func allowFleetOverride(
2323
) bool {
2424
// first match wins
2525
for _, cap := range fleetOverrideCaps {
26+
if cap == nil {
27+
// being defensive here, should not happen
28+
continue
29+
}
30+
2631
switch cap.rule {
2732
case ruleTypeAllow:
2833
log.Debugf("Fleet override allowed by capability")

0 commit comments

Comments
 (0)