diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fac4d58..3a11c84 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,22 +20,20 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Setup Go 1.22 + - name: Setup Go 1.23.2 uses: actions/setup-go@v5 with: - go-version: 1.22 - - - name: Install dependencies - run: | - go install go.opentelemetry.io/collector/cmd/builder@latest - go install github.com/open-telemetry/opentelemetry-collector-contrib/cmd/mdatagen@latest + go-version: 1.23.2 + + - name: Install dependency + run: go install go.opentelemetry.io/collector/cmd/builder@v0.104.0 - name: Get release tag if: github.event_name == 'release' run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Prepare release - run: builder --skip-compilation --config builder-config.yaml + run: builder --skip-compilation --config builder-config.yaml - name: Build Go binary amd64 run: cd castai-collector && go build -ldflags "-s -w -X main.GitCommit=$GITHUB_SHA -X main.GitRef=$GITHUB_REF -X main.Version=${RELEASE_TAG:-commit-$GITHUB_SHA}" -o castai-collector-amd64 @@ -114,4 +112,4 @@ jobs: uses: fossas/fossa-action@v1 with: api-key: ${{ secrets.FOSSA_API_KEY }} - container: us-docker.pkg.dev/castai-hub/library/audit-logs-receiver:${{ env.RELEASE_TAG }} \ No newline at end of file + container: us-docker.pkg.dev/castai-hub/library/audit-logs-receiver:${{ env.RELEASE_TAG }} diff --git a/.gitignore b/.gitignore index fc12c7d..7066210 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ bin *.out # generated componenet test generated_component_test.go +# opentelemetry collector +opentelemetry-collector # Go workspace file go.work.sum diff --git a/Makefile b/Makefile index dc4092f..e87f5a8 100644 --- a/Makefile +++ b/Makefile @@ -2,16 +2,18 @@ GOARCH := $(shell go env GOARCH) .PHONY: setup # Set up required tools (builder, mdatagen) setup: - go install go.opentelemetry.io/collector/cmd/builder@latest - go install github.com/open-telemetry/opentelemetry-collector-contrib/cmd/mdatagen@latest + git clone https://github.com/open-telemetry/opentelemetry-collector.git ./opentelemetry-collector + cd ./opentelemetry-collector && git checkout v0.104.0 + cd ./opentelemetry-collector/cmd/builder && go build -o builder . + cd ./opentelemetry-collector/cmd/mdatagen && go build -o mdatagen . .PHONY: audit-logs-metadata # Generating Audit Logs receiver's metadata audit-logs-metadata: - cd auditlogsreceiver && mdatagen metadata.yaml + cd auditlogsreceiver && ../opentelemetry-collector/cmd/mdatagen/mdatagen metadata.yaml .PHONY: build # Generate and build collector build: audit-logs-metadata - $(BUILD_ARGS) builder --config builder-config.yaml + $(BUILD_ARGS) ./opentelemetry-collector/cmd/builder/builder --config builder-config.yaml .PHONY: run # Run a default collector that outputs everything to console run: diff --git a/README.md b/README.md index bdbda5a..5777a71 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,15 @@ The first step in building a custom Collector is installing required tools, whic make setup ``` -It installs: -- [Open Telemetry Metadata Generator](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/cmd/mdatagen) - - required to generate receiver's definition (metadata about receiver itself); for example, stability level, is this a logs or metrics receiver, etc. Audit Logs Exporter's [metadata is defined here](./auditlogsreceiver/metadata.yaml). -- [Open Telemetry Collector Builder](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder) - - required to generate a code that bootstraps selected components so compilation may produce an executable binary. Builder's [configuration is defined here](./builder-config.yaml) +It clones: +- [Open Telemetry Collector](https://github.com/open-telemetry/opentelemetry-collector) + and builds required tools + - [Open Telemetry Metadata Generator](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/mdatagen) + required to generate receiver's definition (metadata about receiver itself); for example, stability level, is this a logs or metrics receiver, etc. Audit Logs Exporter's [metadata is defined here](./auditlogsreceiver/metadata.yaml) + - [Open Telemetry Collector Builder](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder) - + required to generate a code that bootstraps selected components so compilation may produce an executable binary. Builder's [configuration is defined here](./builder-config.yaml) + +Cloning the repository is required due to open telemetry having replace directives in go.mod file that point to local directories. Collector can be customized (what gets included in a binary artifact) as needed by tailoring `builder-config.yaml`. Refer to OpenTelemetry Collector Contrib Distro's (for example, [the manifest](https://github.com/open-telemetry/opentelemetry-collector-releases/blob/main/distributions/otelcol-contrib/manifest.yaml) for a full list of available components. diff --git a/auditlogsreceiver/go.mod b/auditlogsreceiver/go.mod index e679ba2..e0519b1 100644 --- a/auditlogsreceiver/go.mod +++ b/auditlogsreceiver/go.mod @@ -1,6 +1,6 @@ module github.com/castai/audit-logs-receiver/audit-logs -go 1.22 +go 1.23.2 require ( github.com/go-resty/resty/v2 v2.7.0