Skip to content

Commit

Permalink
fix: Restructure subresources for cleaner management
Browse files Browse the repository at this point in the history
Signed-off-by: Anurag Rajawat <[email protected]>
  • Loading branch information
anurag-rajawat committed Jan 11, 2024
1 parent 7439b2b commit cc767b3
Show file tree
Hide file tree
Showing 29 changed files with 1,091 additions and 1,719 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN go mod download
# Copy the go source
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/ internal/
COPY pkg/ pkg/

# Build
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ SHELL = /usr/bin/env bash -o pipefail
.PHONY: all
all: build

.PHONY: cleanup
cleanup:
@kubectl delete si --all && kubectl delete sib --all -A && kubectl delete csib --all -A && kubectl delete np --all -A && kubectl delete cwnp --all -A

##@ General

# The help target prints out all targets with their descriptions organized
Expand Down
29 changes: 12 additions & 17 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

// Importing custom API types and controllers

v1 "github.com/5GSEC/nimbus/api/v1"
"github.com/5GSEC/nimbus/internal/controller"
"github.com/5GSEC/nimbus/pkg/exporter/nimbuspolicy"
"github.com/5GSEC/nimbus/pkg/receiver/securityintent"
"github.com/5GSEC/nimbus/pkg/receiver/securityintentbinding"
"github.com/5GSEC/nimbus/pkg/receiver/watcher"
"github.com/5GSEC/nimbus/pkg/watcher"
// Importing third-party Kubernetes resource types
//+kubebuilder:scaffold:imports
)
Expand Down Expand Up @@ -88,25 +83,25 @@ func main() {
os.Exit(1)
}

watcherController, err := watcher.NewWatcherController(mgr.GetClient())
controllerWatcher, err := watcher.NewController(mgr.GetClient())
if err != nil {
setupLog.Error(err, "Unable to create WatcherController")
setupLog.Error(err, "Unable to create ControllerWatcher")
os.Exit(1)
}

if err = (&securityintent.SecurityIntentReconciler{
if err = (&controller.SecurityIntentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
WatcherController: watcherController,
ControllerWatcher: controllerWatcher,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "Unable to create controller", "controller", "SecurityIntent")
os.Exit(1)
}

if err = (&securityintentbinding.SecurityIntentBindingReconciler{
if err = (&controller.SecurityIntentBindingReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
WatcherController: watcherController,
ControllerWatcher: controllerWatcher,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "Unable to create controller", "controller", "SecurityIntentBinding")
os.Exit(1)
Expand All @@ -115,23 +110,23 @@ func main() {
if err = (&controller.ClusterSecurityIntentBindingReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
WatcherController: watcherController,
ControllerWatcher: controllerWatcher,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ClusterSecurityIntentBinding")
os.Exit(1)
}

nimbusPolicyReconciler := nimbuspolicy.NewNimbusPolicyReconciler(mgr.GetClient(), mgr.GetScheme())
nimbusPolicyReconciler := controller.NewNimbusPolicyReconciler(mgr.GetClient(), mgr.GetScheme())
if err != nil {
setupLog.Error(err, "Unable to create NimbusPolicyReconciler")
os.Exit(1)
}
watcherNimbusPolicy, err := watcher.NewWatcherNimbusPolicy(mgr.GetClient())
nimbusPolicywatcher, err := watcher.NewNimbusPolicy(mgr.GetClient())
if err != nil {
setupLog.Error(err, "Unable to create WatcherNimbusPolicy")
setupLog.Error(err, "Unable to create NimbusPolicyWatcher")
os.Exit(1)
}
nimbusPolicyReconciler.WatcherNimbusPolicy = watcherNimbusPolicy
nimbusPolicyReconciler.NimbusPolicyWatcher = nimbusPolicywatcher
if err = nimbusPolicyReconciler.SetupWithManager(mgr); err != nil {
setupLog.Error(err, "Unable to set up NimbusPolicyReconciler with manager", "controller", "NimbusPolicy")
os.Exit(1)
Expand Down
49 changes: 0 additions & 49 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module github.com/5GSEC/nimbus
go 1.21

require (
github.com/cilium/cilium v1.14.3
github.com/kubearmor/KubeArmor/pkg/KubeArmorController v0.0.0-20231218054902-8b18cac961c0
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
k8s.io/apimachinery v0.28.3
Expand All @@ -21,29 +19,16 @@ require (
)

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cilium/ebpf v0.10.1-0.20230626090016-654491c8a500 // indirect
github.com/cilium/proxy v0.0.0-20230623092907-8fddead4e52c // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/runtime v0.26.0 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -54,59 +39,26 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/shirou/gopsutil/v3 v3.23.5 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.16.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/vishvananda/netlink v1.2.1-beta.2.0.20230621221334-77712cff8739 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.mongodb.org/mongo-driver v1.11.3 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/dig v1.17.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
Expand All @@ -116,7 +68,6 @@ require (
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.28.3 // indirect
Expand Down
Loading

0 comments on commit cc767b3

Please sign in to comment.