Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions modules/cbt/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"maps"
"strings"

"github.com/ethpandaops/panda/pkg/cartographoor"
"github.com/ethpandaops/panda/pkg/module"
Expand Down Expand Up @@ -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.<network>.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)
}

Expand All @@ -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
Expand Down
42 changes: 42 additions & 0 deletions modules/cbt/module_test.go
Original file line number Diff line number Diff line change
@@ -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))
})
}
}