diff --git a/modules/cbt/module.go b/modules/cbt/module.go index 416a01fb..03e0330a 100644 --- a/modules/cbt/module.go +++ b/modules/cbt/module.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "maps" + "strings" "github.com/ethpandaops/panda/pkg/cartographoor" "github.com/ethpandaops/panda/pkg/module" @@ -32,10 +33,18 @@ func New() *Module { return &Module{} } -// NetworkBaseURL returns the CBT instance base URL for a network, derived from -// the standard ethpandaops.io naming convention. Cartographoor discovery does -// not expose a CBT service URL, so the per-network host is derived here. +// NetworkBaseURL returns the CBT instance base URL for a network. Cartographoor +// discovery does not expose a CBT service URL, so the per-network host is +// derived here. Named networks follow the cbt..ethpandaops.io +// convention. Devnets have no such record — their wildcard DNS points at the +// devnet fleet's own ingress, not the cluster hosting CBT — so their instances +// are addressed by the analytics ingress host the mca-devnets ApplicationSet +// provisions per devnet. func NetworkBaseURL(network string) string { + if strings.Contains(network, "-devnet-") { + return fmt.Sprintf("https://%s-xatu-cbt.analytics.production.platform.ethpandaops.io", network) + } + return fmt.Sprintf("https://cbt.%s.ethpandaops.io", network) } @@ -55,7 +64,7 @@ func (m *Module) Validate() error { // SandboxEnv returns environment variables for the sandbox. // Returns ETHPANDAOPS_CBT_NETWORKS with network->URL mapping derived from -// cartographoor active networks using the convention https://cbt.{network}.ethpandaops.io. +// cartographoor active networks via NetworkBaseURL. func (m *Module) SandboxEnv() (map[string]string, error) { if m.cartographoorClient == nil { return nil, nil diff --git a/modules/cbt/module_test.go b/modules/cbt/module_test.go new file mode 100644 index 00000000..3d4c0768 --- /dev/null +++ b/modules/cbt/module_test.go @@ -0,0 +1,42 @@ +package cbt + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestNetworkBaseURL(t *testing.T) { + tests := []struct { + name string + network string + want string + }{ + { + name: "named network uses vanity host", + network: "mainnet", + want: "https://cbt.mainnet.ethpandaops.io", + }, + { + name: "hoodi uses vanity host", + network: "hoodi", + want: "https://cbt.hoodi.ethpandaops.io", + }, + { + name: "glamsterdam devnet uses analytics ingress host", + network: "glamsterdam-devnet-7", + want: "https://glamsterdam-devnet-7-xatu-cbt.analytics.production.platform.ethpandaops.io", + }, + { + name: "bal devnet uses analytics ingress host", + network: "bal-devnet-7", + want: "https://bal-devnet-7-xatu-cbt.analytics.production.platform.ethpandaops.io", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, NetworkBaseURL(tt.network)) + }) + } +}