-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: Id50c8ba3443ac2808f7a672799afc4c55eafbd32
- Loading branch information
1 parent
bb3d1d4
commit 6e5c9ec
Showing
306 changed files
with
18,733 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang:1.20 as builder | ||
WORKDIR /sidecar | ||
COPY . . | ||
|
||
RUN apt-get update && apt-get install gettext-base | ||
RUN go install github.com/client9/misspell/cmd/[email protected] \ | ||
&& go install github.com/golangci/golangci-lint/cmd/[email protected] \ | ||
&& go install github.com/google/[email protected] | ||
RUN apt update && apt install -y make | ||
RUN make build-collector | ||
|
||
FROM alpine:3 | ||
RUN apk add --no-cache ca-certificates | ||
COPY --from=builder /sidecar/bin/rungmpcol /rungmpcol | ||
COPY collector-config.yaml /etc/rungmp/config.yaml | ||
|
||
ENTRYPOINT ["/rungmpcol"] | ||
CMD ["--config", "/etc/rungmp/config.yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# read PKG_VERSION from VERSION file | ||
include VERSION | ||
|
||
# if GOOS is not supplied, set default value based on user's system, will be overridden for OS specific packaging commands | ||
GOOS ?= $(shell go env GOOS) | ||
|
||
ALL_SRC := $(shell find . -name '*.go' -type f | sort) | ||
ALL_DOC := $(shell find . \( -name "*.md" -o -name "*.yaml" \) -type f | sort) | ||
GIT_SHA := $(shell git rev-parse --short HEAD) | ||
|
||
BUILD_INFO_IMPORT_PATH := collector/internal/version | ||
BUILD_X1 := -X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA) | ||
BUILD_X2 := -X $(BUILD_INFO_IMPORT_PATH).Version=$(PKG_VERSION) | ||
LD_FLAGS := -ldflags "${BUILD_X1} ${BUILD_X2}" | ||
|
||
TOOLS_DIR := internal/tools | ||
|
||
.EXPORT_ALL_VARIABLES: | ||
|
||
.DEFAULT_GOAL := presubmit | ||
|
||
# -------------------------- | ||
# Helper Commands | ||
# -------------------------- | ||
|
||
.PHONY: update-components-old | ||
update-components-old: | ||
grep -o github.com/open-telemetry/opentelemetry-collector-contrib/[[:lower:]]*/[[:lower:]]* go.mod | xargs -I '{}' go get {} | ||
go mod tidy | ||
cd $(TOOLS_DIR) && go get -u github.com/open-telemetry/opentelemetry-collector-contrib/cmd/mdatagen | ||
cd $(TOOLS_DIR) && go mod tidy | ||
|
||
OTEL_VER ?= latest | ||
.PHONY: update-components | ||
update-components: | ||
go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all | \ | ||
grep "^go.opentelemetry.io" | \ | ||
grep -v "go.opentelemetry.io/collector/featuregate" | \ | ||
grep -v "go.opentelemetry.io/collector/pdata" | \ | ||
xargs -t -I '{}' go get {}@$(OTEL_VER) | ||
go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all | \ | ||
grep "^github.com/open-telemetry/opentelemetry-collector-contrib" | \ | ||
xargs -t -I '{}' go get {}@$(OTEL_VER) | ||
go mod tidy | ||
cd $(TOOLS_DIR) && go get -u github.com/open-telemetry/opentelemetry-collector-contrib/cmd/mdatagen@$(OTEL_VER) | ||
cd $(TOOLS_DIR) && go mod tidy | ||
|
||
# We can bring this target back when https://github.com/open-telemetry/opentelemetry-collector/issues/8063 is resolved. | ||
update-opentelemetry: | ||
$(MAKE) update-components | ||
$(MAKE) install-tools | ||
$(MAKE) GO_BUILD_TAGS=gpu generate | ||
|
||
# -------------------------- | ||
# Tools | ||
# -------------------------- | ||
|
||
.PHONY: install-tools | ||
install-tools: | ||
cd $(TOOLS_DIR) && \ | ||
go install \ | ||
github.com/client9/misspell/cmd/misspell \ | ||
github.com/golangci/golangci-lint/cmd/golangci-lint \ | ||
github.com/google/addlicense \ | ||
github.com/open-telemetry/opentelemetry-collector-contrib/cmd/mdatagen | ||
|
||
.PHONY: addlicense | ||
addlicense: | ||
addlicense -c "Google LLC" -l apache $(ALL_SRC) | ||
|
||
.PHONY: checklicense | ||
checklicense: | ||
@output=`addlicense -check $(ALL_SRC)` && echo checklicense finished successfully || (echo checklicense errors: $$output && exit 1) | ||
|
||
.PHONY: lint | ||
lint: | ||
golangci-lint run --allow-parallel-runners --build-tags=$(GO_BUILD_TAGS) --timeout=20m | ||
|
||
.PHONY: misspell | ||
misspell: | ||
@output=`misspell -error $(ALL_DOC)` && echo misspell finished successfully || (echo misspell errors:\\n$$output && exit 1) | ||
|
||
# -------------------------- | ||
# CI | ||
# -------------------------- | ||
|
||
# Adds license headers to files that are missing it, quiet tests | ||
# so full output is visible at a glance. | ||
.PHONY: precommit | ||
precommit: addlicense lint misspell test | ||
|
||
# Checks for the presence of required license headers, runs verbose | ||
# tests for complete information in CI job. | ||
.PHONY: presubmit | ||
presubmit: checklicense lint misspell test_verbose | ||
|
||
# -------------------------- | ||
# Build and Test | ||
# -------------------------- | ||
|
||
GO_BUILD_OUT ?= ./bin/rungmpcol | ||
.PHONY: build-collector | ||
build-collector: | ||
CGO_ENABLED=0 go build -tags=$(GO_BUILD_TAGS) -o $(GO_BUILD_OUT) $(LD_FLAGS) -buildvcs=false ./collector/cmd/rungmpcol | ||
|
||
OTELCOL_BINARY = google-cloud-run-rmp-sidecar-$(GOOS) | ||
.PHONY: build-collector-full-name | ||
build-collector-full-name: | ||
$(MAKE) GO_BUILD_OUT=./bin/$(OTELCOL_BINARY) build-collector | ||
|
||
.PHONY: test | ||
test: | ||
go test -tags=$(GO_BUILD_TAGS) $(GO_TEST_VERBOSE) -race ./... | ||
|
||
.PHONY: test_quiet | ||
test_verbose: | ||
$(MAKE) GO_TEST_VERBOSE=-v test | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
# -------------------- | ||
# Docker | ||
# -------------------- | ||
|
||
# set default docker build image name | ||
BUILD_IMAGE_NAME ?= rungmpcol-build | ||
BUILD_IMAGE_REPO ?= gcr.io/stackdriver-test-143416/opentelemetry-operations-collector:test | ||
|
||
.PHONY: docker-build-image | ||
docker-build-image: | ||
docker build -t $(BUILD_IMAGE_NAME) . | ||
|
||
.PHONY: docker-push-image | ||
docker-push-image: | ||
docker tag $(BUILD_IMAGE_NAME) $(BUILD_IMAGE_REPO) | ||
docker push $(BUILD_IMAGE_REPO) | ||
|
||
.PHONY: docker-build-and-push | ||
docker-build-and-push: docker-build-image docker-push-image | ||
|
||
# Usage: make TARGET=<target> docker-run | ||
# Example: make TARGET=build-collector docker-run | ||
TARGET ?= build_collector | ||
.PHONY: docker-run | ||
docker-run: | ||
docker run -e PKG_VERSION -v $(CURDIR):/mnt -w /mnt $(BUILD_IMAGE_NAME) /bin/bash -c "make $(TARGET)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# The release version and build number of the google-cloud-metrics-agent package. | ||
PKG_VERSION=0.0.2 | ||
PKG_BUILD=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# See golang.org/issue/9281 | ||
* -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
bin/ | ||
dist/ | ||
|
||
## Editors | ||
|
||
# GoLand IDEA | ||
/.idea/ | ||
*.iml | ||
|
||
# VS Code | ||
.vscode | ||
|
||
# Emacs | ||
*~ | ||
\#*\# | ||
|
||
# Miscellaneous files | ||
*.sw[op] | ||
*.DS_Store | ||
|
||
# Coverage | ||
coverage.txt | ||
coverage.html | ||
|
||
# Wix | ||
*.wixobj | ||
*.wixpdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
run: | ||
timeout: 5m | ||
|
||
skip-dirs: | ||
- receiver/prometheusreceiver | ||
|
||
linters: | ||
enable: | ||
- gocritic | ||
- gofmt | ||
- goimports | ||
- revive | ||
- govet | ||
- misspell | ||
- exportloopref | ||
- staticcheck | ||
- unconvert | ||
|
||
issues: | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- exportloopref | ||
|
||
linters-settings: | ||
gofmt: | ||
# simplify code: gofmt with `-s` option, true by default | ||
simplify: true | ||
goimports: | ||
# put imports beginning with prefix after 3rd-party packages; | ||
# it's a comma-separated list of prefixes | ||
local-prefixes: github.com/GoogleCloudPlatform/opentelemetry-operations-collector | ||
govet: | ||
# report about shadowed variables | ||
check-shadowing: true | ||
# settings per analyzer | ||
settings: | ||
printf: # analyzer name, run `go tool vet help` to see all analyzers | ||
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf | ||
disable: | ||
- fieldalignment | ||
enable-all: true | ||
misspell: | ||
locale: US |
Oops, something went wrong.