@@ -18,7 +18,9 @@ package main
1818
1919import (
2020 "context"
21+ "fmt"
2122 "os"
23+ "strconv"
2224 "strings"
2325
2426 hb "github.com/hachyderm/hachyboop"
@@ -37,8 +39,9 @@ var banner = `
3739`
3840
3941var cfg = & service.HachyboopOptions {
40- S3Output : & service.S3Options {},
41- FileOutput : & service.FileOptions {},
42+ S3Output : & service.S3Options {},
43+ FileOutput : & service.FileOptions {},
44+ RuntimeCloudProviderMetadata : & service.RuntimeCloudProviderMetadata {},
4245}
4346
4447func main () {
@@ -75,6 +78,23 @@ A longer sentence, about how exactly to use this program`,
7578 cfg .Resolvers = strings .Split (cfg .ResolversRaw , "," )
7679 cfg .ObservationHandler = make (chan * service.HachyboopDnsObservation , 32 )
7780
81+ testSec , err := strconv .Atoi (cfg .TestFrequencySecondsRaw )
82+ if err != nil {
83+ logrus .WithField ("rawValue" , cfg .TestFrequencySecondsRaw ).Warn ("couldn't convert HACHYBOOP_TEST_FREQUENCY_SECONDS to an int, defaulting to 300" )
84+ testSec = 300
85+ }
86+ cfg .TestFrequencySeconds = testSec
87+ logrus .WithField ("seconds" , cfg .TestFrequencySeconds ).Info ("Running tests every x seconds" )
88+
89+ // TODO make this dynamic and less hardcoded
90+ if cfg .RuntimeCloudProviderMetadata .BunnyPodId != "" {
91+ logrus .Info ("Cloud provider: Bunny Magic Container Runtime detected" )
92+ cfg .ObservationRegion = fmt .Sprintf ("%s/%s" , cfg .RuntimeCloudProviderMetadata .BunnyRegion , cfg .RuntimeCloudProviderMetadata .BunnyZone )
93+ cfg .ObserverId = fmt .Sprintf ("%s/%s" , cfg .RuntimeCloudProviderMetadata .BunnyAppId , cfg .RuntimeCloudProviderMetadata .BunnyPodId )
94+ }
95+
96+ logrus .WithField ("observer" , cfg .ObserverId ).WithField ("region" , cfg .ObservationRegion ).Debug ("Set region and observer" )
97+
7898 // TODO validate at least one question & one resolver
7999
80100 return hachyboopInstance .Run ()
@@ -89,7 +109,7 @@ A longer sentence, about how exactly to use this program`,
89109 }
90110 logrus .Info ("==========================================================================" )
91111
92- logrus .Debugf ("Parsing config" )
112+ logrus .Debug ("Parsing config" )
93113
94114 // Load environment variables
95115 err = Environment ()
@@ -101,7 +121,7 @@ A longer sentence, about how exactly to use this program`,
101121 // Arbitrary (non-error) pre load
102122 BeforeAppRun ()
103123
104- logrus .Debugf ("Entering main app loop" )
124+ logrus .Debug ("Entering main app loop" )
105125
106126 // Runtime
107127 err = app .Run (context .Background (), os .Args )
0 commit comments