Skip to content

Commit 2e752ab

Browse files
authored
Merge branch 'main' into fix/2589-watch-single-namespace
2 parents 1aee7c4 + 52ad5cc commit 2e752ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1377
-719
lines changed

.github/workflows/continuous-integration.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ jobs:
2323
with:
2424
go-version: "~1.21.1"
2525

26+
- name: Cache tools
27+
uses: actions/cache@v4
28+
with:
29+
path: bin
30+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}
31+
32+
- name: Install tools
33+
run: make install-tools
34+
2635
- name: "basic checks"
2736
run: make ci
2837

@@ -38,6 +47,15 @@ jobs:
3847
with:
3948
go-version: "~1.21.1"
4049

50+
- name: Cache tools
51+
uses: actions/cache@v4
52+
with:
53+
path: bin
54+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}
55+
56+
- name: Install tools
57+
run: make install-tools
58+
4159
- uses: actions/cache@v4
4260
with:
4361
path: |
@@ -58,6 +76,11 @@ jobs:
5876
- name: Check out code into the Go module directory
5977
uses: actions/checkout@v4
6078

79+
- name: Set up Go
80+
uses: actions/setup-go@v5
81+
with:
82+
go-version: "~1.21.1"
83+
6184
- name: Initialize CodeQL
6285
uses: github/codeql-action/init@v3
6386
with:

.github/workflows/e2e.yaml

+7-6
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ jobs:
4747
with:
4848
go-version: "~1.21.3"
4949

50-
- name: Setup kind
51-
env:
52-
KIND_VERSION: "0.20.0"
53-
run: go install sigs.k8s.io/kind@v${KIND_VERSION}
50+
- name: Cache tools
51+
uses: actions/cache@v4
52+
with:
53+
path: bin
54+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}
5455

55-
- name: "install kuttl"
56-
run: ./hack/install-kuttl.sh
56+
- name: Install tools
57+
run: make install-tools
5758

5859
- name: "run tests"
5960
env:

.github/workflows/scorecard.yaml

+9-8
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,22 @@ jobs:
2727
with:
2828
go-version: "~1.21.1"
2929

30-
- name: Setup kind
31-
env:
32-
KIND_VERSION: "0.20.0"
33-
run: go install sigs.k8s.io/kind@v${KIND_VERSION}
34-
3530
- name: Check out code into the Go module directory
3631
uses: actions/checkout@v4
3732

38-
- name: "install kuttl and kind"
39-
run: ./hack/install-kuttl.sh
33+
- name: Cache tools
34+
uses: actions/cache@v4
35+
with:
36+
path: bin
37+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}
38+
39+
- name: Install tools
40+
run: make install-tools
4041

4142
- name: "start kind"
4243
env:
4344
KUBE_VERSION: ${{ matrix.kube-version }}
44-
run: kind create cluster --config kind-$KUBE_VERSION.yaml
45+
run: make start-kind
4546

4647
- name: "wait until cluster is ready"
4748
run: kubectl wait --timeout=5m --for=condition=available deployment/coredns -n kube-system

Makefile

+26-45
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ manager: generate fmt vet
110110

111111
# Build target allocator binary
112112
targetallocator:
113-
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) go build -a -installsuffix cgo -o cmd/otel-allocator/bin/targetallocator_${ARCH} -ldflags "${COMMON_LDFLAGS}" ./cmd/otel-allocator
113+
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) go build -o cmd/otel-allocator/bin/targetallocator_${ARCH} -ldflags "${COMMON_LDFLAGS}" ./cmd/otel-allocator
114114

115115
# Build opamp bridge binary
116116
operator-opamp-bridge:
117-
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) go build -a -installsuffix cgo -o cmd/operator-opamp-bridge/bin/opampbridge_${ARCH} -ldflags "${COMMON_LDFLAGS}" ./cmd/operator-opamp-bridge
117+
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) go build -o cmd/operator-opamp-bridge/bin/opampbridge_${ARCH} -ldflags "${COMMON_LDFLAGS}" ./cmd/operator-opamp-bridge
118118

119119
# Run against the configured Kubernetes cluster in ~/.kube/config
120120
.PHONY: run
@@ -288,9 +288,9 @@ container-operator-opamp-bridge: operator-opamp-bridge
288288
docker build -t ${OPERATOROPAMPBRIDGE_IMG} cmd/operator-opamp-bridge
289289

290290
.PHONY: start-kind
291-
start-kind:
291+
start-kind: kind
292292
ifeq (true,$(START_KIND_CLUSTER))
293-
kind create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG) || true
293+
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG) || true
294294
endif
295295

296296
.PHONY: install-metrics-server
@@ -310,26 +310,26 @@ install-targetallocator-prometheus-crds:
310310
load-image-all: load-image-operator load-image-target-allocator load-image-operator-opamp-bridge
311311

312312
.PHONY: load-image-operator
313-
load-image-operator: container
313+
load-image-operator: container kind
314314
ifeq (true,$(START_KIND_CLUSTER))
315-
kind load --name $(KIND_CLUSTER_NAME) docker-image $(IMG)
315+
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image $(IMG)
316316
else
317317
$(MAKE) container-push
318318
endif
319319

320320

321321
.PHONY: load-image-target-allocator
322-
load-image-target-allocator: container-target-allocator
322+
load-image-target-allocator: container-target-allocator kind
323323
ifeq (true,$(START_KIND_CLUSTER))
324-
kind load --name $(KIND_CLUSTER_NAME) docker-image $(TARGETALLOCATOR_IMG)
324+
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image $(TARGETALLOCATOR_IMG)
325325
else
326326
$(MAKE) container-target-allocator-push
327327
endif
328328

329329

330330
.PHONY: load-image-operator-opamp-bridge
331-
load-image-operator-opamp-bridge: container-operator-opamp-bridge
332-
kind load --name $(KIND_CLUSTER_NAME) docker-image ${OPERATOROPAMPBRIDGE_IMG}
331+
load-image-operator-opamp-bridge: container-operator-opamp-bridge kind
332+
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image ${OPERATOROPAMPBRIDGE_IMG}
333333

334334
.PHONY: cert-manager
335335
cert-manager: cmctl
@@ -355,6 +355,8 @@ cmctl:
355355
}
356356

357357
KUSTOMIZE ?= $(LOCALBIN)/kustomize
358+
KIND ?= $(LOCALBIN)/kind
359+
KUTTL ?= $(LOCALBIN)/kubectl-kuttl
358360
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
359361
ENVTEST ?= $(LOCALBIN)/setup-envtest
360362
CHLOGGEN ?= $(LOCALBIN)/chloggen
@@ -363,24 +365,33 @@ GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
363365
KUSTOMIZE_VERSION ?= v5.0.3
364366
CONTROLLER_TOOLS_VERSION ?= v0.12.0
365367
GOLANGCI_LINT_VERSION ?= v1.54.0
368+
KIND_VERSION ?= v0.20.0
369+
KUTTL_VERSION ?= 0.15.0
366370

371+
.PHONY: install-tools
372+
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kuttl kind operator-sdk
367373

368374
.PHONY: kustomize
369375
kustomize: ## Download kustomize locally if necessary.
370376
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION))
371377

378+
.PHONY: golangci-lint
372379
golangci-lint: ## Download golangci-lint locally if necessary.
373380
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
374381

382+
.PHONY: kind
383+
kind: ## Download kind locally if necessary.
384+
$(call go-get-tool,$(KIND),sigs.k8s.io/kind,$(KIND_VERSION))
385+
375386
.PHONY: controller-gen
376387
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
377388
$(CONTROLLER_GEN): $(LOCALBIN)
378-
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
389+
@test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
379390

380391
.PHONY: envtest
381392
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
382393
$(ENVTEST): $(LOCALBIN)
383-
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
394+
@test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
384395

385396
CRDOC = $(shell pwd)/bin/crdoc
386397
.PHONY: crdoc
@@ -403,42 +414,12 @@ rm -rf $$TMP_DIR ;\
403414
endef
404415

405416
.PHONY: kuttl
406-
kuttl:
407-
ifeq (, $(shell which kubectl-kuttl))
408-
echo ${PATH}
409-
ls -l /usr/local/bin
410-
which kubectl-kuttl
411-
412-
@{ \
413-
set -e ;\
414-
echo "" ;\
415-
echo "ERROR: kuttl not found." ;\
416-
echo "Please check https://kuttl.dev/docs/cli.html for installation instructions and try again." ;\
417-
echo "" ;\
418-
exit 1 ;\
419-
}
420-
else
421-
KUTTL=$(shell which kubectl-kuttl)
422-
endif
423-
424-
.PHONY: kind
425-
kind:
426-
ifeq (, $(shell which kind))
427-
@{ \
428-
set -e ;\
429-
echo "" ;\
430-
echo "ERROR: kind not found." ;\
431-
echo "Please check https://kind.sigs.k8s.io/docs/user/quick-start/#installation for installation instructions and try again." ;\
432-
echo "" ;\
433-
exit 1 ;\
434-
}
435-
else
436-
KIND=$(shell which kind)
437-
endif
417+
kuttl: $(LOCALBIN)
418+
@KUTTL=$(KUTTL) KUTTL_VERSION=$(KUTTL_VERSION) ./hack/install-kuttl.sh
438419

439420
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk
440421
.PHONY: operator-sdk
441-
operator-sdk:
422+
operator-sdk: $(LOCALBIN)
442423
@{ \
443424
set -e ;\
444425
if (`pwd`/bin/operator-sdk version | grep ${OPERATOR_SDK_VERSION}) > /dev/null 2>&1 ; then \

apis/v1alpha2/config.go

+14
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
package v1alpha2
1616

1717
import (
18+
"bytes"
1819
"encoding/json"
1920
"fmt"
2021
"reflect"
2122
"sort"
23+
24+
"gopkg.in/yaml.v3"
2225
)
2326

2427
// AnyConfig represent parts of the config.
@@ -84,6 +87,17 @@ type Config struct {
8487
Service Service `json:"service" yaml:"service"`
8588
}
8689

90+
// Yaml encodes the current object and returns it as a string.
91+
func (c Config) Yaml() (string, error) {
92+
var buf bytes.Buffer
93+
yamlEncoder := yaml.NewEncoder(&buf)
94+
yamlEncoder.SetIndent(2)
95+
if err := yamlEncoder.Encode(&c); err != nil {
96+
return "", err
97+
}
98+
return buf.String(), nil
99+
}
100+
87101
type Service struct {
88102
Extensions *[]string `json:"extensions,omitempty" yaml:"extensions,omitempty"`
89103
// +kubebuilder:pruning:PreserveUnknownFields

apis/v1alpha2/config_test.go

+74
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,77 @@ func TestNullObjects_go_yaml(t *testing.T) {
110110
nullObjects := cfg.nullObjects()
111111
assert.Equal(t, []string{"connectors.spanmetrics:", "exporters.otlp.endpoint:", "extensions.health_check:", "processors.batch:", "receivers.otlp.protocols.grpc:", "receivers.otlp.protocols.http:"}, nullObjects)
112112
}
113+
114+
func TestConfigYaml(t *testing.T) {
115+
cfg := &Config{
116+
Receivers: AnyConfig{
117+
Object: map[string]interface{}{
118+
"otlp": nil,
119+
},
120+
},
121+
Processors: &AnyConfig{
122+
Object: map[string]interface{}{
123+
"modify_2000": "enabled",
124+
},
125+
},
126+
Exporters: AnyConfig{
127+
Object: map[string]interface{}{
128+
"otlp/exporter": nil,
129+
},
130+
},
131+
Connectors: &AnyConfig{
132+
Object: map[string]interface{}{
133+
"con": "magic",
134+
},
135+
},
136+
Extensions: &AnyConfig{
137+
Object: map[string]interface{}{
138+
"addon": "option1",
139+
},
140+
},
141+
Service: Service{
142+
Extensions: &[]string{"addon"},
143+
Telemetry: &AnyConfig{
144+
Object: map[string]interface{}{
145+
"insights": "yeah!",
146+
},
147+
},
148+
Pipelines: AnyConfig{
149+
Object: map[string]interface{}{
150+
"receivers": []string{"otlp"},
151+
"processors": []string{"modify_2000"},
152+
"exporters": []string{"otlp/exporter", "con"},
153+
},
154+
},
155+
},
156+
}
157+
yamlCollector, err := cfg.Yaml()
158+
require.NoError(t, err)
159+
160+
const expected = `receivers:
161+
otlp: null
162+
exporters:
163+
otlp/exporter: null
164+
processors:
165+
modify_2000: enabled
166+
connectors:
167+
con: magic
168+
extensions:
169+
addon: option1
170+
service:
171+
extensions:
172+
- addon
173+
telemetry:
174+
insights: yeah!
175+
pipelines:
176+
exporters:
177+
- otlp/exporter
178+
- con
179+
processors:
180+
- modify_2000
181+
receivers:
182+
- otlp
183+
`
184+
185+
assert.Equal(t, expected, yamlCollector)
186+
}

autoinstrumentation/java/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0
1+
1.32.1

0 commit comments

Comments
 (0)