Skip to content

Commit a804485

Browse files
add a sidekick_address param to managed exporter templates
when we need a reference back to the exporter host address
1 parent adae770 commit a804485

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/exporter/template/exporter_instance.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type ExporterInstanceTemplater struct {
1717
exporterInstance *v1alpha1.ExporterInstance
1818
exporterConfigTemplate *v1alpha1.ExporterConfigTemplate
1919
serviceParameters ServiceParameters
20+
renderedExporterHost *v1alpha1.ExporterHost
2021
}
2122

2223
func NewExporterInstanceTemplater(cfg *config.Config, exporterInstance *v1alpha1.ExporterInstance) (*ExporterInstanceTemplater, error) {
@@ -35,6 +36,10 @@ func (e *ExporterInstanceTemplater) SetServiceParameters(serviceParameters Servi
3536
e.serviceParameters = serviceParameters
3637
}
3738

39+
func (e *ExporterInstanceTemplater) SetRenderedExporterHost(renderedExporterHost *v1alpha1.ExporterHost) {
40+
e.renderedExporterHost = renderedExporterHost
41+
}
42+
3843
func (s *ServiceParameters) Parameters() *templating.Parameters {
3944
parameters := templating.NewParameters("service")
4045
parameters.Set("tls_ca", s.TlsCA)
@@ -65,6 +70,11 @@ func (e *ExporterInstanceTemplater) renderTemplates() (*v1alpha1.ExporterInstanc
6570
templateParametersMap["namespace"] = namespace
6671
templateParametersMap["endpoint"] = endpoint
6772
templateParametersMap["container_image"] = e.exporterConfigTemplate.Spec.ContainerImage
73+
74+
// Add ExporterHost addresses if available (managed devices only)
75+
if e.renderedExporterHost != nil && len(e.renderedExporterHost.Spec.Addresses) > 0 {
76+
templateParametersMap["sidekick_address"] = e.renderedExporterHost.Spec.Addresses[0]
77+
}
6878
templateParameters := templating.NewParameters("exporter-instance")
6979
templateParameters.SetFromMap(templateParametersMap)
7080

0 commit comments

Comments
 (0)