Skip to content

Cleaned up Go code directory structure #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ agent.exe
agent.exe~
.DS_Store
ocb-build/
go.sum
go.work.sum
observecol/go.sum
components/processors/observek8sattributesprocessor/go.sum

#integration
*.pem
Expand Down
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ builds:
goos:
- linux
- darwin
ldflags: -s -w -X observe-agent/build.Version={{.Version}}
ldflags: -s -w -X github.com/observeinc/observe-agent/build.Version={{.Version}}

- id: windows_build
binary: observe-agent
Expand All @@ -34,7 +34,7 @@ builds:
goarch:
- amd64
- '386'
ldflags: -s -w -X observe-agent/build.Version={{.Version}}
ldflags: -s -w -X github.com/observeinc/observe-agent/build.Version={{.Version}}

archives:
- id: default
Expand Down
45 changes: 33 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
## go-test: Runs Go tests across all packages
go-test:
go work vendor
# Uncomment to use OTEL Collector Builder installed by `install-ocb`
OCB=$(HOME)/bin/ocb

# Uncomment to use OTEL Collector Builder installed by
# `go install go.opentelemetry.io/collector/cmd/[email protected]`
#OCB=builder

all: go-test

## vendor: Vendors Go modules
vendor:
go mod tidy && go work vendor
cd observecol && go mod tidy && go work vendor
cd components/processors/observek8sattributesprocessor && go mod tidy && go work vendor
go mod tidy && go work vendor

## build: Build all Go packages
build:
go build ./...

## test: Runs Go tests across all packages
go-test: build
go list -f '{{.Dir}}' -m | xargs go test -v ./...

## release: Releases current tag through goreleaser
Expand All @@ -15,15 +33,18 @@ install-ocb:

## build-ocb: Builds project using ocb
build-ocb:
$(HOME)/bin/ocb --skip-compilation --config=builder-config.yaml
sed -i -e 's/package main/package observeotel/g' ocb-build/components.go
sed -i -e 's/\/Users\/.*observe-agent\//..\/..\//g' ocb-build/go.mod
cp ./ocb-build/components.go ./cmd/collector/components.go
cp ./ocb-build/go.mod ./cmd/collector/go.mod
cp ./ocb-build/go.sum ./cmd/collector/go.sum
go mod tidy && go work vendor
cd ./cmd/collector && go mod tidy && go work vendor
$(OCB) --skip-compilation --config=builder-config.yaml
sed -i -e 's/package main/package observecol/g' ocb-build/components.go
sed -i -e 's/\/Users\/.*observe-agent\//..\//g' ocb-build/go.mod
sed -i -e 's/\/home\/.*observe-agent\//..\//g' ocb-build/go.mod
sed -i -e 's/observek8sattributesprocessor v0.0.0-00010101000000-000000000000 =>/observek8sattributesprocessor =>/g' ocb-build/go.mod
cp ./ocb-build/components.go ./observecol/components.go
cp ./ocb-build/go.mod ./observecol/go.mod
cp ./ocb-build/go.sum ./observecol/go.sum
go mod tidy && go work vendor
cd ./observecol && go mod tidy && go work vendor

install-tools:
cd ./internal/tools && go install go.opentelemetry.io/collector/cmd/mdatagen


.PHONY: all vendor build go-test release install-ocb build-ocb install-tools
11 changes: 5 additions & 6 deletions builder-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dist:
name: observeotel
module: observe/otelcol
name: observecol
module: github.com/observeinc/observe-agent/observecol
description: Observe Distribution of OTEL Collector
output_path: ./ocb-build
otelcol_version: 0.110.0
Expand Down Expand Up @@ -61,7 +61,6 @@ connectors:
- gomod: go.opentelemetry.io/collector/connector/forwardconnector v0.110.0

- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.110.0
# replaces:
# - k8s.io/api => k8s.io/api v0.29.3
# - k8s.io/apimachinery => k8s.io/apimachinery v0.29.3
# - k8s.io/client-go => k8s.io/client-go v0.29.3

replaces:
- github.com/observeinc/observe-agent => ../
1,495 changes: 0 additions & 1,495 deletions cmd/collector/go.sum

This file was deleted.

11 changes: 4 additions & 7 deletions components/processors/observek8sattributesprocessor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@ require (
github.com/jmespath/go-jmespath v0.4.0
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.110.0
go.opentelemetry.io/collector/confmap v0.107.0
go.opentelemetry.io/collector/confmap v1.17.0
go.opentelemetry.io/collector/consumer v0.110.0
go.opentelemetry.io/collector/consumer/consumertest v0.110.0
go.opentelemetry.io/collector/pdata v1.16.0
go.opentelemetry.io/collector/processor v0.110.0
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.27.0
k8s.io/api v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/api v0.31.0
k8s.io/apimachinery v0.31.0
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0 // indirect
github.com/go-viper/mapstructure/v2 v2.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
Expand All @@ -40,8 +39,6 @@ require (
go.opentelemetry.io/collector/component/componentstatus v0.110.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.110.0 // indirect
go.opentelemetry.io/collector/consumer/consumerprofiles v0.110.0 // indirect
go.opentelemetry.io/collector/featuregate v1.13.0 // indirect
go.opentelemetry.io/collector/internal/globalgates v0.107.0 // indirect
go.opentelemetry.io/collector/internal/globalsignal v0.110.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.110.0 // indirect
go.opentelemetry.io/collector/pdata/testdata v0.110.0 // indirect
Expand Down
Loading
Loading