@@ -407,6 +407,14 @@ func (a *ApiClient) versionFromElasticsearch(ctx context.Context) (*version.Vers
407
407
}
408
408
409
409
func (a * ApiClient ) ServerFlavor (ctx context.Context ) (string , diag.Diagnostics ) {
410
+ if a .elasticsearch != nil {
411
+ return a .flavorFromElasticsearch (ctx )
412
+ }
413
+
414
+ return a .flavorFromKibana ()
415
+ }
416
+
417
+ func (a * ApiClient ) flavorFromElasticsearch (ctx context.Context ) (string , diag.Diagnostics ) {
410
418
info , diags := a .serverInfo (ctx )
411
419
if diags .HasError () {
412
420
return "" , diags
@@ -415,6 +423,32 @@ func (a *ApiClient) ServerFlavor(ctx context.Context) (string, diag.Diagnostics)
415
423
return info .Version .BuildFlavor , nil
416
424
}
417
425
426
+ func (a * ApiClient ) flavorFromKibana () (string , diag.Diagnostics ) {
427
+ kibClient , err := a .GetKibanaClient ()
428
+ if err != nil {
429
+ return "" , diag .Errorf ("failed to get flavor from Kibana API: %s, " +
430
+ "please ensure a working 'kibana' endpoint is configured" , err .Error ())
431
+ }
432
+
433
+ status , err := kibClient .KibanaStatus .Get ()
434
+ if err != nil {
435
+ return "" , diag .Errorf ("failed to get flavor from Kibana API: %s, " +
436
+ "Please ensure a working 'kibana' endpoint is configured" , err .Error ())
437
+ }
438
+
439
+ vMap , ok := status ["version" ].(map [string ]interface {})
440
+ if ! ok {
441
+ return "" , diag .Errorf ("failed to get flavor from Kibana API" )
442
+ }
443
+
444
+ serverFlavor , ok := vMap ["build_flavor" ].(string )
445
+ if ! ok {
446
+ return "" , diag .Errorf ("failed to get build flavor from Kibana status" )
447
+ }
448
+
449
+ return serverFlavor , nil
450
+ }
451
+
418
452
func (a * ApiClient ) ClusterID (ctx context.Context ) (* string , diag.Diagnostics ) {
419
453
info , diags := a .serverInfo (ctx )
420
454
if diags .HasError () {
0 commit comments