The controller's own composition it compared mesh-sdk's with is deleted by the commit before; compose_equal_test.go held the comparison (bothWaysDiffer, madeDiffer and their helpers) and is not needed with nothing to compare against. The made type, which compose_perform_integration_test still reads a store through, moves next to madeIn.
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
//go:build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"sort"
|
|
)
|
|
|
|
// made is what a send made in a store, by key and never by value: the machine ports given, the pair credentials and the
|
|
// own secrets.
|
|
type made struct {
|
|
Ports []string
|
|
Pairs []string
|
|
OwnSecrets []string
|
|
}
|
|
|
|
// madeIn is what a store holds that a send makes, by key and never by value.
|
|
func madeIn(ctx context.Context, open *stores) (made, error) {
|
|
var out made
|
|
inv := open.inventory
|
|
nodes, err := inv.Nodes(ctx)
|
|
if err != nil {
|
|
return out, err
|
|
}
|
|
for _, n := range nodes {
|
|
ports, err := inv.PortsFor(ctx, n.Name)
|
|
if err != nil {
|
|
return out, err
|
|
}
|
|
for _, p := range ports {
|
|
out.Ports = append(out.Ports, fmt.Sprintf("%s %s:%d->%d", n.Name, p.Module, p.Wanted, p.Machine))
|
|
}
|
|
rows, err := inv.SecretsFrom(ctx, n.Name)
|
|
if err != nil {
|
|
return out, err
|
|
}
|
|
for _, s := range rows {
|
|
out.Pairs = append(out.Pairs, fmt.Sprintf("%s %s on %s from %s local=%s", s.Name, s.ConsumerModule, s.Consumer, n.Name, s.Local))
|
|
}
|
|
}
|
|
own, err := inv.OwnSecretRows(ctx)
|
|
if err != nil {
|
|
return out, err
|
|
}
|
|
for _, r := range own {
|
|
out.OwnSecrets = append(out.OwnSecrets, fmt.Sprintf("%s %s/%s (%s)", r.Node, r.Module, r.Name, r.Origin))
|
|
}
|
|
sort.Strings(out.Ports)
|
|
sort.Strings(out.Pairs)
|
|
sort.Strings(out.OwnSecrets)
|
|
return out, nil
|
|
}
|