diff --git a/Dockerfile b/Dockerfile index e9f55bb8..c8255318 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,9 +15,9 @@ COPY go.sum go.sum RUN go mod download # Copy the go source -COPY Nimbus/cmd/main.go Nimbus/cmd/main.go -COPY Nimbus/api/ Nimbus/api/ -COPY Nimbus/ontrollers/ Nimbus/controllers/ +COPY cmd/main.go cmd/main.go +COPY pkg/api/ pkg/api/ +COPY pkg/controllers/ pkg/controllers/ # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command diff --git a/Makefile b/Makefile index 26a655b8..684452c9 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust .PHONY: generate generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. - $(CONTROLLER_GEN) object:headerFile="Nimbus/hack/boilerplate.go.txt" paths="./Nimbus/..." + $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./pkg/..." .PHONY: fmt fmt: ## Run go fmt against code. @@ -68,7 +68,7 @@ vet: ## Run go vet against code. test: manifests generate fmt vet envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out -GOLANGCI_LINT = $(shell pwd)/Nimbus/bin/golangci-lint +GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint GOLANGCI_LINT_VERSION ?= v1.54.2 golangci-lint: @[ -f $(GOLANGCI_LINT) ] || { \ @@ -88,11 +88,11 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes .PHONY: build build: manifests generate fmt vet ## Build manager binary. - go build -o Nimbus/bin/manager Nimbus/cmd/main.go + go build -o bin/manager cmd/main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. - go run Nimbus/cmd/main.go + go run cmd/main.go # If you wish to build the manager image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it. @@ -149,7 +149,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi ##@ Build Dependencies ## Location to install dependencies to -LOCALBIN ?= $(shell pwd)/Nimbus/bin +LOCALBIN ?= $(shell pwd)/bin $(LOCALBIN): mkdir -p $(LOCALBIN) diff --git a/Nimbus/bin/controller-gen b/Nimbus/bin/controller-gen deleted file mode 100755 index bc357ab8..00000000 Binary files a/Nimbus/bin/controller-gen and /dev/null differ diff --git a/Nimbus/bin/kustomize b/Nimbus/bin/kustomize deleted file mode 100755 index 5b49fa5d..00000000 Binary files a/Nimbus/bin/kustomize and /dev/null differ diff --git a/Nimbus/cmd/main.go b/cmd/main.go similarity index 95% rename from Nimbus/cmd/main.go rename to cmd/main.go index 146e30e6..5f791ef4 100644 --- a/Nimbus/cmd/main.go +++ b/cmd/main.go @@ -24,11 +24,11 @@ import ( metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" // Importing custom API types and controllers - intentv1 "github.com/5GSEC/nimbus/Nimbus/api/v1" - "github.com/5GSEC/nimbus/Nimbus/controllers" - cleanup "github.com/5GSEC/nimbus/Nimbus/controllers/cleanup" - general "github.com/5GSEC/nimbus/Nimbus/controllers/general" - policy "github.com/5GSEC/nimbus/Nimbus/controllers/policy" + intentv1 "github.com/5GSEC/nimbus/pkg/api/v1" + "github.com/5GSEC/nimbus/pkg/controllers" + cleanup "github.com/5GSEC/nimbus/pkg/controllers/cleanup" + general "github.com/5GSEC/nimbus/pkg/controllers/general" + policy "github.com/5GSEC/nimbus/pkg/controllers/policy" // Importing third-party Kubernetes resource types ciliumv2 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2" diff --git a/go.mod b/go.mod index 53e7242e..48ccb925 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/cilium/cilium v1.14.3 github.com/go-logr/logr v1.3.0 - github.com/kubearmor/KubeArmor/pkg/KubeArmorController v0.0.0-20231215052929-bc6c2f17fe38 + 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 diff --git a/go.sum b/go.sum index fd334e94..bc25ede7 100644 --- a/go.sum +++ b/go.sum @@ -282,6 +282,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kubearmor/KubeArmor/pkg/KubeArmorController v0.0.0-20231215052929-bc6c2f17fe38 h1:nlgCW1NsV9AGk0ghzanS92b91wv18QHOEnEx8PI8MSQ= github.com/kubearmor/KubeArmor/pkg/KubeArmorController v0.0.0-20231215052929-bc6c2f17fe38/go.mod h1:LtrnsoV9isTrXx0ClJgKxSJ/gbYmDj9m3pXIjG1yxBg= +github.com/kubearmor/KubeArmor/pkg/KubeArmorController v0.0.0-20231218054902-8b18cac961c0 h1:Mme8Mfj+g9eQudASTXdz9d/zG2mLIpptvisC9u2RCRQ= +github.com/kubearmor/KubeArmor/pkg/KubeArmorController v0.0.0-20231218054902-8b18cac961c0/go.mod h1:LtrnsoV9isTrXx0ClJgKxSJ/gbYmDj9m3pXIjG1yxBg= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= diff --git a/Nimbus/hack/boilerplate.go.txt b/hack/boilerplate.go.txt similarity index 100% rename from Nimbus/hack/boilerplate.go.txt rename to hack/boilerplate.go.txt diff --git a/Nimbus/api/v1/groupversion_info.go b/pkg/api/v1/groupversion_info.go similarity index 100% rename from Nimbus/api/v1/groupversion_info.go rename to pkg/api/v1/groupversion_info.go diff --git a/Nimbus/api/v1/securityintent_types.go b/pkg/api/v1/securityintent_types.go similarity index 100% rename from Nimbus/api/v1/securityintent_types.go rename to pkg/api/v1/securityintent_types.go diff --git a/Nimbus/api/v1/securityintentbinding_types.go b/pkg/api/v1/securityintentbinding_types.go similarity index 100% rename from Nimbus/api/v1/securityintentbinding_types.go rename to pkg/api/v1/securityintentbinding_types.go diff --git a/Nimbus/api/v1/zz_generated.deepcopy.go b/pkg/api/v1/zz_generated.deepcopy.go similarity index 100% rename from Nimbus/api/v1/zz_generated.deepcopy.go rename to pkg/api/v1/zz_generated.deepcopy.go diff --git a/Nimbus/controllers/cleanup/cleanup.go b/pkg/controllers/cleanup/cleanup.go similarity index 90% rename from Nimbus/controllers/cleanup/cleanup.go rename to pkg/controllers/cleanup/cleanup.go index 501dd604..1d68aa62 100644 --- a/Nimbus/controllers/cleanup/cleanup.go +++ b/pkg/controllers/cleanup/cleanup.go @@ -9,9 +9,9 @@ import ( "github.com/go-logr/logr" "sigs.k8s.io/controller-runtime/pkg/client" - intentv1 "github.com/5GSEC/nimbus/Nimbus/api/v1" - general "github.com/5GSEC/nimbus/Nimbus/controllers/general" - policy "github.com/5GSEC/nimbus/Nimbus/controllers/policy" + intentv1 "github.com/5GSEC/nimbus/pkg/api/v1" + general "github.com/5GSEC/nimbus/pkg/controllers/general" + policy "github.com/5GSEC/nimbus/pkg/controllers/policy" ) // Cleanup is a function to clean up SecurityIntent resources. diff --git a/Nimbus/controllers/general/general_controller.go b/pkg/controllers/general/general_controller.go similarity index 100% rename from Nimbus/controllers/general/general_controller.go rename to pkg/controllers/general/general_controller.go diff --git a/Nimbus/controllers/general/match_intent.go b/pkg/controllers/general/match_intent.go similarity index 97% rename from Nimbus/controllers/general/match_intent.go rename to pkg/controllers/general/match_intent.go index b2e1c899..e2861db9 100644 --- a/Nimbus/controllers/general/match_intent.go +++ b/pkg/controllers/general/match_intent.go @@ -9,7 +9,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" - intentv1 "github.com/5GSEC/nimbus/Nimbus/api/v1" + intentv1 "github.com/5GSEC/nimbus/pkg/api/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/Nimbus/controllers/general/watch_binding.go b/pkg/controllers/general/watch_binding.go similarity index 97% rename from Nimbus/controllers/general/watch_binding.go rename to pkg/controllers/general/watch_binding.go index 7e82a9e2..4a6c85a0 100644 --- a/Nimbus/controllers/general/watch_binding.go +++ b/pkg/controllers/general/watch_binding.go @@ -12,7 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - intentv1 "github.com/5GSEC/nimbus/Nimbus/api/v1" + intentv1 "github.com/5GSEC/nimbus/pkg/api/v1" "k8s.io/apimachinery/pkg/api/errors" ) diff --git a/Nimbus/controllers/general/watch_intent.go b/pkg/controllers/general/watch_intent.go similarity index 97% rename from Nimbus/controllers/general/watch_intent.go rename to pkg/controllers/general/watch_intent.go index c5c302e9..a5675df9 100644 --- a/Nimbus/controllers/general/watch_intent.go +++ b/pkg/controllers/general/watch_intent.go @@ -12,7 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - intentv1 "github.com/5GSEC/nimbus/Nimbus/api/v1" + intentv1 "github.com/5GSEC/nimbus/pkg/api/v1" "k8s.io/apimachinery/pkg/api/errors" ) diff --git a/Nimbus/controllers/policy/network_policy.go b/pkg/controllers/policy/network_policy.go similarity index 94% rename from Nimbus/controllers/policy/network_policy.go rename to pkg/controllers/policy/network_policy.go index 391b5815..e207c804 100644 --- a/Nimbus/controllers/policy/network_policy.go +++ b/pkg/controllers/policy/network_policy.go @@ -12,8 +12,8 @@ import ( ciliumv2 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2" - general "github.com/5GSEC/nimbus/Nimbus/controllers/general" - utils "github.com/5GSEC/nimbus/Nimbus/controllers/utils" + general "github.com/5GSEC/nimbus/pkg/controllers/general" + utils "github.com/5GSEC/nimbus/pkg/controllers/utils" ) // NetworkPolicyController struct to handle network policies. diff --git a/Nimbus/controllers/policy/policy_controller.go b/pkg/controllers/policy/policy_controller.go similarity index 97% rename from Nimbus/controllers/policy/policy_controller.go rename to pkg/controllers/policy/policy_controller.go index 38c00183..1effee67 100644 --- a/Nimbus/controllers/policy/policy_controller.go +++ b/pkg/controllers/policy/policy_controller.go @@ -11,7 +11,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - general "github.com/5GSEC/nimbus/Nimbus/controllers/general" + general "github.com/5GSEC/nimbus/pkg/controllers/general" ) // Constant for the finalizer name used in the SecurityIntent resource. diff --git a/Nimbus/controllers/policy/system_policy.go b/pkg/controllers/policy/system_policy.go similarity index 94% rename from Nimbus/controllers/policy/system_policy.go rename to pkg/controllers/policy/system_policy.go index d98cdc76..3d8c1403 100644 --- a/Nimbus/controllers/policy/system_policy.go +++ b/pkg/controllers/policy/system_policy.go @@ -10,8 +10,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - general "github.com/5GSEC/nimbus/Nimbus/controllers/general" - utils "github.com/5GSEC/nimbus/Nimbus/controllers/utils" + general "github.com/5GSEC/nimbus/pkg/controllers/general" + utils "github.com/5GSEC/nimbus/pkg/controllers/utils" ) // SystemPolicyController is a struct to handle system policies. diff --git a/Nimbus/controllers/securityintent_controller.go b/pkg/controllers/securityintent_controller.go similarity index 96% rename from Nimbus/controllers/securityintent_controller.go rename to pkg/controllers/securityintent_controller.go index e87cb8cd..711b3b9d 100644 --- a/Nimbus/controllers/securityintent_controller.go +++ b/pkg/controllers/securityintent_controller.go @@ -12,8 +12,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/5GSEC/nimbus/Nimbus/api/v1" - general "github.com/5GSEC/nimbus/Nimbus/controllers/general" + "github.com/5GSEC/nimbus/pkg/api/v1" + general "github.com/5GSEC/nimbus/pkg/controllers/general" ) type SecurityIntentReconciler struct { diff --git a/Nimbus/controllers/securityintentbinding_controller.go b/pkg/controllers/securityintentbinding_controller.go similarity index 95% rename from Nimbus/controllers/securityintentbinding_controller.go rename to pkg/controllers/securityintentbinding_controller.go index 8e6ccc5e..4bbaa645 100644 --- a/Nimbus/controllers/securityintentbinding_controller.go +++ b/pkg/controllers/securityintentbinding_controller.go @@ -12,9 +12,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - intentv1 "github.com/5GSEC/nimbus/Nimbus/api/v1" - general "github.com/5GSEC/nimbus/Nimbus/controllers/general" - policy "github.com/5GSEC/nimbus/Nimbus/controllers/policy" + intentv1 "github.com/5GSEC/nimbus/pkg/api/v1" + general "github.com/5GSEC/nimbus/pkg/controllers/general" + policy "github.com/5GSEC/nimbus/pkg/controllers/policy" ) // SecurityIntentBindingReconciler reconciles a SecurityIntentBinding object diff --git a/Nimbus/controllers/suite_test.go b/pkg/controllers/suite_test.go similarity index 98% rename from Nimbus/controllers/suite_test.go rename to pkg/controllers/suite_test.go index 9a0874a7..3516e66b 100644 --- a/Nimbus/controllers/suite_test.go +++ b/pkg/controllers/suite_test.go @@ -19,7 +19,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - intentv1 "github.com/5GSEC/nimbus/Nimbus/api/v1" + intentv1 "github.com/5GSEC/nimbus/pkg/api/v1" //+kubebuilder:scaffold:imports ) diff --git a/Nimbus/controllers/utils/utils_policy.go b/pkg/controllers/utils/utils_policy.go similarity index 99% rename from Nimbus/controllers/utils/utils_policy.go rename to pkg/controllers/utils/utils_policy.go index 7ecdbac7..79d2fdb1 100644 --- a/Nimbus/controllers/utils/utils_policy.go +++ b/pkg/controllers/utils/utils_policy.go @@ -11,7 +11,7 @@ import ( "reflect" "strings" - general "github.com/5GSEC/nimbus/Nimbus/controllers/general" + general "github.com/5GSEC/nimbus/pkg/controllers/general" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" client "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log"