Skip to content

Commit

Permalink
refactor: remove otel and reduce binary size
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <[email protected]>
  • Loading branch information
shanduur-akamai committed Dec 12, 2024
1 parent c3fcee2 commit f753f62
Show file tree
Hide file tree
Showing 27 changed files with 113 additions and 893 deletions.
52 changes: 9 additions & 43 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,60 @@
run:
# Timeout for analysis, e.g. 30s, 5m.
timeout: 5m

# Include test files.
tests: true

# List of build tags to pass to all linters.
build-tags:
- integration

issues:
# Set to 0 to not skip any issues.
max-issues-per-linter: 0

# Set to 0 to not skip any issues.
max-same-issues: 0

output:
# Sort results by: filepath, then line, then column.
sort-results: true

# Make issues output unique by line.
uniq-by-line: false

linters:
# Enable specific linter
enable:
# Detect context.Context contained in structs.
- containedctx
# Check whether a function uses a non-inherited context.
- contextcheck
# Find declarations and assignments with too many blank identifiers.
- dogsled
# Check for unchecked errors.
- errcheck
# Find code that will cause problems with the error wrapping scheme.
- errorlint
# Inspects source code for security problems.
- gci
- gosec
# Check that compiler directives are valid.
- gocheckcompilerdirectives
# Calculate cognitive complexities of functions.
- gocognit
# Find repeated strings that could be replaced by a constant.
- goconst
# Provides functionalities missing from other linters.
- gocritic
# Calculates cyclomatic complexity of a function.
- gocyclo
# Check if comments end with a dot.
- godot
# A stricter replacement for gofmt.
- gofumpt
# Simplify the code.
- gosimple
# Check for correctness of programs.
- govet
# Detect ineffectual assignments.
- ineffassign
# Correct commonly misspelled English words in source files.
- misspell
# Magic Number Detector.
- mnd
# Finds the code that returns nil even if it checks that the error is not nil.
- nilerr
# Checks that there is no simultaneous return of nil error and an invalid value.
- nilnil
# Find incorrect usages of t.Parallel().
- paralleltest
# Reports direct reads from proto message fields when getters should be used.
- protogetter
# Drop-in replacement of golint.
- revive
# Ensure consistent code style when using log/slog.
- sloglint
# Find bugs and performance issues statically.
- staticcheck
# Checks Go code for unused constants, variables, functions and types.
- unused
# Empty lines linter.
- wsl

# Setting of specific linters.
linters-settings:
paralleltest:
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.
ignore-missing: false

sloglint:
# Enforce using key-value pairs only (incompatible with attr-only).
kv-only: true
# Enforce a single key naming convention.
key-naming-case: snake

gci:
sections:
- standard
- default
- blank
- dot
- prefix(github.com/linode)
31 changes: 10 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ PLATFORM ?= linux/$(shell go env GOARCH)
CHAINSAW_ARGS ?=

# Versions of COSI dependencies
CRD_VERSION := v0.1.0
CONTROLLER_VERSION := v0.1.2-alpha1
CRD_VERSION := 7ddc93baaa3f08c9c8990a17c7b958955d93c044
CONTROLLER_VERSION := 7ddc93baaa3f08c9c8990a17c7b958955d93c044

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand All @@ -46,7 +46,7 @@ SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

.PHONY: all
all: generate
all: build

.PHONY: clean
clean:
Expand Down Expand Up @@ -78,12 +78,8 @@ help: ## Display this help.

##@ Development

.PHONY: generate
generate: gowrap # Generate code.
go generate ./...

.PHONY: build
build: generate # Build the binary.
build: # Build the binary.
${GO_SETTINGS} go build \
${GOFLAGS} \
-ldflags="${LDFLAGS}" \
Expand All @@ -103,14 +99,14 @@ generate-schemas: helm-values-schema-json ## Run generate schema for Helm Chart
-output=helm/linode-cosi-driver/values.schema.json \

.PHONY: test
test: generate ## Run tests.
test: ## Run tests.
go test \
-race \
-cover -covermode=atomic -coverprofile=coverage.out \
./...

.PHONY: test-integration
test-integration: generate ## Run integration tests.
test-integration: ## Run integration tests.
go test \
-tags=integration \
-race \
Expand Down Expand Up @@ -174,13 +170,13 @@ cluster-reset: kind ctlptl

.PHONY: deploy-deps
deploy-deps: ## Deploy all dependencies of Linode COSI Driver. This step installs CRDs and Controller.
kubectl apply -k github.com/kubernetes-sigs/container-object-storage-interface-api/?ref=${CRD_VERSION}
kubectl apply -k github.com/kubernetes-sigs/container-object-storage-interface-controller/?ref=${CONTROLLER_VERSION}
kubectl apply -k github.com/kubernetes-sigs/container-object-storage-interface/?ref=${CRD_VERSION}
kubectl apply -k github.com/kubernetes-sigs/container-object-storage-interface//controller?ref=${CONTROLLER_VERSION}

.PHONY: undeploy-deps
undeploy-deps: ## Deploy all dependencies of Linode COSI Driver. This step installs CRDs and Controller.
kubectl delete -k github.com/kubernetes-sigs/container-object-storage-interface-controller/?ref=${CONTROLLER_VERSION}
kubectl delete -k github.com/kubernetes-sigs/container-object-storage-interface-api/?ref=${CRD_VERSION}
kubectl delete -k github.com/kubernetes-sigs/container-object-storage-interface/?ref=${CONTROLLER_VERSION}
kubectl delete -k github.com/kubernetes-sigs/container-object-storage-interface//controller?ref=${CRD_VERSION}

.PHONY: deploy
deploy: helm ## Deploy driver to the K8s cluster specified in ~/.kube/config.
Expand All @@ -202,7 +198,6 @@ KUBECTL ?= kubectl
CHAINSAW ?= $(LOCALBIN)/chainsaw
CTLPTL ?= $(LOCALBIN)/ctlptl
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GOWRAP ?= $(LOCALBIN)/gowrap
HELM ?= $(LOCALBIN)/helm
HELM_DOCS ?= $(LOCALBIN)/helm-docs
HELM_VALUES_SCHEMA_JSON ?= $(LOCALBIN)/helm-values-schema-json
Expand All @@ -213,7 +208,6 @@ KUBE_LINTER ?= $(LOCALBIN)/kube-linter
CHAINSAW_VERSION ?= $(shell grep 'github.com/kyverno/chainsaw ' ./go.mod | cut -d ' ' -f 2)
CTLPTL_VERSION ?= $(shell grep 'github.com/tilt-dev/ctlptl ' ./go.mod | cut -d ' ' -f 2)
GOLANGCI_LINT_VERSION ?= $(shell grep 'github.com/golangci/golangci-lint ' ./go.mod | cut -d ' ' -f 2)
GOWRAP_VERSION ?= $(shell grep 'github.com/hexdigest/gowrap ' ./go.mod | cut -d ' ' -f 2)
HELM_VERSION ?= $(shell grep 'helm.sh/helm/v3 ' ./go.mod | cut -d ' ' -f 2)
HELM_DOCS_VERSION ?= $(shell grep 'github.com/norwoodj/helm-docs ' ./go.mod | cut -d ' ' -f 2)
HELM_VALUES_SCHEMA_JSON_VERSION ?= $(shell grep 'github.com/losisin/helm-values-schema-json ' ./go.mod | cut -d ' ' -f 2)
Expand All @@ -235,11 +229,6 @@ golangci-lint: $(GOLANGCI_LINT)$(GOLANGCI_LINT_VERSION) ## Download golangci-lin
$(GOLANGCI_LINT)$(GOLANGCI_LINT_VERSION): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

.PHONY: gowrap
gowrap: $(GOWRAP)$(GOWRAP_VERSION) ## Download gowrap locally if necessary.
$(GOWRAP)$(GOWRAP_VERSION): $(LOCALBIN)
$(call go-install-tool,$(GOWRAP),github.com/hexdigest/gowrap/cmd/gowrap,$(GOWRAP_VERSION))

.PHONY: helm
helm: $(HELM)$(HELM_VERSION) ## Download helm locally if necessary.
$(HELM)$(HELM_VERSION): $(LOCALBIN)
Expand Down
Loading

0 comments on commit f753f62

Please sign in to comment.