From c11a3fa122d02fdb1126bb22ac4f54f6c6413bb6 Mon Sep 17 00:00:00 2001 From: Bence Csati Date: Thu, 24 Oct 2024 13:09:57 +0200 Subject: [PATCH] chore: tidy up Signed-off-by: Bence Csati --- .gitignore | 1 - Makefile | 65 +++++++------ PROJECT | 9 +- api/telemetry/v1alpha1/output_types.go | 6 -- config/crd/kustomization.yaml | 6 +- config/samples/telemetry_v1alpha1_bridge.yaml | 8 +- .../samples/telemetry_v1alpha1_collector.yaml | 1 + config/samples/telemetry_v1alpha1_tenant.yaml | 3 + e2e/e2e_test.sh | 4 +- go.mod | 92 ++++++++----------- go.sum | 28 ------ .../telemetry/otel_conf_gen_test.go | 5 +- .../controller/telemetry/route_controller.go | 17 ++-- 13 files changed, 106 insertions(+), 139 deletions(-) diff --git a/.gitignore b/.gitignore index dc78265d..84021b67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ - # Binaries for programs and plugins *.exe *.exe~ diff --git a/Makefile b/Makefile index 6ad287a7..dd08bfdf 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ CI_MODE_ENABLED := "" NO_KIND_CLEANUP := "" # Image URL to use all building/pushing image targets -IMG ?= ghcr.io/kube-logging/telemetry-controller:dev +IMG ?= controller:local # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.28.0 @@ -79,6 +79,10 @@ fmt: ## Run go fmt against code. vet: ## Run go vet against code. go vet ./... +.PHONY: tidy +tidy: ## Tidy Go modules + find . -iname "go.mod" -not -path "./.devcontainer/*" | xargs -L1 sh -c 'cd $$(dirname $$0); go mod tidy' + .PHONY: test test: manifests generate fmt vet envtest ## Run verifications and tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -v ./... -coverprofile cover.out @@ -99,6 +103,33 @@ lint: golangci-lint ## Run golangci-lint lint-fix: golangci-lint ## Run golangci-lint and perform fixes $(GOLANGCI_LINT) run --fix +.PHONY: run-delve +run-delve: generate fmt vet manifests + go build -o bin/manager cmd/main.go + dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./bin/manager + +.PHONY: e2e-test +e2e-test: ## Run e2e tests + cd e2e && export CI_MODE=$(CI_MODE_ENABLED) NO_KIND_CLEANUP=$(NO_KIND_CLEANUP) && $(TIMEOUT_CMD) --foreground 15m ./e2e_test.sh || (echo "E2E test failed"; exit 1) + +.PHONY: e2e-test-ci +e2e-test-ci: CI_MODE_ENABLED=1 +e2e-test-ci: NO_KIND_CLEANUP=1 +e2e-test-ci: docker-build e2e-test + +.PHONY: check-diff +check-diff: generate + git diff --exit-code + +.PHONY: license-check +license-check: ${LICENSEI} .licensei.cache ## Run license check + ${LICENSEI} check + ${LICENSEI} header + +.PHONY: license-cache +license-cache: ${LICENSEI} ## Generate license cache + ${LICENSEI} cache + ##@ Build .PHONY: build @@ -207,38 +238,6 @@ envtest: $(ENVTEST) crddir/github.com/open-telemetry/opentelemetry-operator ## D $(ENVTEST): $(LOCALBIN) test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest -.PHONY: run-delve -run-delve: generate fmt vet manifests - go build -o bin/manager cmd/main.go - dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./bin/manager - -.PHONY: tidy -tidy: ## Tidy Go modules - find . -iname "go.mod" -not -path "./.devcontainer/*" | xargs -L1 sh -c 'cd $$(dirname $$0); go mod tidy' - -.PHONY: e2e-test -e2e-test: ## Run e2e tests - cd e2e && export CI_MODE=$(CI_MODE_ENABLED) NO_KIND_CLEANUP=$(NO_KIND_CLEANUP) && $(TIMEOUT_CMD) --foreground 15m ./e2e_test.sh || (echo "E2E test failed"; exit 1) - -.PHONY: e2e-test-ci -e2e-test-ci: CI_MODE_ENABLED=1 -e2e-test-ci: NO_KIND_CLEANUP=1 -e2e-test-ci: IMG="controller:latest" ## Run e2e tests, telemetry collector runs inside k8s -e2e-test-ci: docker-build e2e-test - -.PHONY: check-diff -check-diff: generate - git diff --exit-code - -.PHONY: license-check -license-check: ${LICENSEI} .licensei.cache ## Run license check - ${LICENSEI} check - ${LICENSEI} header - -.PHONY: license-cache -license-cache: ${LICENSEI} ## Generate license cache - ${LICENSEI} cache - stern: | ${BIN} GOBIN=${BIN} go install github.com/stern/stern@latest diff --git a/PROJECT b/PROJECT index b6f49913..7c6b210e 100644 --- a/PROJECT +++ b/PROJECT @@ -11,7 +11,6 @@ repo: github.com/kube-logging/telemetry-controller resources: - api: crdVersion: v1 - namespaced: true controller: true domain: kube-logging.dev group: telemetry @@ -28,7 +27,6 @@ resources: version: v1alpha1 - api: crdVersion: v1 - namespaced: true domain: kube-logging.dev group: telemetry kind: Tenant @@ -42,4 +40,11 @@ resources: kind: Output path: github.com/kube-logging/telemetry-controller/api/telemetry/v1alpha1 version: v1alpha1 +- api: + crdVersion: v1 + domain: kube-logging.dev + group: telemetry + kind: Bridge + path: github.com/kube-logging/telemetry-controller/api/telemetry/v1alpha1 + version: v1alpha1 version: "3" diff --git a/api/telemetry/v1alpha1/output_types.go b/api/telemetry/v1alpha1/output_types.go index aca62b48..8b2224db 100644 --- a/api/telemetry/v1alpha1/output_types.go +++ b/api/telemetry/v1alpha1/output_types.go @@ -22,14 +22,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // OutputSpec defines the desired state of Output type OutputSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - OTLPGRPC *OTLPGRPC `json:"otlp,omitempty"` Fluentforward *Fluentforward `json:"fluentforward,omitempty"` OTLPHTTP *OTLPHTTP `json:"otlphttp,omitempty"` diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 6e74f0a2..cab75664 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -12,18 +12,20 @@ resources: patches: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -#- path: patches/webhook_in_collectors.yaml +#- path: patches/webhook_in_telemetry_collectors.yaml #- path: patches/webhook_in_telemetry_subscriptions.yaml #- path: patches/webhook_in_telemetry_tenants.yaml #- path: patches/webhook_in_telemetry_outputs.yaml +#- path: patches/webhook_in_telemetry_bridges.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -#- path: patches/cainjection_in_collectors.yaml +#- path: patches/cainjection_in_telemetry_collectors.yaml #- path: patches/cainjection_in_telemetry_subscriptions.yaml #- path: patches/cainjection_in_telemetry_tenants.yaml #- path: patches/cainjection_in_telemetry_outputs.yaml +#- path: patches/cainjection_in_telemetry_bridges.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section diff --git a/config/samples/telemetry_v1alpha1_bridge.yaml b/config/samples/telemetry_v1alpha1_bridge.yaml index b949f174..9bf42a8b 100644 --- a/config/samples/telemetry_v1alpha1_bridge.yaml +++ b/config/samples/telemetry_v1alpha1_bridge.yaml @@ -1,7 +1,13 @@ apiVersion: telemetry.kube-logging.dev/v1alpha1 kind: Bridge metadata: - name: shared-tenantA + labels: + app.kubernetes.io/name: bridge + app.kubernetes.io/instance: bridge-sample + app.kubernetes.io/part-of: telemetry-controller + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/created-by: telemetry-controller + name: bridge-sample spec: sourceTenant: shared destinationTenant: tenantA diff --git a/config/samples/telemetry_v1alpha1_collector.yaml b/config/samples/telemetry_v1alpha1_collector.yaml index f2e6d524..26f2374b 100644 --- a/config/samples/telemetry_v1alpha1_collector.yaml +++ b/config/samples/telemetry_v1alpha1_collector.yaml @@ -9,6 +9,7 @@ metadata: app.kubernetes.io/created-by: telemetry-controller name: collector-sample spec: + controlNamespace: collector tenantSelector: matchLabels: tenant: tenantA diff --git a/config/samples/telemetry_v1alpha1_tenant.yaml b/config/samples/telemetry_v1alpha1_tenant.yaml index de0a3083..ab1050a0 100644 --- a/config/samples/telemetry_v1alpha1_tenant.yaml +++ b/config/samples/telemetry_v1alpha1_tenant.yaml @@ -13,3 +13,6 @@ spec: subscriptionNamespaceSelector: matchLabels: nsTenant: tenantA + logSourceNamespaceSelector: + matchLabels: + nsTenant: tenantA diff --git a/e2e/e2e_test.sh b/e2e/e2e_test.sh index 5476eee5..9eceb8a2 100755 --- a/e2e/e2e_test.sh +++ b/e2e/e2e_test.sh @@ -24,8 +24,10 @@ TIMEOUT_CMD=timeout kind create cluster --name "${KIND_CLUSTER_NAME}" --wait 5m kubectl config set-context kind-"${KIND_CLUSTER_NAME}" +kind load docker-image controller:local --name "${KIND_CLUSTER_NAME}" + # Install telemetry-controller and opentelemetry-operator -helm upgrade --install --wait --create-namespace --namespace telemetry-controller-system telemetry-controller oci://ghcr.io/kube-logging/helm-charts/telemetry-controller +helm upgrade --install --wait --create-namespace --namespace telemetry-controller-system telemetry-controller oci://ghcr.io/kube-logging/helm-charts/telemetry-controller --set image.repository=controller --set image.tag=local # Wait for the pod to be ready, without it the webhook backend service will be unavailable. sleep 10 diff --git a/go.mod b/go.mod index 43b99106..3c915362 100644 --- a/go.mod +++ b/go.mod @@ -7,101 +7,86 @@ toolchain go1.22.3 require ( emperror.dev/errors v0.8.1 github.com/cisco-open/operator-tools v0.34.0 + github.com/google/go-cmp v0.6.0 github.com/onsi/ginkgo/v2 v2.17.3 github.com/onsi/gomega v1.33.1 github.com/open-telemetry/opentelemetry-operator v0.103.0 + github.com/prometheus/client_golang v1.19.1 github.com/siliconbrain/go-mapseqs v0.2.0 github.com/siliconbrain/go-seqs v0.12.0 + github.com/stretchr/testify v1.9.0 + go.opentelemetry.io/collector/config/configauth v0.103.0 + go.opentelemetry.io/collector/config/configcompression v1.7.0 + go.opentelemetry.io/collector/config/configopaque v1.16.0 + golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 + k8s.io/api v0.30.2 k8s.io/apimachinery v0.30.2 k8s.io/client-go v0.30.2 sigs.k8s.io/controller-runtime v0.18.4 + sigs.k8s.io/yaml v1.4.0 ) require ( - github.com/go-viper/mapstructure/v2 v2.1.0 - go.opentelemetry.io/collector/config/configauth v0.103.0 - go.opentelemetry.io/collector/config/configopaque v1.16.0 -) - -require ( - github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect + github.com/beorn7/perks v1.0.1 // indirect github.com/briandowns/spinner v1.23.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cisco-open/k8s-objectmatcher v1.9.0 // indirect github.com/cppforlife/go-patch v0.2.0 // indirect - github.com/evanphx/json-patch v5.9.0+incompatible // indirect - github.com/fatih/color v1.16.0 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/iancoleman/orderedmap v0.3.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/nxadm/tail v1.4.8 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/spf13/cast v1.6.0 // indirect - github.com/tg123/go-htpasswd v1.2.2 // indirect - github.com/wayneashleyberry/terminal-dimensions v1.1.0 // indirect - go.opentelemetry.io/collector/client v1.16.0 // indirect - go.opentelemetry.io/collector/component v0.110.0 // indirect - go.opentelemetry.io/collector/config/configtelemetry v0.110.0 // indirect - go.opentelemetry.io/collector/extension v0.110.0 // indirect - go.opentelemetry.io/collector/extension/auth v0.110.0 // indirect - go.opentelemetry.io/collector/internal/globalsignal v0.110.0 // indirect - go.opentelemetry.io/collector/pdata v1.16.0 // indirect - go.opentelemetry.io/collector/pipeline v0.110.0 // indirect - go.opentelemetry.io/otel v1.30.0 // indirect - go.opentelemetry.io/otel/exporters/prometheus v0.49.0 // indirect - go.opentelemetry.io/otel/metric v1.30.0 // indirect - go.opentelemetry.io/otel/sdk v1.30.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.30.0 // indirect - go.opentelemetry.io/otel/trace v1.30.0 // indirect - golang.org/x/crypto v0.26.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/grpc v1.66.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - -) - -require ( - github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/go-restful/v3 v3.12.0 // indirect + github.com/evanphx/json-patch v5.9.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect + github.com/fatih/color v1.16.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.6.0 github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect github.com/google/uuid v1.6.0 // indirect + github.com/iancoleman/orderedmap v0.3.0 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // 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/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.110.0 - github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension v0.110.0 + github.com/nxadm/tail v1.4.8 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.19.1 + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.54.0 // indirect github.com/prometheus/procfs v0.15.0 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/collector/config/configcompression v1.7.0 + github.com/wayneashleyberry/terminal-dimensions v1.1.0 // indirect + go.opentelemetry.io/collector/component v0.110.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.110.0 // indirect + go.opentelemetry.io/collector/extension v0.110.0 // indirect + go.opentelemetry.io/collector/extension/auth v0.110.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.110.0 // indirect + go.opentelemetry.io/collector/pdata v1.16.0 // indirect + go.opentelemetry.io/collector/pipeline v0.110.0 // indirect + go.opentelemetry.io/otel v1.30.0 // indirect + go.opentelemetry.io/otel/exporters/prometheus v0.49.0 // indirect + go.opentelemetry.io/otel/metric v1.30.0 // indirect + go.opentelemetry.io/otel/sdk v1.30.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.30.0 // indirect + go.opentelemetry.io/otel/trace v1.30.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 golang.org/x/net v0.28.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sys v0.25.0 // indirect @@ -110,15 +95,16 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect + google.golang.org/grpc v1.66.2 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/api v0.30.2 + gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.30.2 // indirect k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20240322212309-b815d8309940 // indirect k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.4.0 ) diff --git a/go.sum b/go.sum index 1805f1da..97484ae4 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ emperror.dev/errors v0.8.1 h1:UavXZ5cSX/4u9iyvH6aDcuGkVjeexUGJ7Ij7G4VfQT0= emperror.dev/errors v0.8.1/go.mod h1:YcRvLPh626Ubn2xqtoprejnA5nFha+TJ+2vew48kWuE= -github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 h1:KeNholpO2xKjgaaSyd+DyQRrsQjhbSeS7qe4nEw8aQw= -github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962/go.mod h1:kC29dT1vFpj7py2OvG1khBdQpo3kInWP+6QipLbdngo= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A= @@ -48,8 +46,6 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= -github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= -github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= @@ -78,12 +74,6 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= -github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= -github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= -github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= -github.com/knadh/koanf/v2 v2.1.1 h1:/R8eXqasSTsmDCsAyYj+81Wteg8AqrV9CP6gvsTsOmM= -github.com/knadh/koanf/v2 v2.1.1/go.mod h1:4mnTRbZCK+ALuBXHZMjDfG9y714L7TykVnZkXbMU3Es= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -95,10 +85,6 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= -github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= -github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -114,10 +100,6 @@ github.com/onsi/ginkgo/v2 v2.17.3 h1:oJcvKpIb7/8uLpDDtnQuf18xVnwKp8DTD7DQ6gTd/MU github.com/onsi/ginkgo/v2 v2.17.3/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= -github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.110.0 h1:OzdaJriUgOT2iyFG4f9pjQdgruYO2P77fw5Z4tjm5iQ= -github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.110.0/go.mod h1:y7jCFpCEEN6HRyeu6tJQtZZkw6q/ZwBa6JTpm//T9NE= -github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension v0.110.0 h1:QfCtczND32VwLrw80qbLcMIPeCMYdsPX6a/MGek0cbc= -github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension v0.110.0/go.mod h1:l1SQz/z61b8I+EQOOK0ZET8qHyTidBbaFWKEnwtTOB4= github.com/open-telemetry/opentelemetry-operator v0.103.0 h1:L0REMuJSMZjqCw7p7fWMn19XkiIULMr3NnHdPLryMQs= github.com/open-telemetry/opentelemetry-operator v0.103.0/go.mod h1:kf5B7DLm4m88avApWmHhBjn66fQfSABM2cuQfHqAR+Y= github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw= @@ -149,14 +131,10 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tg123/go-htpasswd v1.2.2 h1:tmNccDsQ+wYsoRfiONzIhDm5OkVHQzN3w4FOBAlN6BY= -github.com/tg123/go-htpasswd v1.2.2/go.mod h1:FcIrK0J+6zptgVwK1JDlqyajW/1B4PtuJ/FLWl7nx8A= github.com/wayneashleyberry/terminal-dimensions v1.1.0 h1:EB7cIzBdsOzAgmhTUtTTQXBByuPheP/Zv1zL2BRPY6g= github.com/wayneashleyberry/terminal-dimensions v1.1.0/go.mod h1:2lc/0eWCObmhRczn2SdGSQtgBooLUzIotkkEGXqghyg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/collector/client v1.16.0 h1:3m7HzWR41+4M8r9q7UvEDjMBTFMrik/BdvAuwCs0cV4= -go.opentelemetry.io/collector/client v1.16.0/go.mod h1:N01Alc/CouREl18hmxdaQXGfID7dBZrrbsBar7WHkZ0= go.opentelemetry.io/collector/component v0.110.0 h1:z7uSY/1dcK+vTY2z3v0XxeCoi2wqgHTow/ds3Gozuz4= go.opentelemetry.io/collector/component v0.110.0/go.mod h1:W99gZdfGtQ5Zg6Bhrwrcl/uZcCG+2qBnZ1z2JO5WCW0= go.opentelemetry.io/collector/config/configauth v0.103.0 h1:tv2Ilj0X9T8ZsDd4mB8Sl+nXQ8CG8MJVQ1Lo4mmE0Pk= @@ -167,10 +145,6 @@ go.opentelemetry.io/collector/config/configopaque v1.16.0 h1:83cVlPL151kHWrHLUAk go.opentelemetry.io/collector/config/configopaque v1.16.0/go.mod h1:6zlLIyOoRpJJ+0bEKrlZOZon3rOp5Jrz9fMdR4twOS4= go.opentelemetry.io/collector/config/configtelemetry v0.110.0 h1:V8Y/Xv7TJpnNGHLrheRKrMydcKBxWYAZ+dj71Kllyos= go.opentelemetry.io/collector/config/configtelemetry v0.110.0/go.mod h1:R0MBUxjSMVMIhljuDHWIygzzJWQyZHXXWIgQNxcFwhc= -go.opentelemetry.io/collector/confmap v1.16.0 h1:0bWw/XSosX6xoE1sGsaD3glzRtSxanrF4sgib3jAYr4= -go.opentelemetry.io/collector/confmap v1.16.0/go.mod h1:GrIZ12P/9DPOuTpe2PIS51a0P/ZM6iKtByVee1Uf3+k= -go.opentelemetry.io/collector/consumer v0.110.0 h1:CnB83KSFQxhFAbNJwTM0blahg16xa6CyUnIIA5qPMbA= -go.opentelemetry.io/collector/consumer v0.110.0/go.mod h1:WlzhfwDfwKkEa5XFdN5x9+jjp9ZF5EUSmtOgVe69zm0= go.opentelemetry.io/collector/extension v0.110.0 h1:AYFk57W25f7xOo3I6pV0rWNWVtOLZsW+lzFCctnvCkU= go.opentelemetry.io/collector/extension v0.110.0/go.mod h1:zD/pw9o83SFyn/DCbBdBcH0eUPyGtYgpMSAOqotFYRc= go.opentelemetry.io/collector/extension/auth v0.110.0 h1:9SHC2sF/KR99LciHABDXRIsXLiujzIjTJpWHO0V8Bqg= @@ -204,8 +178,6 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= diff --git a/internal/controller/telemetry/otel_conf_gen_test.go b/internal/controller/telemetry/otel_conf_gen_test.go index 059a2e71..2a7c2ab8 100644 --- a/internal/controller/telemetry/otel_conf_gen_test.go +++ b/internal/controller/telemetry/otel_conf_gen_test.go @@ -27,7 +27,6 @@ import ( "github.com/siliconbrain/go-seqs/seqs" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" @@ -199,7 +198,7 @@ func TestOtelColConfComplex(t *testing.T) { }, Authentication: &v1alpha1.OutputAuth{ BearerAuth: &v1alpha1.BearerAuthConfig{ - SecretRef: &v1.SecretReference{ + SecretRef: &corev1.SecretReference{ Name: "bearer-test-secret", Namespace: "collector", }, @@ -461,7 +460,7 @@ func TestOtelColConfigInput_generateRoutingConnectorForTenantsSubscription(t *te } } -func TestGenerateNamedPipelines(t *testing.T) { +func TestOtelColConfigInput_generateNamedPipelines(t *testing.T) { tests := []struct { name string cfgInput OtelColConfigInput diff --git a/internal/controller/telemetry/route_controller.go b/internal/controller/telemetry/route_controller.go index 70d0b1f3..ffcdd491 100644 --- a/internal/controller/telemetry/route_controller.go +++ b/internal/controller/telemetry/route_controller.go @@ -336,7 +336,6 @@ func (r *RouteReconciler) getSubscriptionsForTenant(ctx context.Context, tenant func (r *RouteReconciler) getNamespacesForSelectorSlice(ctx context.Context, labelSelectors []metav1.LabelSelector) ([]apiv1.Namespace, error) { var namespaces []apiv1.Namespace for _, ls := range labelSelectors { - selector, err := metav1.LabelSelectorAsSelector(&ls) if err != nil { return nil, err @@ -442,14 +441,11 @@ func (r *RouteReconciler) getBridges(ctx context.Context, listOpts *client.ListO } func (r *RouteReconciler) getBridgesForTenant(ctx context.Context, tenantName string) (bridgesOwned []v1alpha1.Bridge, err error) { - logger := log.FromContext(ctx) - listOpts := &client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(bridgeSourceTenantReferenceField, tenantName), } sourceBridge, err := r.getBridges(ctx, listOpts) if err != nil { - logger.Error(err, "failed to list bridges for tenant") return nil, err } @@ -458,7 +454,6 @@ func (r *RouteReconciler) getBridgesForTenant(ctx context.Context, tenantName st } targetBridge, err := r.getBridges(ctx, listOpts) if err != nil { - logger.Error(err, "failed to list bridges for tenant") return nil, err } @@ -487,7 +482,7 @@ func (r *RouteReconciler) checkBridgeConnections(ctx context.Context, bridge *v1 } sourceTenant, err := r.getTenants(ctx, listOpts) if err != nil { - return errors.Errorf("failed to list tenants for bridge (%s)", bridge.Name) + return err } listOpts = &client.ListOptions{ @@ -495,7 +490,7 @@ func (r *RouteReconciler) checkBridgeConnections(ctx context.Context, bridge *v1 } targetTenant, err := r.getTenants(ctx, listOpts) if err != nil { - return errors.Errorf("failed to list tenants for bridge (%s)", bridge.Name) + return err } // Granular check to ensure that the tenants are correctly assigned to the bridge @@ -504,8 +499,12 @@ func (r *RouteReconciler) checkBridgeConnections(ctx context.Context, bridge *v1 return errors.Errorf("bridge (%s) has invalid tenants", bridge.Name) } - if !(tenants[0].Name == bridge.Spec.SourceTenant && tenants[1].Name == bridge.Spec.TargetTenant) || - (tenants[0].Name == bridge.Spec.TargetTenant && tenants[1].Name == bridge.Spec.SourceTenant) { + connectedTenants := map[string]bool{ + tenants[0].Name: true, + tenants[1].Name: true, + } + + if connectedTenants[bridge.Spec.SourceTenant] && connectedTenants[bridge.Spec.TargetTenant] { return errors.Errorf("bridge (%s) has invalid tenants", bridge.Name) }