package catalogue import ( "encoding/json" "testing" ) // The other half of an edge. // // `requires` says a thing must be there. It never said what to do with it — a web application // requiring a reverse proxy has to say *which name, which port*, and there was nowhere to put // that. The two modules that needed it most, the proxy and the VPN, went round the outside and // opened a connection to the control plane's database, which is why every node held a credential // to it permanently. // A provision answered from anywhere in the mesh has consumers on other machines, and the // provider has to know who they are. Contributions were node-local until this, which meant the // one case that most needed them was the one they did not reach. func provider() Manifest { return Manifest{Module: "postgres", Version: "1", Provides: FromAnywhere("postgres-database"), Receives: map[string]string{"postgres-database": "/var/lib/postgres/grants/mesh.json"}, Grants: map[string]string{"postgres-database": "/var/lib/postgres/grants"}, } } func grantedTo(t *testing.T, out []map[string]any) []Contribution { t.Helper() for _, r := range out { if r["path"] != "/var/lib/postgres/grants/mesh.json" { continue } var parsed struct { Given []Contribution `json:"given"` } if err := json.Unmarshal([]byte(r["content"].(string)), &parsed); err != nil { t.Fatal(err) } return parsed.Given } t.Fatalf("the provider was given no manifest: %v", out) return nil }