@@ -363,6 +363,23 @@ func TestDetect(t *testing.T) {
363
363
},
364
364
addFaasID : true ,
365
365
},
366
+ {
367
+ desc : "Bare Metal Solution" ,
368
+ detector : newTestDetector (& fakeGCPDetector {
369
+ projectID : "my-project" ,
370
+ cloudPlatform : gcp .BareMetalSolution ,
371
+ gcpBareMetalSolutionCloudRegion : "us-central1" ,
372
+ gcpBareMetalSolutionInstanceID : "1472385723456792345" ,
373
+ gcpBareMetalSolutionProjectID : "my-project" ,
374
+ }),
375
+ expectedResource : map [string ]any {
376
+ conventions .AttributeCloudProvider : conventions .AttributeCloudProviderGCP ,
377
+ conventions .AttributeCloudAccountID : "my-project" ,
378
+ conventions .AttributeCloudPlatform : "gcp_bare_metal_solution" ,
379
+ conventions .AttributeCloudRegion : "us-central1" ,
380
+ conventions .AttributeHostName : "1472385723456792345" ,
381
+ },
382
+ },
366
383
{
367
384
desc : "Unknown Platform" ,
368
385
detector : newTestDetector (& fakeGCPDetector {
@@ -413,32 +430,35 @@ func newTestDetector(gcpDetector *fakeGCPDetector, opts ...func(*localMetadata.R
413
430
414
431
// fakeGCPDetector implements gcpDetector and uses fake values.
415
432
type fakeGCPDetector struct {
416
- err error
417
- projectID string
418
- cloudPlatform gcp.Platform
419
- gkeAvailabilityZone string
420
- gkeRegion string
421
- gkeClusterName string
422
- gkeHostID string
423
- faaSName string
424
- faaSVersion string
425
- faaSID string
426
- faaSCloudRegion string
427
- appEngineAvailabilityZone string
428
- appEngineRegion string
429
- appEngineServiceName string
430
- appEngineServiceVersion string
431
- appEngineServiceInstance string
432
- gceAvailabilityZone string
433
- gceRegion string
434
- gceHostType string
435
- gceHostID string
436
- gceHostName string
437
- gceHostNameErr error
438
- gcpCloudRunJobExecution string
439
- gcpCloudRunJobTaskIndex string
440
- gcpGceInstanceName string
441
- gcpGceInstanceHostname string
433
+ err error
434
+ projectID string
435
+ cloudPlatform gcp.Platform
436
+ gkeAvailabilityZone string
437
+ gkeRegion string
438
+ gkeClusterName string
439
+ gkeHostID string
440
+ faaSName string
441
+ faaSVersion string
442
+ faaSID string
443
+ faaSCloudRegion string
444
+ appEngineAvailabilityZone string
445
+ appEngineRegion string
446
+ appEngineServiceName string
447
+ appEngineServiceVersion string
448
+ appEngineServiceInstance string
449
+ gceAvailabilityZone string
450
+ gceRegion string
451
+ gceHostType string
452
+ gceHostID string
453
+ gceHostName string
454
+ gceHostNameErr error
455
+ gcpCloudRunJobExecution string
456
+ gcpCloudRunJobTaskIndex string
457
+ gcpGceInstanceName string
458
+ gcpGceInstanceHostname string
459
+ gcpBareMetalSolutionInstanceID string
460
+ gcpBareMetalSolutionCloudRegion string
461
+ gcpBareMetalSolutionProjectID string
442
462
}
443
463
444
464
func (f * fakeGCPDetector ) ProjectID () (string , error ) {
@@ -601,3 +621,24 @@ func (f *fakeGCPDetector) GCEInstanceHostname() (string, error) {
601
621
}
602
622
return f .gcpGceInstanceHostname , nil
603
623
}
624
+
625
+ func (f * fakeGCPDetector ) BareMetalSolutionInstanceID () (string , error ) {
626
+ if f .err != nil {
627
+ return "" , f .err
628
+ }
629
+ return f .gcpBareMetalSolutionInstanceID , nil
630
+ }
631
+
632
+ func (f * fakeGCPDetector ) BareMetalSolutionCloudRegion () (string , error ) {
633
+ if f .err != nil {
634
+ return "" , f .err
635
+ }
636
+ return f .gcpBareMetalSolutionCloudRegion , nil
637
+ }
638
+
639
+ func (f * fakeGCPDetector ) BareMetalSolutionProjectID () (string , error ) {
640
+ if f .err != nil {
641
+ return "" , f .err
642
+ }
643
+ return f .gcpBareMetalSolutionProjectID , nil
644
+ }
0 commit comments