Skip to content

Commit

Permalink
Merge pull request #24 from siemens/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
thediveo authored Oct 18, 2023
2 parents 158434e + a8b8044 commit 9d7b3dc
Show file tree
Hide file tree
Showing 53 changed files with 62 additions and 1,711 deletions.
9 changes: 4 additions & 5 deletions api/v1/netns.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import (
"strings"

"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/ghostwire/v2/turtlefinder"
"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/siemens/turtlefinder"
"github.com/thediveo/lxkns/decorator/kuhbernetes"
"github.com/thediveo/lxkns/model"
"github.com/thediveo/whalewatcher/engineclient/moby"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

var titler = cases.Title(language.Und)
Expand Down Expand Up @@ -185,7 +184,7 @@ func (n *networkNamespace) marshal(allnetns *networkNamespaces) ([]byte, error)
GroupID: gid,
ID: cntrID(tenant.Process),
Name: c.Name,
Prefix: c.Labels[turtlefinder.GostwireContainerPrefixLabelName],
Prefix: c.Labels[turtlefinder.TurtlefinderContainerPrefixLabelName],
Labels: c.Labels,
API: c.Engine.API,
PID: c.PID,
Expand Down
7 changes: 3 additions & 4 deletions api/v1/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import (
"time"

"github.com/getkin/kin-openapi/openapi3"
"github.com/thediveo/lxkns/decorator/kuhbernetes"

gostwire "github.com/siemens/ghostwire/v2"
"github.com/siemens/ghostwire/v2/decorator/ieappicon"
"github.com/siemens/ghostwire/v2/test/nerdctl"
"github.com/siemens/ghostwire/v2/turtlefinder"
"github.com/siemens/ghostwire/v2/util"
"github.com/siemens/turtlefinder"
"github.com/thediveo/lxkns/decorator/kuhbernetes"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -106,7 +105,7 @@ var _ = BeforeSuite(func() {
)
for _, c := range disco.Lxkns.Containers {
if c.Name == bareName {
c.Labels[turtlefinder.GostwireContainerPrefixLabelName] = barePrefix
c.Labels[turtlefinder.TurtlefinderContainerPrefixLabelName] = barePrefix
break
}
}
Expand Down
7 changes: 3 additions & 4 deletions api/v1/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ package v1
import (
"strings"

"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/ghostwire/v2/turtlefinder"

gostwire "github.com/siemens/ghostwire/v2"
"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/turtlefinder"
"github.com/thediveo/lxkns/decorator/kuhbernetes"
"github.com/thediveo/lxkns/model"
)
Expand Down Expand Up @@ -108,7 +107,7 @@ func newCaptureTargets(dr gostwire.DiscoveryResult) captureTargets {
NifNames: nifNames,
PID: tenant.Process.PID,
Starttime: tenant.Process.Starttime,
Prefix: container.Labels[turtlefinder.GostwireContainerPrefixLabelName],
Prefix: container.Labels[turtlefinder.TurtlefinderContainerPrefixLabelName],
})
}
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/gostdump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import (
"encoding/json"
"fmt"

apiv1 "github.com/siemens/ghostwire/v2/api/v1"
"github.com/siemens/ghostwire/v2/turtlefinder"

gostwire "github.com/siemens/ghostwire/v2"
apiv1 "github.com/siemens/ghostwire/v2/api/v1"
"github.com/siemens/turtlefinder"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gostwire/cmdroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"time"
"unsafe"

"github.com/siemens/ghostwire/v2/turtlefinder"
"github.com/siemens/turtlefinder"

gostwire "github.com/siemens/ghostwire/v2"

Expand Down
5 changes: 2 additions & 3 deletions cmd/lsallnifs/rootcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import (
"fmt"
"strings"

"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/ghostwire/v2/turtlefinder"

gostwire "github.com/siemens/ghostwire/v2"
"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/turtlefinder"

"github.com/spf13/cobra"
"github.com/thediveo/lxkns/log"
Expand Down
7 changes: 3 additions & 4 deletions decorator/dockernet/dockernet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
"os"
"time"

"github.com/ory/dockertest/v3"
dtclient "github.com/ory/dockertest/v3/docker"
"github.com/siemens/ghostwire/v2/decorator"
"github.com/siemens/ghostwire/v2/internal/discover"
"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/ghostwire/v2/turtlefinder"

"github.com/ory/dockertest/v3"
dtclient "github.com/ory/dockertest/v3/docker"
"github.com/siemens/turtlefinder"
"github.com/thediveo/go-plugger/v3"
lxknsdiscover "github.com/thediveo/lxkns/discover"
"github.com/thediveo/lxkns/model"
Expand Down
4 changes: 2 additions & 2 deletions decorator/nerdctlnet/nerdctlnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
"os"
"time"

"github.com/onsi/gomega/gexec"
"github.com/siemens/ghostwire/v2/decorator"
"github.com/siemens/ghostwire/v2/internal/discover"
"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/ghostwire/v2/test/nerdctl"
"github.com/siemens/ghostwire/v2/turtlefinder"
"github.com/siemens/ghostwire/v2/util"
"github.com/siemens/turtlefinder"
"github.com/thediveo/go-plugger/v3"
"github.com/thediveo/lxkns/model"
"github.com/thediveo/whalewatcher/watcher/containerd"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
. "github.com/onsi/gomega/gleak"
. "github.com/thediveo/fdooze"
)
Expand Down
2 changes: 1 addition & 1 deletion discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
_ "github.com/siemens/ghostwire/v2/decorator/all" // activate all Gostwire-specific decorators.
"github.com/siemens/ghostwire/v2/internal/discover"
"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/ghostwire/v2/turtlefinder"
"github.com/siemens/turtlefinder"
"github.com/thediveo/lxkns/containerizer"
lxknsdiscover "github.com/thediveo/lxkns/discover"
"github.com/thediveo/lxkns/model"
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"fmt"

"github.com/siemens/ghostwire/v2/turtlefinder"
"github.com/siemens/turtlefinder"
)

func Example_discovery() {
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ require (
require (
github.com/containerd/log v0.1.0 // indirect
gotest.tools v2.2.0+incompatible // indirect
k8s.io/cri-api v0.28.2 // indirect
)

require (
Expand Down Expand Up @@ -115,6 +116,7 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/siemens/turtlefinder v1.0.1
github.com/spf13/pflag v1.0.5 // indirect
github.com/thediveo/go-mntinfo v1.0.1 // indirect
github.com/thediveo/ioctl v0.9.2
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ github.com/siemens/ieddata v1.0.0 h1:jS4w5G/XBZ28s48IQfFmocNYkXrTQvMVzCgaWKSXqmg
github.com/siemens/ieddata v1.0.0/go.mod h1:klA6Gx4K55NrSp8re+rZb7XuCIL8vI5jWgRYfoghiE4=
github.com/siemens/mobydig v1.0.0 h1:kOZ0QYwXGxAuhT+A3Dz1QGoaovxyywVvwEvLC9yETkc=
github.com/siemens/mobydig v1.0.0/go.mod h1:TtROWS4S7mfaAFUGmbhaZ9jnUFsdfLWYnLPTi+44g4Q=
github.com/siemens/turtlefinder v1.0.1 h1:CMReXXC5dWu1/JJTLyxZ6ja20GleyVuRD9gcxUNpjIo=
github.com/siemens/turtlefinder v1.0.1/go.mod h1:GCWkpEhDxcOyYN5ZqXpss1uxc70Lbg3TsZdcyQEMlw4=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
Expand Down Expand Up @@ -645,6 +647,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.2.1/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY=
honnef.co/go/tools v0.2.2 h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1xvnzk=
honnef.co/go/tools v0.2.2/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY=
k8s.io/cri-api v0.28.2 h1:RzDo9YY9tkWhAx9/UZEcn6ug1WcvDhU3eA1YLevFreI=
k8s.io/cri-api v0.28.2/go.mod h1:xXygwvSOGcT/2KXg8sMYTHns2xFem3949kCQn5IS1k4=
sigs.k8s.io/kind v0.20.0 h1:f0sc3v9mQbGnjBUaqSFST1dwIuiikKVGgoTwpoP33a8=
sigs.k8s.io/kind v0.20.0/go.mod h1:aBlbxg08cauDgZ612shr017/rZwqd7AS563FvpWKPVs=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
Expand Down
3 changes: 1 addition & 2 deletions internal/discover/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (

"github.com/siemens/ghostwire/v2/decorator"
"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/ghostwire/v2/turtlefinder"

"github.com/siemens/turtlefinder"
"github.com/thediveo/go-plugger/v3"
"github.com/thediveo/lxkns/containerizer"
lxknsdiscover "github.com/thediveo/lxkns/discover"
Expand Down
6 changes: 2 additions & 4 deletions metadata/engines/engines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import (
"os"
"time"

"github.com/siemens/ghostwire/v2/turtlefinder"

gostwire "github.com/siemens/ghostwire/v2"

"github.com/ory/dockertest"
gostwire "github.com/siemens/ghostwire/v2"
"github.com/siemens/turtlefinder"
"github.com/thediveo/lxkns/containerizer"
"github.com/thediveo/lxkns/model"
"github.com/thediveo/whalewatcher/engineclient/moby"
Expand Down
7 changes: 3 additions & 4 deletions metadata/iecore/iecore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import (
"sync"
"time"

gostwire "github.com/siemens/ghostwire/v2"
"github.com/siemens/ghostwire/v2/turtlefinder"
"github.com/siemens/ieddata"

"github.com/cenkalti/backoff/v4"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
gostwire "github.com/siemens/ghostwire/v2"
"github.com/siemens/ieddata"
"github.com/siemens/turtlefinder"
"github.com/thediveo/lxkns/containerizer"
"github.com/thediveo/lxkns/model"
"github.com/thediveo/lxkns/species"
Expand Down
7 changes: 3 additions & 4 deletions mobydig/mobydig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import (
"os"
"time"

lxknsdiscover "github.com/thediveo/lxkns/discover"
"github.com/thediveo/lxkns/model"

"github.com/siemens/ghostwire/v2/internal/discover"
"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/ghostwire/v2/turtlefinder"
"github.com/siemens/mobydig/messymoby"
"github.com/siemens/turtlefinder"
lxknsdiscover "github.com/thediveo/lxkns/discover"
"github.com/thediveo/lxkns/model"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
7 changes: 3 additions & 4 deletions mobydig/neighborhood_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import (
"os"
"time"

lxknsdiscover "github.com/thediveo/lxkns/discover"
"github.com/thediveo/lxkns/model"

"github.com/siemens/ghostwire/v2/decorator/dockernet"
"github.com/siemens/ghostwire/v2/internal/discover"
"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/ghostwire/v2/turtlefinder"
"github.com/siemens/mobydig/messymoby"
"github.com/siemens/turtlefinder"
lxknsdiscover "github.com/thediveo/lxkns/discover"
"github.com/thediveo/lxkns/model"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
27 changes: 20 additions & 7 deletions test/kind/kind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ import (
"os"

"github.com/siemens/ghostwire/v2/internal/discover"
"github.com/siemens/ghostwire/v2/turtlefinder"
"github.com/siemens/ghostwire/v2/util"
"github.com/siemens/turtlefinder"
"github.com/thediveo/lxkns/containerizer"
"github.com/thediveo/lxkns/model"
"github.com/thediveo/whalewatcher/watcher/moby"
"sigs.k8s.io/kind/pkg/cluster"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/types"
. "github.com/thediveo/success"
)

Expand All @@ -35,6 +36,18 @@ nodes:

const kindTestClusterName = "gw-kind-test"

func withPrefix(prefix string) types.GomegaMatcher {
return WithTransform(func(actual any) (string, error) {
switch container := actual.(type) {
case *model.Container:
return container.Labels[turtlefinder.TurtlefinderContainerPrefixLabelName], nil
case model.Container:
return container.Labels[turtlefinder.TurtlefinderContainerPrefixLabelName], nil
}
return "", fmt.Errorf("withPrefix expects a model.Container or *model.Container, but got %T", actual)
}, Equal(prefix))
}

var _ = Describe("kind", func() {

var prov *cluster.Provider
Expand Down Expand Up @@ -85,10 +98,10 @@ var _ = Describe("kind", func() {
}, "10s", "500ms").Should(ContainElements(
SatisfyAll(
util.HaveContainer(kindTestClusterName+"-control-plane", moby.Type),
turtlefinder.WithPrefix("")),
withPrefix("")),
SatisfyAll(
util.HaveContainer(kindTestClusterName+"-worker", moby.Type),
turtlefinder.WithPrefix("")),
withPrefix("")),
))
})

Expand All @@ -101,16 +114,16 @@ var _ = Describe("kind", func() {
}, "10s", "500ms").Should(ContainElements(
SatisfyAll(
util.FromPod(MatchRegexp(`^kube-system/etcd-%s-control-plane$`, kindTestClusterName)),
turtlefinder.WithPrefix(kindTestClusterName+"-control-plane")),
withPrefix(kindTestClusterName+"-control-plane")),
SatisfyAll(
util.FromPod(MatchRegexp(`^kube-system/kube-proxy-\w+`)),
turtlefinder.WithPrefix(kindTestClusterName+"-control-plane")),
withPrefix(kindTestClusterName+"-control-plane")),
SatisfyAll(
util.FromPod(MatchRegexp(`^kube-system/coredns-\w+-\w+$`)),
turtlefinder.WithPrefix(kindTestClusterName+"-control-plane")),
withPrefix(kindTestClusterName+"-control-plane")),
SatisfyAll(
util.FromPod(MatchRegexp(`^kube-system/kube-proxy-\w+`)),
turtlefinder.WithPrefix(kindTestClusterName+"-worker")),
withPrefix(kindTestClusterName+"-worker")),
), func() string {
return fmt.Sprintf("current pod list: %v", util.AllPods(containers))
})
Expand Down
10 changes: 0 additions & 10 deletions turtlefinder/detector/all/all.go

This file was deleted.

4 changes: 0 additions & 4 deletions turtlefinder/detector/all/doc.go

This file was deleted.

17 changes: 0 additions & 17 deletions turtlefinder/detector/all/package_test.go

This file was deleted.

Loading

0 comments on commit 9d7b3dc

Please sign in to comment.