Skip to content

Commit

Permalink
chore: tidy up
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <bence.csati@axoflow.com>
  • Loading branch information
csatib02 committed Oct 25, 2024
1 parent ed5852e commit c47814e
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 138 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Binaries for programs and plugins
*.exe
*.exe~
Expand Down
66 changes: 33 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -99,6 +103,34 @@ 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: 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

##@ Build

.PHONY: build
Expand Down Expand Up @@ -207,38 +239,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

Expand Down
9 changes: 7 additions & 2 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,7 +27,6 @@ resources:
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: kube-logging.dev
group: telemetry
kind: Tenant
Expand All @@ -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"
6 changes: 0 additions & 6 deletions api/telemetry/v1alpha1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 4 additions & 2 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion config/samples/telemetry_v1alpha1_bridge.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions config/samples/telemetry_v1alpha1_collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ metadata:
app.kubernetes.io/created-by: telemetry-controller
name: collector-sample
spec:
controlNamespace: collector
tenantSelector:
matchLabels:
tenant: tenantA
3 changes: 3 additions & 0 deletions config/samples/telemetry_v1alpha1_tenant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ spec:
subscriptionNamespaceSelector:
matchLabels:
nsTenant: tenantA
logSourceNamespaceSelector:
matchLabels:
nsTenant: tenantA
2 changes: 2 additions & 0 deletions e2e/e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ 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

Expand Down
92 changes: 39 additions & 53 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Loading

0 comments on commit c47814e

Please sign in to comment.