@@ -30,12 +30,14 @@ const testTenantName = "tenant1"
3030
3131func TestGenerateFluentforwardExporters (t * testing.T ) {
3232 tests := []struct {
33- name string
34- resourceRelations components.ResourceRelations
35- expectedResult map [string ]any
33+ name string
34+ resourceRelations components.ResourceRelations
35+ isAxoflowDistribution bool
36+ expectedResult map [string ]any
3637 }{
3738 {
38- name : "Valid config" ,
39+ name : "Valid config" ,
40+ isAxoflowDistribution : true ,
3941 resourceRelations : components.ResourceRelations {
4042 Tenants : []v1alpha1.Tenant {
4143 {
@@ -125,7 +127,8 @@ func TestGenerateFluentforwardExporters(t *testing.T) {
125127 },
126128 },
127129 {
128- name : "All fields set, tls settings omitted" ,
130+ name : "All fields set, tls settings omitted" ,
131+ isAxoflowDistribution : true ,
129132 resourceRelations : components.ResourceRelations {
130133 Tenants : []v1alpha1.Tenant {
131134 {
@@ -233,11 +236,78 @@ func TestGenerateFluentforwardExporters(t *testing.T) {
233236 },
234237 },
235238 },
239+ {
240+ name : "kubernetes_metadata dropped for non-axoflow distribution" ,
241+ isAxoflowDistribution : false ,
242+ resourceRelations : components.ResourceRelations {
243+ Tenants : []v1alpha1.Tenant {
244+ {
245+ ObjectMeta : metav1.ObjectMeta {
246+ Name : testTenantName ,
247+ },
248+ },
249+ },
250+ OutputsWithSecretData : []components.OutputWithSecretData {
251+ {
252+ Output : v1alpha1.Output {
253+ ObjectMeta : metav1.ObjectMeta {
254+ Name : "output3" ,
255+ Namespace : "default" ,
256+ },
257+ Spec : v1alpha1.OutputSpec {
258+ Fluentforward : & v1alpha1.Fluentforward {
259+ TCPClientSettings : v1alpha1.TCPClientSettings {
260+ Endpoint : & v1alpha1.Endpoint {
261+ TCPAddr : new ("http ://example.com"),
262+ },
263+ },
264+ Kubernetes : & v1alpha1.KubernetesMetadata {Key : "key" , IncludePodLabels : true },
265+ },
266+ },
267+ },
268+ },
269+ },
270+ TenantSubscriptionMap : map [string ][]v1alpha1.NamespacedName {
271+ testTenantName : {
272+ {
273+ Name : "sub1" ,
274+ Namespace : "default" ,
275+ },
276+ },
277+ },
278+ SubscriptionOutputMap : map [v1alpha1.NamespacedName ][]v1alpha1.NamespacedName {
279+ {
280+ Name : "sub1" ,
281+ Namespace : "default" ,
282+ }: {
283+ {
284+ Name : "output3" ,
285+ Namespace : "default" ,
286+ },
287+ },
288+ },
289+ },
290+ expectedResult : map [string ]any {
291+ "fluentforwardexporter/default_output3" : map [string ]any {
292+ "endpoint" : map [string ]any {
293+ "tcp_addr" : "http://example.com" ,
294+ },
295+ "sending_queue" : map [string ]any {
296+ "enabled" : true ,
297+ "queue_size" : float64 (1000 ),
298+ },
299+ "retry_on_failure" : map [string ]any {
300+ "enabled" : true ,
301+ "max_elapsed_time" : "0s" ,
302+ },
303+ },
304+ },
305+ },
236306 }
237307
238308 for _ , tt := range tests {
239309 t .Run (tt .name , func (t * testing.T ) {
240- assert .Equal (t , tt .expectedResult , GenerateFluentforwardExporters (context .TODO (), tt .resourceRelations ))
310+ assert .Equal (t , tt .expectedResult , GenerateFluentforwardExporters (context .TODO (), tt .resourceRelations , tt . isAxoflowDistribution ))
241311 })
242312 }
243313}
0 commit comments