Skip to content

Commit a5ad6f8

Browse files
committed
init with empty available components if host components is nil and ReportsAvailableComponents is set to true
Signed-off-by: Florian Bacher <[email protected]>
1 parent b75f66f commit a5ad6f8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

extension/opampextension/config_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ func TestUnmarshalConfig(t *testing.T) {
4040
},
4141
InstanceUID: "01BX5ZZKBKACTAV9WEVGEMMVRZ",
4242
Capabilities: Capabilities{
43-
ReportsEffectiveConfig: true,
44-
ReportsHealth: true,
43+
ReportsEffectiveConfig: true,
44+
ReportsHealth: true,
45+
ReportsAvailableComponents: true,
4546
},
4647
PPIDPollInterval: 5 * time.Second,
4748
}, cfg)
@@ -65,8 +66,9 @@ func TestUnmarshalHttpConfig(t *testing.T) {
6566
},
6667
InstanceUID: "01BX5ZZKBKACTAV9WEVGEMMVRZ",
6768
Capabilities: Capabilities{
68-
ReportsEffectiveConfig: true,
69-
ReportsHealth: true,
69+
ReportsEffectiveConfig: true,
70+
ReportsHealth: true,
71+
ReportsAvailableComponents: true,
7072
},
7173
PPIDPollInterval: 5 * time.Second,
7274
}, cfg)

extension/opampextension/opamp_agent.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ func (o *opampAgent) Start(ctx context.Context, host component.Host) error {
168168

169169
if mi, ok := host.(moduleInfo); ok {
170170
o.initAvailableComponents(mi.GetModuleInfos())
171+
} else if o.capabilities.ReportsAvailableComponents {
172+
// init empty availableComponents to not get an error when starting the opampClient
173+
o.initAvailableComponents(service.ModuleInfos{})
171174
}
172175

173176
if o.availableComponents != nil {

0 commit comments

Comments
 (0)