From 713eb5fa29a07b4b28b436c2291b7e2513a2c571 Mon Sep 17 00:00:00 2001 From: mattdurham Date: Fri, 4 Jun 2021 09:47:14 -0400 Subject: [PATCH 001/101] Initial drone support --- .drone/drone.yml | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .drone/drone.yml diff --git a/.drone/drone.yml b/.drone/drone.yml new file mode 100644 index 000000000000..53a25a394912 --- /dev/null +++ b/.drone/drone.yml @@ -0,0 +1,64 @@ +--- +kind: pipeline +name: Test +platform: + os: linux + arch: amd64 + +steps: +- name: lint + image: golangci/golangci-lint:v1.37.1 + # libsystemd-dev is required for cgo + commands: + - apt-get update -y && apt-get install -y libsystemd-dev + - make lint + +- name: test-ubuntu + image: golang:1.16 + commands: + - apt-get update -y && apt-get install -y libsystemd-dev + - make cmd/agent/agent cmd/agentctl/agentctl + - make test + - RELEASE_TAG=v0.0.0 make test-packages +--- +kind: pipeline +type: docker +name: Containerize +platform: + os: linux + arch: amd64 + +steps: +- name: Build Agent Container + image: docker + volumes: + - name: docker + path: /var/run/docker.sock + commands: + - apk update && apk add make bash wget git qemu + - wget https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 + - mkdir -p ~/.docker/cli-plugins + - cp buildx-v0.5.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx + - chmod a+x ~/.docker/cli-plugins/docker-buildx + - docker buildx create --use + - CROSS_BUILD=true RELEASE_BUILD=true make agent-image + +steps: +- name: Build Agentctl Container + image: docker + volumes: + - name: docker + path: /var/run/docker.sock + commands: + - apk update && apk add make bash wget git qemu + - wget https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 + - mkdir -p ~/.docker/cli-plugins + - cp buildx-v0.5.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx + - chmod a+x ~/.docker/cli-plugins/docker-buildx + - docker buildx create --use + - CROSS_BUILD=true RELEASE_BUILD=true make agentctl-image + +volumes: +- name: docker + host: + path: /var/run/docker.sock From b0c03bda44afdf48e705a72e6853b4d3315d7b63 Mon Sep 17 00:00:00 2001 From: mattdurham Date: Fri, 4 Jun 2021 10:00:18 -0400 Subject: [PATCH 002/101] Fix drone file --- .drone/drone.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 53a25a394912..e996b3bd0c5b 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -42,8 +42,6 @@ steps: - chmod a+x ~/.docker/cli-plugins/docker-buildx - docker buildx create --use - CROSS_BUILD=true RELEASE_BUILD=true make agent-image - -steps: - name: Build Agentctl Container image: docker volumes: @@ -57,7 +55,7 @@ steps: - chmod a+x ~/.docker/cli-plugins/docker-buildx - docker buildx create --use - CROSS_BUILD=true RELEASE_BUILD=true make agentctl-image - + volumes: - name: docker host: From 4f7831bac4bdde9e44e96920e7ad3c19eeab39eb Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 10:26:53 -0400 Subject: [PATCH 003/101] Drone changes --- .drone/drone.yml | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index e996b3bd0c5b..842fab098f83 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -13,13 +13,43 @@ steps: - apt-get update -y && apt-get install -y libsystemd-dev - make lint +# - name: test +# image: ubuntu +# volumes: +# - name: docker +# path: /var/run/docker.sock +# commands: +# - apt-get update && apt-get install -y libsystemd-dev +# - mkdir -p /usr/local/go/bin +# - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz +# - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz +# - export PATH=$PATH:/usr/local/go/bin +# - make cmd/agent/agent cmd/agentctl/agentctl +# - make test +# - RELEASE_TAG=v0.0.0 make test-packages + + - name: test-ubuntu - image: golang:1.16 + image: ubuntu commands: - - apt-get update -y && apt-get install -y libsystemd-dev + - export DEBIAN_FRONTEND=noninteractive + - apt-get update -y && apt-get install -y libsystemd-dev apt-transport-https ca-certificates curl gnupg lsb-release wget make build-essential + - mkdir -p /usr/local/go/bin + - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz + - export PATH=$PATH:/usr/local/go/bin + - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + - echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null + - apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io - make cmd/agent/agent cmd/agentctl/agentctl - make test - RELEASE_TAG=v0.0.0 make test-packages + +volumes: +- name: docker + host: + path: /var/run/docker.sock + --- kind: pipeline type: docker From d57c0d987facb7abda85c6ea8f33a4f1ff17d4c0 Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 10:44:58 -0400 Subject: [PATCH 004/101] Added support for drone building --- .drone/drone.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.drone/drone.yml b/.drone/drone.yml index 842fab098f83..afd02fb1eb0b 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -31,6 +31,9 @@ steps: - name: test-ubuntu image: ubuntu + volumes: + - name: docker + path: /var/run/docker.sock commands: - export DEBIAN_FRONTEND=noninteractive - apt-get update -y && apt-get install -y libsystemd-dev apt-transport-https ca-certificates curl gnupg lsb-release wget make build-essential From 5e4d08ea662821963c68fc063aa866419e2e18bc Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 12:03:08 -0400 Subject: [PATCH 005/101] Echo from makefile --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 1a2a3503d2f1..8cab3547f15d 100644 --- a/Makefile +++ b/Makefile @@ -123,6 +123,7 @@ cmd/agent/agent: check-seego cmd/agent/main.go ifeq ($(CROSS_BUILD),false) CGO_ENABLED=1 go build $(CGO_FLAGS) -o $@ ./$(@D) else + @echo About to run cgo $(seego) @CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) endif $(NETGO_CHECK) From 096fe82ce935ff1b9af30be176f70914004087ae Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 12:14:32 -0400 Subject: [PATCH 006/101] Add logging info --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 8cab3547f15d..4f0c52cf7310 100644 --- a/Makefile +++ b/Makefile @@ -278,6 +278,9 @@ dist-packages: dist-packages-amd64 dist-packages-arm64 dist-packages-armv6 dist- ifeq ($(BUILD_IN_CONTAINER), true) +@echo $(shell pwd) +ls + container_make = docker run --rm \ -v $(shell pwd):/src/agent:delegated \ -e RELEASE_TAG=$(RELEASE_TAG) \ From 5af54bc5b010b35e4369b4b57a63d3b109b56c3a Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 12:15:58 -0400 Subject: [PATCH 007/101] Add logging info --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4f0c52cf7310..cb01ef5183d7 100644 --- a/Makefile +++ b/Makefile @@ -278,8 +278,7 @@ dist-packages: dist-packages-amd64 dist-packages-arm64 dist-packages-armv6 dist- ifeq ($(BUILD_IN_CONTAINER), true) -@echo $(shell pwd) -ls +@echo $(shell pwd) $(shell ls) container_make = docker run --rm \ -v $(shell pwd):/src/agent:delegated \ From 025f81ab52f78515b764dd13fda2469ccbd3c64a Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 12:18:51 -0400 Subject: [PATCH 008/101] Add logging info --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index cb01ef5183d7..71745663e838 100644 --- a/Makefile +++ b/Makefile @@ -277,9 +277,7 @@ packaging/centos-systemd/.uptodate: $(wildcard packaging/centos-systemd/*) dist-packages: dist-packages-amd64 dist-packages-arm64 dist-packages-armv6 dist-packages-armv7 ifeq ($(BUILD_IN_CONTAINER), true) - @echo $(shell pwd) $(shell ls) - container_make = docker run --rm \ -v $(shell pwd):/src/agent:delegated \ -e RELEASE_TAG=$(RELEASE_TAG) \ From f4cf85cb6267a284a5e1371029ec806031adae7b Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 16:10:32 -0400 Subject: [PATCH 009/101] Add debugging info --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 71745663e838..a54b344e1c09 100644 --- a/Makefile +++ b/Makefile @@ -277,7 +277,8 @@ packaging/centos-systemd/.uptodate: $(wildcard packaging/centos-systemd/*) dist-packages: dist-packages-amd64 dist-packages-arm64 dist-packages-armv6 dist-packages-armv7 ifeq ($(BUILD_IN_CONTAINER), true) -@echo $(shell pwd) $(shell ls) + @echo $(shell pwd) $(shell ls) + container_make = docker run --rm \ -v $(shell pwd):/src/agent:delegated \ -e RELEASE_TAG=$(RELEASE_TAG) \ From 244bb516120c58892b585454663ae82edfc8e7aa Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 16:22:45 -0400 Subject: [PATCH 010/101] Add make debugging info --- .drone/drone.yml | 6 +++--- Makefile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index afd02fb1eb0b..9dce772c2a1b 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -44,9 +44,9 @@ steps: - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null - apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io - - make cmd/agent/agent cmd/agentctl/agentctl - - make test - - RELEASE_TAG=v0.0.0 make test-packages + - make -d cmd/agent/agent cmd/agentctl/agentctl + - make -d test + - RELEASE_TAG=v0.0.0 make -d test-packages volumes: - name: docker diff --git a/Makefile b/Makefile index a54b344e1c09..79ca04f99ef9 100644 --- a/Makefile +++ b/Makefile @@ -277,7 +277,7 @@ packaging/centos-systemd/.uptodate: $(wildcard packaging/centos-systemd/*) dist-packages: dist-packages-amd64 dist-packages-arm64 dist-packages-armv6 dist-packages-armv7 ifeq ($(BUILD_IN_CONTAINER), true) - @echo $(shell pwd) $(shell ls) + @echo !!! Building in container container_make = docker run --rm \ -v $(shell pwd):/src/agent:delegated \ From f0462588be06bf97d224fe79ee43abcfdcaf19ee Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 16:34:41 -0400 Subject: [PATCH 011/101] Add seego debugging --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 79ca04f99ef9..72d1de1cee9b 100644 --- a/Makefile +++ b/Makefile @@ -196,6 +196,7 @@ dist: dist-agent dist-agentctl dist-packages dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe dist/agent-linux-amd64: seego + @echo !!! ${seego} @CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: seego @CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent From ba6190b1f4ee49518e57c692f621814b92597d4e Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 16:46:09 -0400 Subject: [PATCH 012/101] add ls to see why files arent getting copied --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 72d1de1cee9b..8479423f71d3 100644 --- a/Makefile +++ b/Makefile @@ -197,6 +197,7 @@ dist: dist-agent dist-agentctl dist-packages dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe dist/agent-linux-amd64: seego @echo !!! ${seego} + @echo !!! $(shell ls) @CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: seego @CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent From 7048075802b7627a5ea28bb032355df4635236da Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 16:57:43 -0400 Subject: [PATCH 013/101] More debugging --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8479423f71d3..6026a7723b8b 100644 --- a/Makefile +++ b/Makefile @@ -197,8 +197,8 @@ dist: dist-agent dist-agentctl dist-packages dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe dist/agent-linux-amd64: seego @echo !!! ${seego} - @echo !!! $(shell ls) - @CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + @echo !!! $(shell ls /drone/src) + @CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: seego @CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv6: seego From 6f781f6aca2204843e751c698a9a962929a90fe0 Mon Sep 17 00:00:00 2001 From: mattdurham Date: Mon, 7 Jun 2021 17:09:01 -0400 Subject: [PATCH 014/101] simplify --- .drone/drone.yml | 4 ++-- Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 9dce772c2a1b..490629f5bd40 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -44,8 +44,8 @@ steps: - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null - apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io - - make -d cmd/agent/agent cmd/agentctl/agentctl - - make -d test +# - make -d cmd/agent/agent cmd/agentctl/agentctl +# - make -d test - RELEASE_TAG=v0.0.0 make -d test-packages volumes: diff --git a/Makefile b/Makefile index 6026a7723b8b..d2f96d3b2a1b 100644 --- a/Makefile +++ b/Makefile @@ -197,7 +197,7 @@ dist: dist-agent dist-agentctl dist-packages dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe dist/agent-linux-amd64: seego @echo !!! ${seego} - @echo !!! $(shell ls /drone/src) + @echo !!! $(shell ls /drone/src/cmd/agent) @CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: seego @CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent From 28b013f342ff7656186cd1d51b28678b34eb42bd Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 22 Jun 2021 10:53:47 -0400 Subject: [PATCH 015/101] Drone changes --- .drone/drone.yml | 35 +++--- .drone/packages.list | 27 +++++ .gitignore | 4 +- GOVERNANCE.md | 156 ------------------------- Makefile | 21 ++-- go_wrapper.sh | 145 +++++++++++++++++++++++ packaging/windows/install_script.nsis | 3 +- tools/seego/Dockerfile | 3 + tools/seego/go_wrapper.sh | 161 ++++++++++++++++++++++++++ 9 files changed, 373 insertions(+), 182 deletions(-) create mode 100644 .drone/packages.list delete mode 100644 GOVERNANCE.md create mode 100755 go_wrapper.sh create mode 100644 tools/seego/go_wrapper.sh diff --git a/.drone/drone.yml b/.drone/drone.yml index 490629f5bd40..714e4a437ad7 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -31,27 +31,32 @@ steps: - name: test-ubuntu image: ubuntu - volumes: - - name: docker - path: /var/run/docker.sock + #volumes: + #- name: docker + # path: /var/run/docker.sock commands: - - export DEBIAN_FRONTEND=noninteractive - - apt-get update -y && apt-get install -y libsystemd-dev apt-transport-https ca-certificates curl gnupg lsb-release wget make build-essential + - export DEBIAN_FRONTEND=noninteractive + - dpkg --add-architecture i386 + - apt-get update -y && apt-get install -y $(grep -vE "^\s*#" ./.drone/packages.list | tr "\n" " ") -y + - gem install --no-document fpm - mkdir -p /usr/local/go/bin - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz + - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - - echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null - - apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io -# - make -d cmd/agent/agent cmd/agentctl/agentctl -# - make -d test - - RELEASE_TAG=v0.0.0 make -d test-packages + - apt-get clean && rm -rf /var/lib/apt/lists/* + # - make BUILD_IN_CONTAINER=false cmd/agent/agent + - make BUILD_IN_CONTAINER=false cmd/agent/agent cmd/agentctl/agentctl + - make BUILD_IN_CONTAINER=false dist + - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 BUILD_IN_CONTAINER=false test-packages + # - make cmd/agentctl/agentctl + # - make test + # - RELEASE_TAG=v0.0.0 make test-packages -volumes: -- name: docker - host: - path: /var/run/docker.sock +#volumes: +#- name: docker +# host: +# path: /var/run/docker.sock --- kind: pipeline diff --git a/.drone/packages.list b/.drone/packages.list new file mode 100644 index 000000000000..592b12726827 --- /dev/null +++ b/.drone/packages.list @@ -0,0 +1,27 @@ +apt-transport-https +build-essential +bzr +ca-certificates +clang +cmake +curl +g++ +gcc +gcc-multilib +git +gnupg +libc6-dev +libc6-dev-i386 +libsnmp-dev +libsystemd-dev +libxml2-dev +linux-libc-dev:i386 mingw-w64 +lsb-release +make +nsis +patch +ruby +ruby-dev +rubygems +wget +xz-utils \ No newline at end of file diff --git a/.gitignore b/.gitignore index 358dc9dcb7d7..ab3343dec5e7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,12 @@ .published .pkg .cache +.vscode +vendor cover*.out cmd/agent/agent cmd/agentctl/agentctl dist/ -.DS_Store \ No newline at end of file +.DS_Store diff --git a/GOVERNANCE.md b/GOVERNANCE.md deleted file mode 100644 index c4123c67a653..000000000000 --- a/GOVERNANCE.md +++ /dev/null @@ -1,156 +0,0 @@ ---- -title: Governance ---- -# Governance - -This document describes the rules and governance of the project. It is meant to be followed by all the developers of the project and the Grafana Agent community. Common terminology used in this governance document are listed below: - -- **Team members**: Any members of the private [team mailing list][team]. - -- **Maintainers**: Maintainers lead an individual project or parts thereof ([`MAINTAINERS.md`][maintainers]). - -- **Projects**: A single repository in the Grafana GitHub organization and listed below is referred to as a project: - - Grafana Agent - -- **The Grafana Agent project**: The sum of all activities performed under this governance, concerning one or more repositories or the community. - -## Values - -The Grafana Agent developers and community are expected to follow the values defined in the [Code of Conduct][coc]. Furthermore, the Grafana Agent community strives for kindness, giving feedback effectively, and building a welcoming environment. The Grafana Agent developers generally decide by consensus and only resort to conflict resolution by a majority vote if consensus cannot be reached. - -## Projects - -Each project must have a [`MAINTAINERS.md`][maintainers] file with at least one maintainer. Where a project has a release process, access and documentation should be such that more than one person can perform a release. Where a project has a release process, access and documentation should be such that more than one person can perform a release. Releases should be announced on the [GitHub Discussions][discussions] page. Any new projects should be first proposed on the [team mailing list][team] following the voting procedures listed below. - -## Decision making - -### Team members - -Team member status may be given to those who have made ongoing contributions to the Grafana Agent project for at least 3 months. This is usually in the form of code improvements and/or notable work on documentation, but organizing events or user support could also be taken into account. - -New members may be proposed by any existing member by email to the [team mailing list][team]. It is highly desirable to reach consensus about acceptance of a new member. However, the proposal is ultimately voted on by a formal [supermajority vote](#supermajority-vote). - -If the new member proposal is accepted, the proposed team member should be contacted privately via email to confirm or deny their acceptance of team membership. This email will also be CC'd to the [team mailing list][team] for record-keeping purposes. - -If they choose to accept, the [onboarding](#onboarding) procedure is followed. - -Team members may retire at any time by emailing [the team][team]. - -Team members can be removed by [supermajority vote](#supermajority-vote) on [the team mailing list][team]. -For this vote, the member in question is not eligible to vote and does not count towards the quorum. -Any removal vote can cover only one single person. - -Upon death of a member, they leave the team automatically. - -In case a member leaves, the [offboarding](#offboarding) procedure is applied. - -The current team members are: - -- Matt Durham - [mattdurham](https://github.com/mattdurham) ([Grafana Labs](https://grafana.com)) -- Joe Elliott - [joe-elliott](https://github.com/joe-elliott) ([Grafana Labs](https://grafana.com)) -- Robert Fratto - [rfratto](https://github.com/rfratto) ([Grafana Labs](https://grafana.com)) -- Richard Hartmann - [RichiH](https://github.com/RichiH) ([Grafana Labs](https://grafana.com)) -- Mario Rodriguez - [mapno](https://github.com/mapno) ([Grafana Labs](https://grafana.com)) - -### Maintainers - -Maintainers lead one or more project(s) or parts thereof and serve as a point of conflict resolution amongst the contributors to this project. Ideally, maintainers are also team members, but exceptions are possible for suitable maintainers that, for whatever reason, are not yet team members. - -Changes in maintainership have to be announced on the [developers mailing list][devs]. They are decided by [rough consensus](#consensus) and formalized by changing the [`MAINTAINERS.md`][maintainers] file of the respective repository. - -Maintainers are granted commit rights to all projects covered by this governance. - -A maintainer or committer may resign by notifying the [team mailing list][team]. A maintainer with no project activity for a year is considered to have resigned. Maintainers that wish to resign are encouraged to propose another team member to take over the project. - -A project may have multiple maintainers, as long as the responsibilities are clearly agreed upon between them. This includes coordinating who handles which issues and pull requests. - -### Technical decisions - -Technical decisions that only affect a single project are made informally by the maintainer of this project, and [rough consensus](#consensus) is assumed. Technical decisions that span multiple parts of the project should be discussed and made on the [developer mailing list][devs]. - -Decisions are usually made by [rough consensus](#consensus). If no consensus can be reached, the matter may be resolved by [majority vote](#majority-vote). - -### Governance changes - -Changes to this document are made by Grafana Labs. - -### Other matters - -Any matter that needs a decision may be called to a vote by any member if they deem it necessary. For private or personnel matters, discussion and voting takes place on the [team mailing list][team], otherwise on the [developer mailing list][devs]. - -## Voting - -The Grafana Agent project usually runs by informal consensus, however sometimes a formal decision must be made. - -Depending on the subject matter, as laid out [above](#decision-making), different methods of voting are used. - -For all votes, voting must be open for at least one week. The end date should be clearly stated in the call to vote. A vote may be called and closed early if enough votes have come in one way so that further votes cannot change the final decision. - -In all cases, all and only [team members](#team-members) are eligible to vote, with the sole exception of the forced removal of a team member, in which said member is not eligible to vote. - -Discussion and votes on personnel matters (including but not limited to team membership and maintainership) are held in private on the [team mailing list][team]. All other discussion and votes are held in public on the [developer mailing list][devs]. - -For public discussions, anyone interested is encouraged to participate. Formal power to object or vote is limited to [team members](#team-members). - -### Consensus - -The default decision making mechanism for the Grafana Agent project is [rough][rough] consensus. This means that any decision on technical issues is considered supported by the [team][team] as long as nobody objects or the objection has been considered but not necessarily accommodated. - -Silence on any consensus decision is implicit agreement and equivalent to explicit agreement. Explicit agreement may be stated at will. Decisions may, but do not need to be called out and put up for decision on the [developers mailing list][devs] at any time and by anyone. - -Consensus decisions can never override or go against the spirit of an earlier explicit vote. - -If any [team member](#team-members) raises objections, the team members work together towards a solution that all involved can accept. This solution is again subject to rough consensus. - -In case no consensus can be found, but a decision one way or the other must be made, any [team member](#team-members) may call a formal [majority vote](#majority-vote). - -### Majority vote - -Majority votes must be called explicitly in a separate thread on the appropriate mailing list. The subject must be prefixed with `[VOTE]`. In the body, the call to vote must state the proposal being voted on. It should reference any discussion leading up to this point. - -Votes may take the form of a single proposal, with the option to vote yes or no, or the form of multiple alternatives. - -A vote on a single proposal is considered successful if more vote in favor than against. - -If there are multiple alternatives, members may vote for one or more alternatives, or vote “no” to object to all alternatives. It is not possible to cast an “abstain” vote. A vote on multiple alternatives is considered decided in favor of one alternative if it has received the most votes in favor, and a vote from more than half of those voting. Should no alternative reach this quorum, another vote on a reduced number of options may be called separately. - -### Supermajority vote - -Supermajority votes must be called explicitly in a separate thread on the appropriate mailing list. The subject must be prefixed with `[VOTE]`. In the body, the call to vote must state the proposal being voted on. It should reference any discussion leading up to this point. - -Votes may take the form of a single proposal, with the option to vote yes or no, or the form of multiple alternatives. - -A vote on a single proposal is considered successful if at least two thirds of those eligible to vote vote in favor. - -If there are multiple alternatives, members may vote for one or more alternatives, or vote “no” to object to all alternatives. A vote on multiple alternatives is considered decided in favor of one alternative if it has received the most votes in favor, and a vote from at least two thirds of those eligible to vote. Should no alternative reach this quorum, another vote on a reduced number of options may be called separately. - -## On- / Offboarding - -### Onboarding - -The new member is - -- added to the list of [team members](#team-members). Ideally by sending a PR of their own, at least approving said PR. -- announced on the [developers mailing list][devs] by an existing team member. Ideally, the new member replies in this thread, acknowledging team membership. -- added to the projects with commit rights. -- added to the [team mailing list][team]. - - -### Offboarding - -The ex-member is - -- removed from the list of [team members](#team-members). Ideally by sending a PR of their own, at least approving said PR. In case of forced removal, no approval is needed. -- removed from the projects. Optionally, they can retain maintainership of one or more repositories if the [team](#team-members) agrees. -- removed from the team mailing list and demoted to a normal member of the other mailing lists. -- not allowed to call themselves an active team member any more, nor allowed to imply this to be the case. -- added to a list of previous members if they so choose. - -If needed, we reserve the right to publicly announce removal. - -[coc]: https://github.com/grafana/agent/blob/main/CODE_OF_CONDUCT.md -[devs]: https://groups.google.com/forum/#!forum/grafana-agent-developers -[maintainers]: https://github.com/grafana/agent/blob/main/MAINTAINERS.md -[rough]: https://tools.ietf.org/html/rfc7282 -[team]: https://groups.google.com/forum/#!forum/grafana-agent-team -[discussions]: https://github.com/grafana/agent/discussions diff --git a/Makefile b/Makefile index d2f96d3b2a1b..d3c05405aa17 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ IMAGE_TAG ?= $(shell ./tools/image-tag) # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, # and seego is used for building binaries instead of go. -CROSS_BUILD ?= false +CROSS_BUILD ?= true # Certain aspects of the build are done in containers for consistency. # If you have the correct tools installed and want to speed up development, @@ -43,9 +43,8 @@ DOCKER_BUILD_FLAGS = --build-arg RELEASE_BUILD=$(RELEASE_BUILD) --build-arg IMAG # We need a separate set of flags for CGO, where building with -static can # cause problems with some C libraries. -CGO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "netgo" +CGO_FLAGS := -ldflags="-s -w $(GO_LDFLAGS)" -tags 'netgo' DEBUG_CGO_FLAGS := -gcflags "all=-N -l" -ldflags "-s -w $(GO_LDFLAGS)" -tags "netgo" - # If we're not building the release, use the debug flags instead. ifeq ($(RELEASE_BUILD),false) GO_FLAGS = $(DEBUG_GO_FLAGS) @@ -85,7 +84,7 @@ docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,lin endif ifeq ($(BUILD_IN_CONTAINER),false) -seego = "/seego.sh" +seego = ./go_wrapper.sh && go endif ############# @@ -123,7 +122,6 @@ cmd/agent/agent: check-seego cmd/agent/main.go ifeq ($(CROSS_BUILD),false) CGO_ENABLED=1 go build $(CGO_FLAGS) -o $@ ./$(@D) else - @echo About to run cgo $(seego) @CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) endif $(NETGO_CHECK) @@ -196,12 +194,11 @@ dist: dist-agent dist-agentctl dist-packages dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe dist/agent-linux-amd64: seego - @echo !!! ${seego} - @echo !!! $(shell ls /drone/src/cmd/agent) - @CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + @CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: seego @CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv6: seego + @echo $(CGO_FLAGS) @CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv7: seego @CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent @@ -216,8 +213,12 @@ dist/agent-windows-amd64.exe: seego dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe cp dist/agent-windows-amd64.exe ./packaging/windows cp LICENSE ./packaging/windows +ifeq ($(BUILD_IN_CONTAINER),true) docker build ./packaging/windows -t windows_nsis - docker run -e VERSION=${RELEASE_TAG} --rm -t -v $(CURDIR)/dist:/app windows_nsis + docker run -e VERSION=${RELEASE_TAG} -DOUT="/app/grafana-agent-installer.exe" --rm -t -v $(CURDIR)/dist:/app windows_nsis +else + makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis +endif dist/agent-freebsd-amd64: seego @CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent @@ -242,7 +243,9 @@ dist/agentctl-freebsd-amd64: seego @CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl seego: tools/seego/Dockerfile +ifeq ($(BUILD_IN_CONTAINER),true) docker build -t grafana/agent/seego tools/seego +endif # Makes seego if CROSS_BUILD is true. check-seego: diff --git a/go_wrapper.sh b/go_wrapper.sh new file mode 100755 index 000000000000..7d1f97843b1a --- /dev/null +++ b/go_wrapper.sh @@ -0,0 +1,145 @@ +#!/usr/bin/env bash + +FOUND_CC="" +FOUND_CXX="" +FOUND_LD_PATH="" +CC_EXTRA="" +CXX_EXTRA="" + +CGO_ENABLED=${CGO_ENABLED:-$(go env CGO_ENABLED)} +GOARCH=$(go env GOARCH) +GOOS=$(go env GOOS) +GOARM=$(go env GOARM) + +main() { + echo ">>> discovering toolchain for GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM}" + + case "$GOOS" in + linux) configure_linux ;; + darwin) configure_darwin ;; + freebsd) configure_bsd ;; + windows) configure_windows ;; + *) + echo ">>> ERROR: unsupported GOOS value $GOOS" + exit 1 + esac + + echo ">>> discovered CC ${FOUND_CC}" + echo ">>> discovered CXX ${FOUND_CXX}" + echo ">>> extra C flags: ${CC_EXTRA}" + + echo ">>> CGO_ENABLED=${CGO_ENABLED} CC=$FOUND_CC CXX=$FOUND_CXX go $@" + + # I'm skeptical that this is the best way to do it because it's so + # annoying, but it works at least. + # + # Export environment variables we want to retain when running go + # as the new user. Even though we preserve the path, we have to use + # the full path to go since sudo won't read the PATH for it. + + export CC="$FOUND_CC $CC_EXTRA" + export CXX="$FOUND_CXX $CC_EXTRA" + + export CGO_CFLAGS=$CC_EXTRA + export CGO_CXX_CFLAGS=$CC_EXTRA + export CGO_LDFLAGS=$CC_EXTRA + + export PATH=$PATH + if [ ! -z "$FOUND_LD_PATH" ]; then + export LD_LIBRARY_PATH="$FOUND_LD_PATH:$LD_LIBRARY_PATH" + fi + + export GOCACHE=$(pwd)/.cache +} + +configure_linux() { + toolchain_prefix="" + + case "$GOARCH" in + # Do nothing for native archs + amd64 | 386) ;; + + arm) toolchain_prefix="arm-linux-gnueabi-" ;; + arm64) toolchain_prefix="aarch64-linux-gnu-" ;; + + ppc64) toolchain_prefix="powerpc-linux-gnu-" ;; + ppc64le) toolchain_prefix="powerpc64le-linux-gnu-" ;; + + mips) toolchain_prefix="mips-linux-gnu-" ;; + mipsle) toolchain_prefix="mipsel-linux-gnu-" ;; + mips64) toolchain_prefix="mips64-linux-gnuabi64-" ;; + mips64le) toolchain_prefix="mips64el-linux-gnuabi64-" ;; + + s390x) toolchain_prefix="s390x-linux-gnu-" ;; + + *) + echo ">>> ERROR: unsupported linux GOARCH value $GOARCH" + echo ">>> supported values: amd64, 386, arm, arm64, ppc64, ppc64le, mips, mipsle, mips64, mips64le, s390x" + exit 1 + esac + + if [ "$GOARCH" == "arm" ] && [ "$GOARM" == "7" ]; then + toolchain_prefix="arm-linux-gnueabihf-" + fi + + FOUND_CC="${toolchain_prefix}gcc" + FOUND_CXX="${toolchain_prefix}g++" +} + +configure_darwin() { + case "$GOARCH" in + amd64) + FOUND_CC="x86_64-apple-darwin20.2-clang" + FOUND_CXX="x86_64-apple-darwin20.2-clang++" + FOUND_LD_PATH="$OSXCROSS_PATH/lib" + ;; + arm64) + FOUND_CC="arm64-apple-darwin20.2-clang" + FOUND_CXX="arm64-apple-darwin20.2-clang++" + FOUND_LD_PATH="$OSXCROSS_PATH/lib" + ;; + *) + echo ">>> ERROR: unsupported darwin GOARCH value $GOARCH" + echo ">>> supported values: amd64, arm64" + exit 1 + esac +} + +configure_bsd() { + case "$GOARCH" in + amd64) + FOUND_CC="clang" + FOUND_CXX="clang++" + CC_EXTRA="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" + ;; + 386) + FOUND_CC="clang" + FOUND_CXX="clang++" + CC_EXTRA="-target i386-pc-freebsd11 --sysroot=/usr/freebsd/i386-pc-freebsd11 -v" + ;; + + *) + echo ">>> ERROR: unsupported bsd GOARCH value $GOARCH" + echo ">>> supported values: amd64, 386" + exit 1 + esac +} + +configure_windows() { + case "$GOARCH" in + 386) + FOUND_CC="i686-w64-mingw32-gcc" + FOUND_CXX="i686-w64-mingw32-g++" + ;; + amd64) + FOUND_CC="x86_64-w64-mingw32-gcc" + FOUND_CXX="x86_64-w64-mingw32-g++" + ;; + + *) + echo ">>> ERROR: unsupported windows GOARCH value $GOARCH" + echo ">>> supported values: 386, amd64" + exit 1 + esac +} +main "$@" diff --git a/packaging/windows/install_script.nsis b/packaging/windows/install_script.nsis index 6558b8ff775b..3c735d173207 100644 --- a/packaging/windows/install_script.nsis +++ b/packaging/windows/install_script.nsis @@ -16,7 +16,8 @@ InstallDir "$PROGRAMFILES64\${APPNAME}" # This will be in the installer/uninstaller's title bar Name "${APPNAME} ${VERSION}" Icon "logo.ico" -outFile "/app/grafana-agent-installer.exe" +outFile "${OUT}" + !include nsDialogs.nsh !include FileFunc.nsh diff --git a/tools/seego/Dockerfile b/tools/seego/Dockerfile index 36c5b1879ac2..fdee9a079990 100644 --- a/tools/seego/Dockerfile +++ b/tools/seego/Dockerfile @@ -9,3 +9,6 @@ RUN rm -rf /usr/local/go \ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ && tar -C /usr/local -xzf golang.tar.gz \ && rm golang.tar.gz +COPY go_wrapper.sh / +RUN chmod +x /go_wrapper.sh +ENTRYPOINT ["/go_wrapper.sh"] diff --git a/tools/seego/go_wrapper.sh b/tools/seego/go_wrapper.sh new file mode 100644 index 000000000000..a2cdcf8bf2a6 --- /dev/null +++ b/tools/seego/go_wrapper.sh @@ -0,0 +1,161 @@ +#!/usr/bin/env bash + +FOUND_CC="" +FOUND_CXX="" +FOUND_LD_PATH="" +CC_EXTRA="" +CXX_EXTRA="" + +CGO_ENABLED=${CGO_ENABLED:-$(go env CGO_ENABLED)} +GOARCH=$(go env GOARCH) +GOOS=$(go env GOOS) +GOARM=$(go env GOARM) + +main() { + echo ">>> discovering toolchain for GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM}" + + case "$GOOS" in + linux) configure_linux ;; + darwin) configure_darwin ;; + freebsd) configure_bsd ;; + windows) configure_windows ;; + *) + echo ">>> ERROR: unsupported GOOS value $GOOS" + exit 1 + esac + + echo ">>> discovered CC ${FOUND_CC}" + echo ">>> discovered CXX ${FOUND_CXX}" + echo ">>> extra C flags: ${CC_EXTRA}" + + echo ">>> CGO_ENABLED=${CGO_ENABLED} CC=$FOUND_CC CXX=$FOUND_CXX go $@" + + # If we run go directly, any files created on the bind mount + # will have awkward ownership. So we switch to a user with the + # same user and group IDs as source directory. We have to set a + # few things up so that sudo works without complaining later on. + uid=$(stat --format="%u" $(pwd)) + gid=$(stat --format="%g" $(pwd)) + echo "seego:x:$uid:$gid::$(pwd):/bin/bash" >>/etc/passwd + echo "seego:*:::::::" >>/etc/shadow + echo "seego ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers + + # I'm skeptical that this is the best way to do it because it's so + # annoying, but it works at least. + # + # Export environment variables we want to retain when running go + # as the new user. Even though we preserve the path, we have to use + # the full path to go since sudo won't read the PATH for it. + + export CC="$FOUND_CC $CC_EXTRA" + export CXX="$FOUND_CXX $CC_EXTRA" + + export CGO_CFLAGS=$CC_EXTRA + export CGO_CXX_CFLAGS=$CC_EXTRA + export CGO_LDFLAGS=$CC_EXTRA + + export PATH=$PATH + if [ ! -z "$FOUND_LD_PATH" ]; then + export LD_LIBRARY_PATH="$FOUND_LD_PATH:$LD_LIBRARY_PATH" + fi + + export GOCACHE=$(pwd)/.cache + + exec sudo -E \ + --preserve-env=PATH \ + --preserve-env=LD_LIBRARY_PATH \ + -u seego -- $(which go) "$@" +} + +configure_linux() { + toolchain_prefix="" + + case "$GOARCH" in + # Do nothing for native archs + amd64 | 386) ;; + + arm) toolchain_prefix="arm-linux-gnueabi-" ;; + arm64) toolchain_prefix="aarch64-linux-gnu-" ;; + + ppc64) toolchain_prefix="powerpc-linux-gnu-" ;; + ppc64le) toolchain_prefix="powerpc64le-linux-gnu-" ;; + + mips) toolchain_prefix="mips-linux-gnu-" ;; + mipsle) toolchain_prefix="mipsel-linux-gnu-" ;; + mips64) toolchain_prefix="mips64-linux-gnuabi64-" ;; + mips64le) toolchain_prefix="mips64el-linux-gnuabi64-" ;; + + s390x) toolchain_prefix="s390x-linux-gnu-" ;; + + *) + echo ">>> ERROR: unsupported linux GOARCH value $GOARCH" + echo ">>> supported values: amd64, 386, arm, arm64, ppc64, ppc64le, mips, mipsle, mips64, mips64le, s390x" + exit 1 + esac + + if [ "$GOARCH" == "arm" ] && [ "$GOARM" == "7" ]; then + toolchain_prefix="arm-linux-gnueabihf-" + fi + + FOUND_CC="${toolchain_prefix}gcc" + FOUND_CXX="${toolchain_prefix}g++" +} + +configure_darwin() { + case "$GOARCH" in + amd64) + FOUND_CC="x86_64-apple-darwin20.2-clang" + FOUND_CXX="x86_64-apple-darwin20.2-clang++" + FOUND_LD_PATH="$OSXCROSS_PATH/lib" + ;; + arm64) + FOUND_CC="arm64-apple-darwin20.2-clang" + FOUND_CXX="arm64-apple-darwin20.2-clang++" + FOUND_LD_PATH="$OSXCROSS_PATH/lib" + ;; + *) + echo ">>> ERROR: unsupported darwin GOARCH value $GOARCH" + echo ">>> supported values: amd64, arm64" + exit 1 + esac +} + +configure_bsd() { + case "$GOARCH" in + amd64) + FOUND_CC="clang" + FOUND_CXX="clang++" + CC_EXTRA="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" + ;; + 386) + FOUND_CC="clang" + FOUND_CXX="clang++" + CC_EXTRA="-target i386-pc-freebsd11 --sysroot=/usr/freebsd/i386-pc-freebsd11 -v" + ;; + + *) + echo ">>> ERROR: unsupported bsd GOARCH value $GOARCH" + echo ">>> supported values: amd64, 386" + exit 1 + esac +} + +configure_windows() { + case "$GOARCH" in + 386) + FOUND_CC="i686-w64-mingw32-gcc" + FOUND_CXX="i686-w64-mingw32-g++" + ;; + amd64) + FOUND_CC="x86_64-w64-mingw32-gcc" + FOUND_CXX="x86_64-w64-mingw32-g++" + ;; + + *) + echo ">>> ERROR: unsupported windows GOARCH value $GOARCH" + echo ">>> supported values: 386, amd64" + exit 1 + esac +} +echo "!!!<<>>!!!" +main "$@" From a9c683e6ecc687b054758103b25d20e583a193e1 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Fri, 2 Jul 2021 09:30:37 -0400 Subject: [PATCH 016/101] Drone v2 Former-commit-id: 914b4a37991b7d651ae37f06840c1c7d968bb669 --- .drone/Dockerfile | 102 +++++++++ .drone/drone.yml | 90 +++++--- .drone/packages.list | 1 + Makefile | 107 ++++------ go.mod | 6 +- go.sum | 34 +++ go_wrapper.sh | 4 +- packaging/windows/LICENSE | 202 ++++++++++++++++++ .../agent-windows-amd64.exe.REMOVED.git-id | 1 + test.sh | 8 + tools/test-packages | 17 +- 11 files changed, 467 insertions(+), 105 deletions(-) create mode 100644 .drone/Dockerfile create mode 100644 packaging/windows/LICENSE create mode 100644 packaging/windows/agent-windows-amd64.exe.REMOVED.git-id create mode 100644 test.sh diff --git a/.drone/Dockerfile b/.drone/Dockerfile new file mode 100644 index 000000000000..fa5f492573f9 --- /dev/null +++ b/.drone/Dockerfile @@ -0,0 +1,102 @@ +FROM ubuntu +COPY ./packages.list /packages.list +ARG DEBIAN_FRONTEND=noninteractive +RUN dpkg --add-architecture i386 +RUN apt-get update -y && apt-get install -y $(grep -vE "^\s*#" /packages.list | tr "\n" " ") -y +RUN gem install --no-document fpm +RUN mkdir -p /usr/local/go/bin +RUN wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz +RUN tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz +RUN rm go1.16.5.linux-amd64.tar.gz +ENV PATH=$PATH:/usr/local/go/bin +RUN apt-get clean && rm -rf /var/lib/apt/lists/* +RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg +RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null +RUN apt-get update +RUN apt-get install -y docker-ce docker-ce-cli containerd.io +ARG OSXCROSS_SDK_URL +ENV OSXCROSS_PATH=/usr/osxcross \ + OSXCROSS_REV=035cc170338b7b252e3f13b0e3ccbf4411bffc41 \ + SDK_VERSION=11.1 +RUN mkdir -p /tmp/osxcross && cd /tmp/osxcross \ + && curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" \ + | tar -C /tmp/osxcross --strip=1 -xzf - \ + && curl -sSLo tarballs/MacOSX${SDK_VERSION}.sdk.tar.xz ${OSXCROSS_SDK_URL} \ + && UNATTENDED=yes ./build.sh \ + && mv target "${OSXCROSS_PATH}" \ + && rm -rf /tmp/osxcross "/usr/osxcross/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man" +RUN dpkg --add-architecture amd64 \ + && dpkg --add-architecture i386 \ + && dpkg --add-architecture armel \ + && dpkg --add-architecture armhf \ + && dpkg --add-architecture arm64 \ + && dpkg --add-architecture mips \ + && dpkg --add-architecture mipsel \ + && dpkg --add-architecture powerpc \ + && dpkg --add-architecture ppc64el \ + && dpkg --add-architecture s390x \ + && apt-get update \ + && apt-get install -yq \ + binfmt-support \ + binutils-multiarch \ + binutils-multiarch-dev \ + build-essential \ + bzr \ + clang \ + crossbuild-essential-arm64 \ + crossbuild-essential-armel \ + crossbuild-essential-armhf \ + crossbuild-essential-mipsel \ + crossbuild-essential-powerpc \ + crossbuild-essential-ppc64el \ + crossbuild-essential-s390x \ + curl \ + git \ + git-core \ + libssl-dev \ + llvm \ + mercurial \ + mingw-w64 \ + openssl \ + patch \ + qemu-user-static \ + software-properties-common \ + subversion \ + sudo \ + wget \ + xz-utils \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Backports repo required to get a libsystemd version 246 or newer which is required to handle journal +ZSTD compression +RUN echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list +RUN apt-get update \ + && apt-get install -t buster-backports -qy libsystemd-dev \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# +# OSX +# + +ENV OSXCROSS_PATH=/usr/osxcross +COPY --from=osxcross $OSXCROSS_PATH $OSXCROSS_PATH +ENV PATH $OSXCROSS_PATH/bin:$PATH + + +# +# FreeBSD +# + +COPY assets/freebsd-amd64-11.3.tar.xz /usr/freebsd/freebsd-amd64.tar.xz +COPY assets/freebsd-i386-11.3.tar.xz /usr/freebsd/freebsd-i386.tar.xz + +RUN mkdir /usr/freebsd/x86_64-pc-freebsd11 \ + && cd /usr/freebsd/x86_64-pc-freebsd11 \ + && tar -xf /usr/freebsd/freebsd-amd64.tar.xz ./lib ./usr/lib ./usr/include \ + && rm /usr/freebsd/freebsd-amd64.tar.xz \ + \ + && mkdir /usr/freebsd/i386-pc-freebsd11 \ + && cd /usr/freebsd/i386-pc-freebsd11 \ + && tar -xf /usr/freebsd/freebsd-i386.tar.xz ./lib ./usr/lib ./usr/include \ + && rm /usr/freebsd/freebsd-i386.tar.xz + +CMD ["bash"] \ No newline at end of file diff --git a/.drone/drone.yml b/.drone/drone.yml index 714e4a437ad7..290f925bb617 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -1,6 +1,6 @@ --- kind: pipeline -name: Test +name: Lint platform: os: linux arch: amd64 @@ -8,32 +8,62 @@ platform: steps: - name: lint image: golangci/golangci-lint:v1.37.1 - # libsystemd-dev is required for cgo commands: - apt-get update -y && apt-get install -y libsystemd-dev - make lint +--- +kind: pipeline +type: docker +name: Dist +platform: + os: linux + arch: amd64 -# - name: test -# image: ubuntu -# volumes: -# - name: docker -# path: /var/run/docker.sock -# commands: -# - apt-get update && apt-get install -y libsystemd-dev -# - mkdir -p /usr/local/go/bin -# - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz -# - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz -# - export PATH=$PATH:/usr/local/go/bin -# - make cmd/agent/agent cmd/agentctl/agentctl -# - make test -# - RELEASE_TAG=v0.0.0 make test-packages - - +steps: - name: test-ubuntu + image: rfratto/seego + commands: + - apt-get update && apt-get install -y rubygems rpm nsis + - gem install --no-document fpm + - mkdir -p /usr/local/go/bin + - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz + - rm go1.16.5.linux-amd64.tar.gz + - export PATH=$PATH:/usr/local/go/bin + - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist/agent-freebsd-amd64 +--- +kind: pipeline +type: docker +name: Release +platform: + os: linux + arch: amd64 +trigger: + event: + - tag +steps: +- name: create-release + image: agentbuild + pull: if-not-exists + commands: + - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr + - export PATH="$(go env GOPATH)/bin:$PATH" + - export RELEASE_TAG=${GITHUB_REF##*/} + - make -j4 RELEASE_BUILD=true publish +- name: publish + image: plugins/github-release + settings: + api_key: xxxxxxxx + files: /drone/src/dist/* + draft: true +--- +kind: pipeline +type: docker +name: Containerize2 + +steps: +- name: Build Agent Containers image: ubuntu - #volumes: - #- name: docker - # path: /var/run/docker.sock commands: - export DEBIAN_FRONTEND=noninteractive - dpkg --add-architecture i386 @@ -44,19 +74,9 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - apt-get clean && rm -rf /var/lib/apt/lists/* - # - make BUILD_IN_CONTAINER=false cmd/agent/agent - - make BUILD_IN_CONTAINER=false cmd/agent/agent cmd/agentctl/agentctl - - make BUILD_IN_CONTAINER=false dist - - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 BUILD_IN_CONTAINER=false test-packages - # - make cmd/agentctl/agentctl - # - make test - # - RELEASE_TAG=v0.0.0 make test-packages + - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make agent + - CGO_ENABLED=1 GOOS=linux GOARCH=arm64 make agent -#volumes: -#- name: docker -# host: -# path: /var/run/docker.sock --- kind: pipeline @@ -79,6 +99,10 @@ steps: - cp buildx-v0.5.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx - chmod a+x ~/.docker/cli-plugins/docker-buildx - docker buildx create --use + - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - docker buildx create --name multiarch --driver docker-container --use + - docker buildx inspect --bootstrap + - docker buildx ls - CROSS_BUILD=true RELEASE_BUILD=true make agent-image - name: Build Agentctl Container image: docker diff --git a/.drone/packages.list b/.drone/packages.list index 592b12726827..3ff0ff0acd1a 100644 --- a/.drone/packages.list +++ b/.drone/packages.list @@ -20,6 +20,7 @@ lsb-release make nsis patch +rpm ruby ruby-dev rubygems diff --git a/Makefile b/Makefile index d3c05405aa17..b5a12fbe6189 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,6 @@ PACKAGE_RELEASE := 1 DOCKERFILE = Dockerfile -seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" -e "GOMIPS=$$GOMIPS" grafana/agent/seego docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) @@ -83,10 +82,6 @@ DOCKERFILE = Dockerfile.buildx docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) endif -ifeq ($(BUILD_IN_CONTAINER),false) -seego = ./go_wrapper.sh && go -endif - ############# # Protobufs # ############# @@ -192,68 +187,50 @@ dist: dist-agent dist-agentctl dist-packages pushd dist && sha256sum * > SHA256SUMS && popd .PHONY: dist -dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe -dist/agent-linux-amd64: seego - @CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-arm64: seego - @CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-armv6: seego - @echo $(CGO_FLAGS) - @CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-armv7: seego - @CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-mipsle: seego - @CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-darwin-amd64: seego - @CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-darwin-arm64: seego - @CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-windows-amd64.exe: seego - @CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent +dist-agent: dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe +dist/agent-linux-amd64: + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./cmd/agent +dist/agent-linux-arm64: + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent +dist/agent-linux-armv6: + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent +dist/agent-linux-armv7: + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent +dist/agent-linux-mipsle: + @CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++;go build $(CGO_FLAGS) -o $@ ./cmd/agent +dist/agent-darwin-amd64: + export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent +dist/agent-darwin-arm64: + export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent +dist/agent-windows-amd64.exe: + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe cp dist/agent-windows-amd64.exe ./packaging/windows cp LICENSE ./packaging/windows -ifeq ($(BUILD_IN_CONTAINER),true) - docker build ./packaging/windows -t windows_nsis - docker run -e VERSION=${RELEASE_TAG} -DOUT="/app/grafana-agent-installer.exe" --rm -t -v $(CURDIR)/dist:/app windows_nsis -else makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis -endif -dist/agent-freebsd-amd64: seego - @CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent - -dist-agentctl: seego dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 -dist/agentctl-linux-amd64: seego - @CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-arm64: seego - @CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-armv6: seego - @CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-armv7: seego - @CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-mipsle: seego - @CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-darwin-amd64: seego - @CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-darwin-arm64: seego - @CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-windows-amd64.exe: seego - @CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-freebsd-amd64: seego - @CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl - -seego: tools/seego/Dockerfile -ifeq ($(BUILD_IN_CONTAINER),true) - docker build -t grafana/agent/seego tools/seego -endif +dist/agent-freebsd-amd64: + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS='-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11' ; go build $(CGO_FLAGS) -o $@ ./cmd/agent + +dist-agentctl: dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 +dist/agentctl-linux-amd64: + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc CCX=g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +dist/agentctl-linux-arm64: + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +dist/agentctl-linux-armv6: + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +dist/agentctl-linux-armv7: + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +dist/agentctl-linux-mipsle: + export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +dist/agentctl-darwin-amd64: + export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +dist/agentctl-darwin-arm64: + export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +dist/agentctl-windows-amd64.exe: + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +dist/agentctl-freebsd-amd64: + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11"; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -# Makes seego if CROSS_BUILD is true. -check-seego: -ifeq ($(CROSS_BUILD),true) -ifeq ($(BUILD_IN_CONTAINER),true) - $(MAKE) seego -endif -endif build-image/.uptodate: build-image/Dockerfile docker pull $(BUILD_IMAGE) || docker build -t $(BUILD_IMAGE) $(@D) @@ -300,9 +277,7 @@ dist-packages-armv7: enforce-release-tag dist/agent-linux-armv7 dist/agentctl-li $(container_make) $@; else - -package_base = dist/grafana-agent-$(PACKAGE_VERSION)-$(PACKAGE_RELEASE) - +package_base = ./dist/grafana-agent-$(PACKAGE_VERSION)-$(PACKAGE_RELEASE) dist-packages-amd64: $(package_base).amd64.deb $(package_base).amd64.rpm dist-packages-arm64: $(package_base).arm64.deb $(package_base).arm64.rpm dist-packages-armv6: $(package_base).armv6.deb @@ -374,4 +349,4 @@ clean-dist: .PHONY: clean publish: dist - ./tools/release + ./tools/release \ No newline at end of file diff --git a/go.mod b/go.mod index 4f629fd86adf..f1e61a7a87f8 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/jsternberg/zap-logfmt v1.2.0 github.com/justwatchcom/elasticsearch_exporter v1.1.0 github.com/miekg/dns v1.1.41 + github.com/mitchellh/gox v1.0.1 // indirect github.com/ncabatoff/process-exporter v0.7.5 github.com/oklog/run v1.1.0 github.com/olekukonko/tablewriter v0.0.2 @@ -41,6 +42,7 @@ require ( github.com/spf13/cobra v1.1.3 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 + github.com/tcnksm/ghr v0.14.0 // indirect github.com/uber/jaeger-client-go v2.28.0+incompatible github.com/weaveworks/common v0.0.0-20210419092856-009d1eebd624 github.com/wrouesnel/postgres_exporter v0.0.0-00010101000000-000000000000 @@ -48,8 +50,10 @@ require ( go.opentelemetry.io/collector v0.21.0 go.uber.org/atomic v1.7.0 go.uber.org/zap v1.16.0 - golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6 + golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 // indirect + golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 google.golang.org/grpc v1.37.0 + google.golang.org/protobuf v1.27.1 // indirect gopkg.in/alecthomas/kingpin.v2 v2.2.6 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b diff --git a/go.sum b/go.sum index eecfb46b60ad..f754687df1a0 100644 --- a/go.sum +++ b/go.sum @@ -163,6 +163,8 @@ github.com/Shopify/sarama v1.28.0 h1:lOi3SfE6OcFlW9Trgtked2aHNZ2BIG/d6Do+PEUAqqM github.com/Shopify/sarama v1.28.0/go.mod h1:j/2xTrU39dlzBmsxF1eQ2/DdWrxyBCl6pzz7a81o/ZY= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/Songmu/retry v0.1.0 h1:hPA5xybQsksLR/ry/+t/7cFajPW+dqjmjhzZhioBILA= +github.com/Songmu/retry v0.1.0/go.mod h1:7sXIW7eseB9fq0FUvigRcQMVLR9tuHI0Scok+rkpAuA= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f h1:5ZfJxyXo8KyX8DgGXC5B7ILL8y51fci/qYz2B4j8iLY= github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= @@ -732,12 +734,15 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-github/v25 v25.1.3/go.mod h1:6z5pC69qHtrPJ0sXPsj4BLnd82b+r6sLB7qcBoRZqpw= github.com/google/go-github/v32 v32.1.0/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI= github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -905,7 +910,10 @@ github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v0.0.0-20170202080759-03c5bf6be031/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw= +github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -1127,6 +1135,8 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.0-20191113090002-7c0f6868bffe/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E= @@ -1137,6 +1147,8 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= +github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -1181,6 +1193,8 @@ github.com/minio/minio-go/v7 v7.0.10/go.mod h1:td4gW1ldOsj1PbSNS+WYK43j+P1XVhX/8 github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/mitchellh/copystructure v0.0.0-20160804032330-cdac8253d00f/go.mod h1:eOsF2yLPlBBJPvD+nhl5QMTBSOBbOph6N7j/IDUw7PY= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= @@ -1192,7 +1206,10 @@ github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdI github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= +github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= +github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -1281,6 +1298,7 @@ github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGV github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= @@ -1603,6 +1621,12 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62/go.mod h1:qUzPVlSj2UgxJkVbH0ZwuuiR46U8RBMDT5KLY78Ifpw= +github.com/tcnksm/ghr v0.14.0 h1:3iCanOmn2xDgLnbbTy3ifzHiJ8/gCzYv6K5YWW+1P1s= +github.com/tcnksm/ghr v0.14.0/go.mod h1:6FdZv7a1yCKqJGwA4srq5ZtqGzEUnSCtRQOfGuuzSd4= +github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPgXBPw= +github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE= +github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e h1:IWllFTiDjjLIf2oeKxpIUmtiDV5sn71VgeQgg6vcE7k= +github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM= github.com/tedsuo/ifrit v0.0.0-20191009134036-9a97d0632f00/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0= github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= github.com/thanos-io/thanos v0.8.1-0.20200109203923-552ffa4c1a0d/go.mod h1:usT/TxtJQ7DzinTt+G9kinDQmRS5sxwu0unVKZ9vdcw= @@ -1916,6 +1940,8 @@ golang.org/x/net v0.0.0-20210324051636-2c4c8ecb7826/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210505214959-0714010a04ed h1:V9kAVxLvz1lkufatrpHuUVyJ/5tR3Ms7rk951P4mI98= golang.org/x/net v0.0.0-20210505214959-0714010a04ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20170807180024-9a379c6b3e95/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1934,6 +1960,9 @@ golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c h1:SgVl/sCtkicsS7psKkje4H9YtjdEl3xsYh7N+5TDHqY= golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 h1:3B43BWw0xEBsLZ/NO1VALz6fppU3481pik+2Ksv45z8= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2055,6 +2084,9 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210503080704-8803ae5d1324/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6 h1:cdsMqa2nXzqlgs183pHxtvoVwU7CyzaCTAUOg94af4c= golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= @@ -2315,6 +2347,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/go_wrapper.sh b/go_wrapper.sh index 7d1f97843b1a..64c9de708140 100755 --- a/go_wrapper.sh +++ b/go_wrapper.sh @@ -142,4 +142,6 @@ configure_windows() { exit 1 esac } -main "$@" +main +echo $CC + diff --git a/packaging/windows/LICENSE b/packaging/windows/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/packaging/windows/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id b/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id new file mode 100644 index 000000000000..3f295ba4fb92 --- /dev/null +++ b/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id @@ -0,0 +1 @@ +d6eae2127554e81c48d69fcd4cbad8952bb2bb43 \ No newline at end of file diff --git a/test.sh b/test.sh new file mode 100644 index 000000000000..7f003f966042 --- /dev/null +++ b/test.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if [ ${BUILD_IN_CONTAINER} = "false" ] +then + echo true +else + echo false +fi \ No newline at end of file diff --git a/tools/test-packages b/tools/test-packages index 503b90670ce8..f9570572320e 100755 --- a/tools/test-packages +++ b/tools/test-packages @@ -6,6 +6,7 @@ readonly IMAGE_PREFIX=$1 readonly VERSION=$2 readonly RELEASE=$3 readonly DISABLE_CLEANUP=${DISABLE_CLEANUP:-0} +readonly DRONE=${DRONE:-"false"} readonly GID=${GID:-$(id -g)} @@ -21,7 +22,10 @@ function cleanup() { fi } -trap cleanup EXIT +if [[ "${DRONE}" = "false" ]]; +then + trap cleanup EXIT +fi function test_with_systemd() { local -r image=$1 @@ -39,6 +43,11 @@ function test_with_systemd() { docker exec -i "${container}" /bin/bash -c "${remove_command}" } - -test_with_systemd "${IMAGE_PREFIX}"/centos-systemd "rpm -i /dist/grafana-agent-${VERSION}-${RELEASE}.amd64.rpm" "rpm -e grafana-agent" -test_with_systemd "${IMAGE_PREFIX}"/debian-systemd "dpkg -i /dist/grafana-agent-${VERSION}-${RELEASE}.amd64.deb" "dpkg -r grafana-agent" +if [[ "${DRONE}" = "true" ]]; +then + echo "In drone not running grafana agent tests" + exit 0 +else + test_with_systemd "${IMAGE_PREFIX}"/centos-systemd "rpm -i /dist/grafana-agent-${VERSION}-${RELEASE}.amd64.rpm" "rpm -e grafana-agent" + test_with_systemd "${IMAGE_PREFIX}"/debian-systemd "dpkg -i /dist/grafana-agent-${VERSION}-${RELEASE}.amd64.deb" "dpkg -r grafana-agent" +fi \ No newline at end of file From cb56cfa3510653d543c7eef75c13effe14442655 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Fri, 2 Jul 2021 09:31:53 -0400 Subject: [PATCH 017/101] Remove invalid files Former-commit-id: 7426669328b02626ff099a2e45a3f78b62a173dc --- .drone/Dockerfile | 102 --------- .drone/packages.list | 28 --- packaging/windows/LICENSE | 202 ------------------ .../agent-windows-amd64.exe.REMOVED.git-id | 1 - test.sh | 8 - 5 files changed, 341 deletions(-) delete mode 100644 .drone/Dockerfile delete mode 100644 .drone/packages.list delete mode 100644 packaging/windows/LICENSE delete mode 100644 packaging/windows/agent-windows-amd64.exe.REMOVED.git-id delete mode 100644 test.sh diff --git a/.drone/Dockerfile b/.drone/Dockerfile deleted file mode 100644 index fa5f492573f9..000000000000 --- a/.drone/Dockerfile +++ /dev/null @@ -1,102 +0,0 @@ -FROM ubuntu -COPY ./packages.list /packages.list -ARG DEBIAN_FRONTEND=noninteractive -RUN dpkg --add-architecture i386 -RUN apt-get update -y && apt-get install -y $(grep -vE "^\s*#" /packages.list | tr "\n" " ") -y -RUN gem install --no-document fpm -RUN mkdir -p /usr/local/go/bin -RUN wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz -RUN tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz -RUN rm go1.16.5.linux-amd64.tar.gz -ENV PATH=$PATH:/usr/local/go/bin -RUN apt-get clean && rm -rf /var/lib/apt/lists/* -RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg -RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null -RUN apt-get update -RUN apt-get install -y docker-ce docker-ce-cli containerd.io -ARG OSXCROSS_SDK_URL -ENV OSXCROSS_PATH=/usr/osxcross \ - OSXCROSS_REV=035cc170338b7b252e3f13b0e3ccbf4411bffc41 \ - SDK_VERSION=11.1 -RUN mkdir -p /tmp/osxcross && cd /tmp/osxcross \ - && curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" \ - | tar -C /tmp/osxcross --strip=1 -xzf - \ - && curl -sSLo tarballs/MacOSX${SDK_VERSION}.sdk.tar.xz ${OSXCROSS_SDK_URL} \ - && UNATTENDED=yes ./build.sh \ - && mv target "${OSXCROSS_PATH}" \ - && rm -rf /tmp/osxcross "/usr/osxcross/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man" -RUN dpkg --add-architecture amd64 \ - && dpkg --add-architecture i386 \ - && dpkg --add-architecture armel \ - && dpkg --add-architecture armhf \ - && dpkg --add-architecture arm64 \ - && dpkg --add-architecture mips \ - && dpkg --add-architecture mipsel \ - && dpkg --add-architecture powerpc \ - && dpkg --add-architecture ppc64el \ - && dpkg --add-architecture s390x \ - && apt-get update \ - && apt-get install -yq \ - binfmt-support \ - binutils-multiarch \ - binutils-multiarch-dev \ - build-essential \ - bzr \ - clang \ - crossbuild-essential-arm64 \ - crossbuild-essential-armel \ - crossbuild-essential-armhf \ - crossbuild-essential-mipsel \ - crossbuild-essential-powerpc \ - crossbuild-essential-ppc64el \ - crossbuild-essential-s390x \ - curl \ - git \ - git-core \ - libssl-dev \ - llvm \ - mercurial \ - mingw-w64 \ - openssl \ - patch \ - qemu-user-static \ - software-properties-common \ - subversion \ - sudo \ - wget \ - xz-utils \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -# Backports repo required to get a libsystemd version 246 or newer which is required to handle journal +ZSTD compression -RUN echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list -RUN apt-get update \ - && apt-get install -t buster-backports -qy libsystemd-dev \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -# -# OSX -# - -ENV OSXCROSS_PATH=/usr/osxcross -COPY --from=osxcross $OSXCROSS_PATH $OSXCROSS_PATH -ENV PATH $OSXCROSS_PATH/bin:$PATH - - -# -# FreeBSD -# - -COPY assets/freebsd-amd64-11.3.tar.xz /usr/freebsd/freebsd-amd64.tar.xz -COPY assets/freebsd-i386-11.3.tar.xz /usr/freebsd/freebsd-i386.tar.xz - -RUN mkdir /usr/freebsd/x86_64-pc-freebsd11 \ - && cd /usr/freebsd/x86_64-pc-freebsd11 \ - && tar -xf /usr/freebsd/freebsd-amd64.tar.xz ./lib ./usr/lib ./usr/include \ - && rm /usr/freebsd/freebsd-amd64.tar.xz \ - \ - && mkdir /usr/freebsd/i386-pc-freebsd11 \ - && cd /usr/freebsd/i386-pc-freebsd11 \ - && tar -xf /usr/freebsd/freebsd-i386.tar.xz ./lib ./usr/lib ./usr/include \ - && rm /usr/freebsd/freebsd-i386.tar.xz - -CMD ["bash"] \ No newline at end of file diff --git a/.drone/packages.list b/.drone/packages.list deleted file mode 100644 index 3ff0ff0acd1a..000000000000 --- a/.drone/packages.list +++ /dev/null @@ -1,28 +0,0 @@ -apt-transport-https -build-essential -bzr -ca-certificates -clang -cmake -curl -g++ -gcc -gcc-multilib -git -gnupg -libc6-dev -libc6-dev-i386 -libsnmp-dev -libsystemd-dev -libxml2-dev -linux-libc-dev:i386 mingw-w64 -lsb-release -make -nsis -patch -rpm -ruby -ruby-dev -rubygems -wget -xz-utils \ No newline at end of file diff --git a/packaging/windows/LICENSE b/packaging/windows/LICENSE deleted file mode 100644 index d64569567334..000000000000 --- a/packaging/windows/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id b/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id deleted file mode 100644 index 3f295ba4fb92..000000000000 --- a/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -d6eae2127554e81c48d69fcd4cbad8952bb2bb43 \ No newline at end of file diff --git a/test.sh b/test.sh deleted file mode 100644 index 7f003f966042..000000000000 --- a/test.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if [ ${BUILD_IN_CONTAINER} = "false" ] -then - echo true -else - echo false -fi \ No newline at end of file From df55cc232255af6172216a361067595e8409e031 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Fri, 2 Jul 2021 10:08:46 -0400 Subject: [PATCH 018/101] Fix freebsd build Former-commit-id: 8f1fc6460b20fc1e6871ad413006f51d4f6a4b4a --- .drone/drone.yml | 4 ++-- Makefile | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 290f925bb617..9b933221fb72 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -20,7 +20,7 @@ platform: arch: amd64 steps: -- name: test-ubuntu +- name: distribute image: rfratto/seego commands: - apt-get update && apt-get install -y rubygems rpm nsis @@ -30,7 +30,7 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist/agent-freebsd-amd64 + - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist --- kind: pipeline type: docker diff --git a/Makefile b/Makefile index b5a12fbe6189..6b5736c86482 100644 --- a/Makefile +++ b/Makefile @@ -208,8 +208,8 @@ dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe cp dist/agent-windows-amd64.exe ./packaging/windows cp LICENSE ./packaging/windows makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis -dist/agent-freebsd-amd64: - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS='-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11' ; go build $(CGO_FLAGS) -o $@ ./cmd/agent +dist/agent-freebsd-amd64: + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agent dist-agentctl: dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 dist/agentctl-linux-amd64: @@ -229,7 +229,7 @@ dist/agentctl-darwin-arm64: dist/agentctl-windows-amd64.exe: export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-freebsd-amd64: - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11"; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl build-image/.uptodate: build-image/Dockerfile From 9a79616f40934e4cbd70c48747ee1bb17311c956 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Wed, 7 Jul 2021 09:46:51 -0400 Subject: [PATCH 019/101] Setting up tokens Former-commit-id: 246be580844cd0c7dd9c2ef634723329537bf559 --- .drone/drone.yml | 18 +- go.mod | 2 +- go.sum | 2 + packaging/windows/LICENSE | 202 ++++++++++++++++++ .../agent-windows-amd64.exe.REMOVED.git-id | 1 + 5 files changed, 221 insertions(+), 4 deletions(-) create mode 100644 packaging/windows/LICENSE create mode 100644 packaging/windows/agent-windows-amd64.exe.REMOVED.git-id diff --git a/.drone/drone.yml b/.drone/drone.yml index 9b933221fb72..c1b1113bee4a 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -41,21 +41,33 @@ platform: trigger: event: - tag + steps: - name: create-release - image: agentbuild - pull: if-not-exists + image: rfratto/seego commands: + - apt-get update && apt-get install -y rubygems rpm nsis + - gem install --no-document fpm + - mkdir -p /usr/local/go/bin + - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz + - rm go1.16.5.linux-amd64.tar.gz + - export PATH=$PATH:/usr/local/go/bin - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - export PATH="$(go env GOPATH)/bin:$PATH" - export RELEASE_TAG=${GITHUB_REF##*/} - make -j4 RELEASE_BUILD=true publish - name: publish image: plugins/github-release + environment: + GITHUB_KEY: + from_secret: GITHUB_KEY settings: - api_key: xxxxxxxx + api_key: ${GITHUB_KEY} files: /drone/src/dist/* draft: true + when: + event: tag --- kind: pipeline type: docker diff --git a/go.mod b/go.mod index f1e61a7a87f8..3b6f1af2341d 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( go.uber.org/atomic v1.7.0 go.uber.org/zap v1.16.0 golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 // indirect - golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 + golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c google.golang.org/grpc v1.37.0 google.golang.org/protobuf v1.27.1 // indirect gopkg.in/alecthomas/kingpin.v2 v2.2.6 diff --git a/go.sum b/go.sum index f754687df1a0..793af810db09 100644 --- a/go.sum +++ b/go.sum @@ -2087,6 +2087,8 @@ golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= diff --git a/packaging/windows/LICENSE b/packaging/windows/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/packaging/windows/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id b/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id new file mode 100644 index 000000000000..0eb11b823a19 --- /dev/null +++ b/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id @@ -0,0 +1 @@ +41dee7ab87325a204cb63b8d501895830b8d279d \ No newline at end of file From 1f7a85d7912079976d43de1051f771bb7da55f0b Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Wed, 7 Jul 2021 09:48:15 -0400 Subject: [PATCH 020/101] Removing windows build output Former-commit-id: 241d9bb324481b374c89d58e5654905e72198e07 --- .gitignore | 2 + packaging/windows/LICENSE | 202 ------------------ .../agent-windows-amd64.exe.REMOVED.git-id | 1 - 3 files changed, 2 insertions(+), 203 deletions(-) delete mode 100644 packaging/windows/LICENSE delete mode 100644 packaging/windows/agent-windows-amd64.exe.REMOVED.git-id diff --git a/.gitignore b/.gitignore index ab3343dec5e7..9db930a9cfd8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,7 @@ cover*.out cmd/agent/agent cmd/agentctl/agentctl dist/ +packaging/windows/LICENSE +packaging/windows/agent-windows-amd64.exe .DS_Store diff --git a/packaging/windows/LICENSE b/packaging/windows/LICENSE deleted file mode 100644 index d64569567334..000000000000 --- a/packaging/windows/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id b/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id deleted file mode 100644 index 0eb11b823a19..000000000000 --- a/packaging/windows/agent-windows-amd64.exe.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -41dee7ab87325a204cb63b8d501895830b8d279d \ No newline at end of file From e22211c39b84b249bf4e8f279055964c32322e3c Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Wed, 7 Jul 2021 12:33:54 -0400 Subject: [PATCH 021/101] Fix for docker builds Former-commit-id: 3babea61aec31d49fa8829abac2f6870fbf4f872 --- .drone/drone.yml | 22 +++-- Makefile | 42 +++++++--- Release.key | 0 cmd/agent/Dockerfile.buildx | 2 +- tools/cross_build.bash | 46 ----------- tools/seego/go_wrapper.sh | 161 ------------------------------------ 6 files changed, 46 insertions(+), 227 deletions(-) create mode 100644 Release.key delete mode 100755 tools/cross_build.bash delete mode 100644 tools/seego/go_wrapper.sh diff --git a/.drone/drone.yml b/.drone/drone.yml index c1b1113bee4a..49a6803f3986 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -71,23 +71,29 @@ steps: --- kind: pipeline type: docker -name: Containerize2 +name: ContainerizeNoDocker steps: -- name: Build Agent Containers - image: ubuntu +- name: Build Artifacts + image: rfratto/seego commands: - - export DEBIAN_FRONTEND=noninteractive - - dpkg --add-architecture i386 - - apt-get update -y && apt-get install -y $(grep -vE "^\s*#" ./.drone/packages.list | tr "\n" " ") -y + - apt-get update && apt-get install -y rubygems rpm nsis - gem install --no-document fpm - mkdir -p /usr/local/go/bin - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make agent - - CGO_ENABLED=1 GOOS=linux GOARCH=arm64 make agent + - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr + - export PATH="$(go env GOPATH)/bin:$PATH" + - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist-agent + - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist-agentctl +- name: Package Agent Containers + image: centos + commands: + - yum -y install buildah make + - make agent-image + - make agentctl-image --- diff --git a/Makefile b/Makefile index 6b5736c86482..e463bf9a1f2f 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ SHELL = /usr/bin/env bash # Docker image info IMAGE_PREFIX ?= grafana IMAGE_TAG ?= $(shell ./tools/image-tag) +TARGETPLATFORM ?= "" # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, @@ -113,19 +114,38 @@ all: protos agent agentctl agent: cmd/agent/agent agentctl: cmd/agentctl/agentctl -cmd/agent/agent: check-seego cmd/agent/main.go -ifeq ($(CROSS_BUILD),false) - CGO_ENABLED=1 go build $(CGO_FLAGS) -o $@ ./$(@D) -else - @CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) +cmd/agent/agent: cmd/agent/main.go + echo $(TARGETPLATFORM) + go clean -i net + go install -tags netgo std +ifeq ($(TARGETPLATFORM),) + export CGO_ENABLED=1 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),linux/amd64) + export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),'linux/arm64') + export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),' linux/arm/v7') + export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif $(NETGO_CHECK) -cmd/agentctl/agentctl: check-seego cmd/agentctl/main.go -ifeq ($(CROSS_BUILD),false) - CGO_ENABLED=1 go build $(CGO_FLAGS) -o $@ ./$(@D) -else - @CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) +cmd/agentctl/agentctl: cmd/agentctl/main.go + go clean -i net + go install -tags netgo std +ifeq ($(TARGETPLATFORM),'') + export CGO_ENABLED=1 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),'linux/amd64') + export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),'linux/arm64') + export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),' linux/arm/v7') + export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif $(NETGO_CHECK) @@ -197,7 +217,7 @@ dist/agent-linux-armv6: dist/agent-linux-armv7: export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-mipsle: - @CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++;go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++;go build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-darwin-amd64: export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-darwin-arm64: diff --git a/Release.key b/Release.key new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/cmd/agent/Dockerfile.buildx b/cmd/agent/Dockerfile.buildx index 4500a2446c16..3aef03e123d8 100644 --- a/cmd/agent/Dockerfile.buildx +++ b/cmd/agent/Dockerfile.buildx @@ -20,7 +20,7 @@ ARG IMAGE_TAG # Rename seego's /go_wrapper.sh to /seego.sh for readability in the # Makefile. RUN cp /go_wrapper.sh /seego.sh -RUN make clean && IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false bash ./tools/cross_build.bash agent +RUN IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false make agent FROM debian:buster-slim diff --git a/tools/cross_build.bash b/tools/cross_build.bash deleted file mode 100755 index 30dd753100a8..000000000000 --- a/tools/cross_build.bash +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash -# -# cross_build.bash will set appropriate GOOS/GOARCH values given a TARGETPLATFORM -# variable. TARGETPLATFORM will accept values populated by docker buildx. -# -# $BUILDPLATFORM must be linux/amd64. -# -# Only the following values for $TARGETPLATFORM are supported: -# linux/amd64 -# linux/arm64 -# linux/arm/v7 - -main() { - target=$1 - - if [[ "$target" == "" ]]; then - echo ">>> usage: cross_build.bash [makefile target]" - exit 1 - fi - - if [[ "$BUILDPLATFORM" != "linux/amd64" ]]; then - echo ">>> ERROR: BUILDPLATFORM must be linux/amd64, got $BUILDPLATFORM" - exit 1 - fi - - case "$TARGETPLATFORM" in - linux/amd64) native_build $target ;; - linux/arm64) seego_build $target arm64 ;; - linux/arm/v6) seego_build $target arm 6 ;; - linux/arm/v7) seego_build $target arm 7 ;; - *) - echo ">>> ERROR: unsupported TARGETPLATFORM value $TARGETPLATFORM" - exit 1 - esac -} - -native_build() { - CROSS_BUILD=false make $1 -} - -seego_build() { - echo ">>> building $1 for $2" - CROSS_BUILD=true CGO_ENABLED=1 GOOS=linux GOARCH=$2 GOARM=$3 make $1 -} - -main $1 diff --git a/tools/seego/go_wrapper.sh b/tools/seego/go_wrapper.sh deleted file mode 100644 index a2cdcf8bf2a6..000000000000 --- a/tools/seego/go_wrapper.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash - -FOUND_CC="" -FOUND_CXX="" -FOUND_LD_PATH="" -CC_EXTRA="" -CXX_EXTRA="" - -CGO_ENABLED=${CGO_ENABLED:-$(go env CGO_ENABLED)} -GOARCH=$(go env GOARCH) -GOOS=$(go env GOOS) -GOARM=$(go env GOARM) - -main() { - echo ">>> discovering toolchain for GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM}" - - case "$GOOS" in - linux) configure_linux ;; - darwin) configure_darwin ;; - freebsd) configure_bsd ;; - windows) configure_windows ;; - *) - echo ">>> ERROR: unsupported GOOS value $GOOS" - exit 1 - esac - - echo ">>> discovered CC ${FOUND_CC}" - echo ">>> discovered CXX ${FOUND_CXX}" - echo ">>> extra C flags: ${CC_EXTRA}" - - echo ">>> CGO_ENABLED=${CGO_ENABLED} CC=$FOUND_CC CXX=$FOUND_CXX go $@" - - # If we run go directly, any files created on the bind mount - # will have awkward ownership. So we switch to a user with the - # same user and group IDs as source directory. We have to set a - # few things up so that sudo works without complaining later on. - uid=$(stat --format="%u" $(pwd)) - gid=$(stat --format="%g" $(pwd)) - echo "seego:x:$uid:$gid::$(pwd):/bin/bash" >>/etc/passwd - echo "seego:*:::::::" >>/etc/shadow - echo "seego ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers - - # I'm skeptical that this is the best way to do it because it's so - # annoying, but it works at least. - # - # Export environment variables we want to retain when running go - # as the new user. Even though we preserve the path, we have to use - # the full path to go since sudo won't read the PATH for it. - - export CC="$FOUND_CC $CC_EXTRA" - export CXX="$FOUND_CXX $CC_EXTRA" - - export CGO_CFLAGS=$CC_EXTRA - export CGO_CXX_CFLAGS=$CC_EXTRA - export CGO_LDFLAGS=$CC_EXTRA - - export PATH=$PATH - if [ ! -z "$FOUND_LD_PATH" ]; then - export LD_LIBRARY_PATH="$FOUND_LD_PATH:$LD_LIBRARY_PATH" - fi - - export GOCACHE=$(pwd)/.cache - - exec sudo -E \ - --preserve-env=PATH \ - --preserve-env=LD_LIBRARY_PATH \ - -u seego -- $(which go) "$@" -} - -configure_linux() { - toolchain_prefix="" - - case "$GOARCH" in - # Do nothing for native archs - amd64 | 386) ;; - - arm) toolchain_prefix="arm-linux-gnueabi-" ;; - arm64) toolchain_prefix="aarch64-linux-gnu-" ;; - - ppc64) toolchain_prefix="powerpc-linux-gnu-" ;; - ppc64le) toolchain_prefix="powerpc64le-linux-gnu-" ;; - - mips) toolchain_prefix="mips-linux-gnu-" ;; - mipsle) toolchain_prefix="mipsel-linux-gnu-" ;; - mips64) toolchain_prefix="mips64-linux-gnuabi64-" ;; - mips64le) toolchain_prefix="mips64el-linux-gnuabi64-" ;; - - s390x) toolchain_prefix="s390x-linux-gnu-" ;; - - *) - echo ">>> ERROR: unsupported linux GOARCH value $GOARCH" - echo ">>> supported values: amd64, 386, arm, arm64, ppc64, ppc64le, mips, mipsle, mips64, mips64le, s390x" - exit 1 - esac - - if [ "$GOARCH" == "arm" ] && [ "$GOARM" == "7" ]; then - toolchain_prefix="arm-linux-gnueabihf-" - fi - - FOUND_CC="${toolchain_prefix}gcc" - FOUND_CXX="${toolchain_prefix}g++" -} - -configure_darwin() { - case "$GOARCH" in - amd64) - FOUND_CC="x86_64-apple-darwin20.2-clang" - FOUND_CXX="x86_64-apple-darwin20.2-clang++" - FOUND_LD_PATH="$OSXCROSS_PATH/lib" - ;; - arm64) - FOUND_CC="arm64-apple-darwin20.2-clang" - FOUND_CXX="arm64-apple-darwin20.2-clang++" - FOUND_LD_PATH="$OSXCROSS_PATH/lib" - ;; - *) - echo ">>> ERROR: unsupported darwin GOARCH value $GOARCH" - echo ">>> supported values: amd64, arm64" - exit 1 - esac -} - -configure_bsd() { - case "$GOARCH" in - amd64) - FOUND_CC="clang" - FOUND_CXX="clang++" - CC_EXTRA="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" - ;; - 386) - FOUND_CC="clang" - FOUND_CXX="clang++" - CC_EXTRA="-target i386-pc-freebsd11 --sysroot=/usr/freebsd/i386-pc-freebsd11 -v" - ;; - - *) - echo ">>> ERROR: unsupported bsd GOARCH value $GOARCH" - echo ">>> supported values: amd64, 386" - exit 1 - esac -} - -configure_windows() { - case "$GOARCH" in - 386) - FOUND_CC="i686-w64-mingw32-gcc" - FOUND_CXX="i686-w64-mingw32-g++" - ;; - amd64) - FOUND_CC="x86_64-w64-mingw32-gcc" - FOUND_CXX="x86_64-w64-mingw32-g++" - ;; - - *) - echo ">>> ERROR: unsupported windows GOARCH value $GOARCH" - echo ">>> supported values: 386, amd64" - exit 1 - esac -} -echo "!!!<<>>!!!" -main "$@" From 995732fd09de7957bc27f49afefa15c101b5d558 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Wed, 7 Jul 2021 15:01:40 -0400 Subject: [PATCH 022/101] Remove containerize no docker Former-commit-id: 90660b5ec713ff5a30015b331250eeb227bee71a --- .drone/drone.yml | 30 ------------------------------ Makefile | 5 ++--- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 49a6803f3986..6c09c9a0aafd 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -68,34 +68,6 @@ steps: draft: true when: event: tag ---- -kind: pipeline -type: docker -name: ContainerizeNoDocker - -steps: -- name: Build Artifacts - image: rfratto/seego - commands: - - apt-get update && apt-get install -y rubygems rpm nsis - - gem install --no-document fpm - - mkdir -p /usr/local/go/bin - - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - - rm go1.16.5.linux-amd64.tar.gz - - export PATH=$PATH:/usr/local/go/bin - - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - - export PATH="$(go env GOPATH)/bin:$PATH" - - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist-agent - - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist-agentctl -- name: Package Agent Containers - image: centos - commands: - - yum -y install buildah make - - make agent-image - - make agentctl-image - - --- kind: pipeline type: docker @@ -119,8 +91,6 @@ steps: - docker buildx create --use - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker buildx create --name multiarch --driver docker-container --use - - docker buildx inspect --bootstrap - - docker buildx ls - CROSS_BUILD=true RELEASE_BUILD=true make agent-image - name: Build Agentctl Container image: docker diff --git a/Makefile b/Makefile index e463bf9a1f2f..e07516a80da4 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ SHELL = /usr/bin/env bash # Docker image info IMAGE_PREFIX ?= grafana IMAGE_TAG ?= $(shell ./tools/image-tag) -TARGETPLATFORM ?= "" +TARGETPLATFORM ?= normal # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, @@ -52,7 +52,6 @@ GO_FLAGS = $(DEBUG_GO_FLAGS) endif NETGO_CHECK = @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ - rm $@; \ echo "\nYour go standard library was built without the 'netgo' build tag."; \ echo "To fix that, run"; \ echo " sudo go clean -i net"; \ @@ -118,7 +117,7 @@ cmd/agent/agent: cmd/agent/main.go echo $(TARGETPLATFORM) go clean -i net go install -tags netgo std -ifeq ($(TARGETPLATFORM),) +ifeq ($(TARGETPLATFORM),normal) export CGO_ENABLED=1 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/amd64) From 643bd8c3f809a92b04625a997f0a4fb8d8b15dc8 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Wed, 7 Jul 2021 15:18:33 -0400 Subject: [PATCH 023/101] Make buildx single threaded Former-commit-id: e1fa585bd9b565564e96374a6bfa5c788a97d51f --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e07516a80da4..270cb61031ee 100644 --- a/Makefile +++ b/Makefile @@ -149,10 +149,20 @@ endif $(NETGO_CHECK) agent-image: - $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + # We are separating these builds out to conserve memory + docker buildx build --push --platform linux/amd64 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + docker buildx build --push --platform linux/arm64 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + docker buildx build --push --platform linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + docker buildx build --push --platform linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . +#$(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . agentctl-image: - $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + docker buildx build --push --platform linux/amd64 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + docker buildx build --push --platform linux/arm64 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + docker buildx build --push --platform linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + docker buildx build --push --platform linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + +# $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . install: CGO_ENABLED=1 go install $(CGO_FLAGS) ./cmd/agent From 9a485d64508de677d807e0b679a9a8187d96cc42 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Wed, 7 Jul 2021 16:23:04 -0400 Subject: [PATCH 024/101] Building against personal docker account Former-commit-id: 83bb1cc53758aeed074deb0c099050f04de3f883 --- .drone/drone.yml | 23 ++++++++--------------- Makefile | 16 +++------------- cmd/agentctl/Dockerfile.buildx | 2 +- 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 6c09c9a0aafd..c203d0cdd1a7 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -63,7 +63,7 @@ steps: GITHUB_KEY: from_secret: GITHUB_KEY settings: - api_key: ${GITHUB_KEY} + api_key: $GITHUB_KEY files: /drone/src/dist/* draft: true when: @@ -77,12 +77,18 @@ platform: arch: amd64 steps: -- name: Build Agent Container +- name: Build Containers image: docker volumes: - name: docker path: /var/run/docker.sock + environment: + DOCKER_LOGIN: + from_secret: DOCKER_LOGIN + DOCKER_PASSWORD: + from_secret: DOCKER_PASSWORD commands: + - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - apk update && apk add make bash wget git qemu - wget https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 - mkdir -p ~/.docker/cli-plugins @@ -92,20 +98,7 @@ steps: - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker buildx create --name multiarch --driver docker-container --use - CROSS_BUILD=true RELEASE_BUILD=true make agent-image -- name: Build Agentctl Container - image: docker - volumes: - - name: docker - path: /var/run/docker.sock - commands: - - apk update && apk add make bash wget git qemu - - wget https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 - - mkdir -p ~/.docker/cli-plugins - - cp buildx-v0.5.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx - - chmod a+x ~/.docker/cli-plugins/docker-buildx - - docker buildx create --use - CROSS_BUILD=true RELEASE_BUILD=true make agentctl-image - volumes: - name: docker host: diff --git a/Makefile b/Makefile index 270cb61031ee..a970a460b758 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SHELL = /usr/bin/env bash ############# # Docker image info -IMAGE_PREFIX ?= grafana +IMAGE_PREFIX ?= mrdgrafana IMAGE_TAG ?= $(shell ./tools/image-tag) TARGETPLATFORM ?= normal @@ -149,20 +149,10 @@ endif $(NETGO_CHECK) agent-image: - # We are separating these builds out to conserve memory - docker buildx build --push --platform linux/amd64 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . - docker buildx build --push --platform linux/arm64 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . - docker buildx build --push --platform linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . - docker buildx build --push --platform linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . -#$(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . agentctl-image: - docker buildx build --push --platform linux/amd64 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . - docker buildx build --push --platform linux/arm64 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . - docker buildx build --push --platform linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . - docker buildx build --push --platform linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . - -# $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . install: CGO_ENABLED=1 go install $(CGO_FLAGS) ./cmd/agent diff --git a/cmd/agentctl/Dockerfile.buildx b/cmd/agentctl/Dockerfile.buildx index 0ec4a995a1a1..db63cdab195f 100644 --- a/cmd/agentctl/Dockerfile.buildx +++ b/cmd/agentctl/Dockerfile.buildx @@ -20,7 +20,7 @@ ARG IMAGE_TAG # Rename seego's /go_wrapper.sh to /seego.sh for readability in the # Makefile. RUN cp /go_wrapper.sh /seego.sh -RUN make clean && IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false bash ./tools/cross_build.bash agentctl +RUN IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false make agentctl FROM debian:buster-slim From a4ec0f4b6fe39f484f0cfd7c76ff543fec7b2730 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 10:33:41 -0400 Subject: [PATCH 025/101] Merge changes Former-commit-id: f6b8df968dacf358befe5745866db230c9a70be3 --- buildx-v0.5.1.linux-amd64.REMOVED.git-id | 1 + 1 file changed, 1 insertion(+) create mode 100644 buildx-v0.5.1.linux-amd64.REMOVED.git-id diff --git a/buildx-v0.5.1.linux-amd64.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.REMOVED.git-id new file mode 100644 index 000000000000..bdc808182bcb --- /dev/null +++ b/buildx-v0.5.1.linux-amd64.REMOVED.git-id @@ -0,0 +1 @@ +dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file From 656a89afc66498d0770dda067b899b3590f65fc1 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 10:34:07 -0400 Subject: [PATCH 026/101] Remove exe Former-commit-id: 79ce552eb13f3412795a5c250fe2949ad2278cd1 --- buildx-v0.5.1.linux-amd64.REMOVED.git-id | 1 - 1 file changed, 1 deletion(-) delete mode 100644 buildx-v0.5.1.linux-amd64.REMOVED.git-id diff --git a/buildx-v0.5.1.linux-amd64.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.REMOVED.git-id deleted file mode 100644 index bdc808182bcb..000000000000 --- a/buildx-v0.5.1.linux-amd64.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file From 71424e9d26740c2826a50a7eab0454d5bd0f47ab Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 12:54:43 -0400 Subject: [PATCH 027/101] Removed V6 temporarily to see if fixed Former-commit-id: e6c5680160d903ec8a5dfc8ab574bdf285a8acf0 --- .drone/drone.yml | 8 ++++-- Makefile | 51 +++++++++++++++++----------------- cmd/agent/Dockerfile.buildx | 4 +-- cmd/agentctl/Dockerfile.buildx | 4 +-- 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index c203d0cdd1a7..33d9589f52c0 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -76,6 +76,8 @@ platform: os: linux arch: amd64 +steps: + steps: - name: Build Containers image: docker @@ -94,11 +96,11 @@ steps: - mkdir -p ~/.docker/cli-plugins - cp buildx-v0.5.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx - chmod a+x ~/.docker/cli-plugins/docker-buildx - - docker buildx create --use - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker buildx create --name multiarch --driver docker-container --use - - CROSS_BUILD=true RELEASE_BUILD=true make agent-image - - CROSS_BUILD=true RELEASE_BUILD=true make agentctl-image + - make CROSS_BUILD=true RELEASE_BUILD=true agent-image + - make CROSS_BUILD=true RELEASE_BUILD=true agentctl-image + volumes: - name: docker host: diff --git a/Makefile b/Makefile index a970a460b758..e49848e057f6 100644 --- a/Makefile +++ b/Makefile @@ -78,8 +78,6 @@ docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx - -docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) endif ############# @@ -114,45 +112,46 @@ agent: cmd/agent/agent agentctl: cmd/agentctl/agentctl cmd/agent/agent: cmd/agent/main.go - echo $(TARGETPLATFORM) - go clean -i net - go install -tags netgo std + @echo $(TARGETPLATFORM) + @echo $(IMAGE_TAG) + @echo $(RELEASE_BUILD) ifeq ($(TARGETPLATFORM),normal) - export CGO_ENABLED=1 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/amd64) - export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build -x $(CGO_FLAGS) -o $@ ./$(@D) endif -ifeq ($(TARGETPLATFORM),'linux/arm64') - export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +ifeq ($(TARGETPLATFORM),linux/arm64) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build -x $(CGO_FLAGS) -o $@ ./$(@D) endif -ifeq ($(TARGETPLATFORM),' linux/arm/v7') - export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +ifeq ($(TARGETPLATFORM),linux/arm/v7) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build -x $(CGO_FLAGS) -o $@ ./$(@D) endif $(NETGO_CHECK) + cmd/agentctl/agentctl: cmd/agentctl/main.go - go clean -i net - go install -tags netgo std -ifeq ($(TARGETPLATFORM),'') - export CGO_ENABLED=1 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) + @echo $(TARGETPLATFORM) +ifeq ($(TARGETPLATFORM),normal) + export CGO_ENABLED=1 GO111MODULE=auto ; go build $(CGO_FLAGS) -o $@ ./$(@D) endif -ifeq ($(TARGETPLATFORM),'linux/amd64') - export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) +ifeq ($(TARGETPLATFORM),linux/amd64) + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) endif -ifeq ($(TARGETPLATFORM),'linux/arm64') - export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +ifeq ($(TARGETPLATFORM),linux/arm64) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif -ifeq ($(TARGETPLATFORM),' linux/arm/v7') - export CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +ifeq ($(TARGETPLATFORM),linux/arm/v7) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif $(NETGO_CHECK) -agent-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . +agent-image: +# docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . -agentctl-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . +agentctl-image: + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . install: CGO_ENABLED=1 go install $(CGO_FLAGS) ./cmd/agent @@ -172,7 +171,7 @@ test: CGO_ENABLED=1 go test $(CGO_FLAGS) -cover -coverprofile=cover-norace.out -p=4 ./pkg/integrations/node_exporter ./pkg/loki clean: - rm -rf cmd/agent/agent + rm -r -f cmd/agent/agent go clean ./... example-kubernetes: diff --git a/cmd/agent/Dockerfile.buildx b/cmd/agent/Dockerfile.buildx index 3aef03e123d8..378589b876cf 100644 --- a/cmd/agent/Dockerfile.buildx +++ b/cmd/agent/Dockerfile.buildx @@ -19,8 +19,8 @@ ARG IMAGE_TAG # Rename seego's /go_wrapper.sh to /seego.sh for readability in the # Makefile. -RUN cp /go_wrapper.sh /seego.sh -RUN IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false make agent +# RUN cp /go_wrapper.sh /seego.sh +RUN make clean && IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false make agent FROM debian:buster-slim diff --git a/cmd/agentctl/Dockerfile.buildx b/cmd/agentctl/Dockerfile.buildx index db63cdab195f..0785afbc7b40 100644 --- a/cmd/agentctl/Dockerfile.buildx +++ b/cmd/agentctl/Dockerfile.buildx @@ -19,8 +19,8 @@ ARG IMAGE_TAG # Rename seego's /go_wrapper.sh to /seego.sh for readability in the # Makefile. -RUN cp /go_wrapper.sh /seego.sh -RUN IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false make agentctl +# RUN cp /go_wrapper.sh /seego.sh +RUN make clean && IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false make agentctl FROM debian:buster-slim From f3cc2bc43f444f90f245a4ff5b4e23f942ce39b4 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 12:59:31 -0400 Subject: [PATCH 028/101] Removed extra steps Former-commit-id: cb89f556fb2524314acdb5131e3ef7e50421beb3 --- .drone/drone.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 33d9589f52c0..bb3c1dc8bcbc 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -76,8 +76,6 @@ platform: os: linux arch: amd64 -steps: - steps: - name: Build Containers image: docker From 397ab83771b48a9c41d9e5c5df9bcee7ebf4122b Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 13:06:37 -0400 Subject: [PATCH 029/101] Signed yaml Former-commit-id: e2665dd5f6088ddc4b2fe25d6a171d908d15f386 --- .drone/drone.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.drone/drone.yml b/.drone/drone.yml index bb3c1dc8bcbc..21a895c3dd26 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -103,3 +103,8 @@ volumes: - name: docker host: path: /var/run/docker.sock +--- +kind: signature +hmac: 8e141e59f309da21fc0bdde1f22584c5eca64533f8924290e8f11e3c899aa7bb + +... From 07531e3359c20c539a0e287bc83bef0ec04e75d2 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 13:27:49 -0400 Subject: [PATCH 030/101] Fix makefile Former-commit-id: 6bfcc9d7a43f65dd680607c9f7f2e3283742a49f --- Makefile | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index e49848e057f6..acd285736e76 100644 --- a/Makefile +++ b/Makefile @@ -119,13 +119,16 @@ ifeq ($(TARGETPLATFORM),normal) export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/amd64) - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build -x $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/arm64) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build -x $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/arm/v7) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build -x $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),linux/arm/v6) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif $(NETGO_CHECK) @@ -136,22 +139,24 @@ ifeq ($(TARGETPLATFORM),normal) export CGO_ENABLED=1 GO111MODULE=auto ; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/amd64) - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/arm64) export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/arm/v7) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),linux/arm/v6) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif $(NETGO_CHECK) agent-image: -# docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . agentctl-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . install: CGO_ENABLED=1 go install $(CGO_FLAGS) ./cmd/agent From 6c4858115ce54edf0c0220942019f9d1510f728c Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 15:37:29 -0400 Subject: [PATCH 031/101] Fix tag Former-commit-id: 9ac229798f14c41d97e6c8cee1170eca12b1d024 --- .drone/drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 21a895c3dd26..3a7183e32a91 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -55,7 +55,7 @@ steps: - export PATH=$PATH:/usr/local/go/bin - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - export PATH="$(go env GOPATH)/bin:$PATH" - - export RELEASE_TAG=${GITHUB_REF##*/} + - export RELEASE_TAG=$(git describe --tags --abbrev=0 ) - make -j4 RELEASE_BUILD=true publish - name: publish image: plugins/github-release @@ -105,6 +105,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 8e141e59f309da21fc0bdde1f22584c5eca64533f8924290e8f11e3c899aa7bb +hmac: 33e9ee03301467379a6b691425252e8a7ad68124cacb8c66ca1cbb71d4051539 ... From d8d8e175559feb4166fb3fae00300579dcbf2607 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 16:07:09 -0400 Subject: [PATCH 032/101] Using drone tag Former-commit-id: 475d8cdf4e9a35c4813d489d1c212cd19db5ab48 --- .drone/drone.yml | 9 +++++---- Makefile | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 3a7183e32a91..9d88c7f11438 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -55,7 +55,8 @@ steps: - export PATH=$PATH:/usr/local/go/bin - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - export PATH="$(go env GOPATH)/bin:$PATH" - - export RELEASE_TAG=$(git describe --tags --abbrev=0 ) + - RELEASE_TAG=$DRONE_TAG + - echo $RELEASE_TAG - make -j4 RELEASE_BUILD=true publish - name: publish image: plugins/github-release @@ -66,8 +67,8 @@ steps: api_key: $GITHUB_KEY files: /drone/src/dist/* draft: true - when: - event: tag +# when: +# event: tag --- kind: pipeline type: docker @@ -105,6 +106,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 33e9ee03301467379a6b691425252e8a7ad68124cacb8c66ca1cbb71d4051539 +hmac: 0e3d4f13065b357b85560fc55af20da8ab27400201dcca471609c4fecc52e7a1 ... diff --git a/Makefile b/Makefile index acd285736e76..6f0b130b74a6 100644 --- a/Makefile +++ b/Makefile @@ -371,5 +371,4 @@ clean-dist: rm -rf dist .PHONY: clean -publish: dist - ./tools/release \ No newline at end of file +publish: dist \ No newline at end of file From fffbf3a3590be8cb2f1a37ca006025d16d207138 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 16:27:30 -0400 Subject: [PATCH 033/101] Fix drone tag Former-commit-id: 4d7029eba80d93d216437aa29ec9b529da77c5a3 --- .drone/drone.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 9d88c7f11438..fa50dc8549d6 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -26,7 +26,7 @@ steps: - apt-get update && apt-get install -y rubygems rpm nsis - gem install --no-document fpm - mkdir -p /usr/local/go/bin - - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz + - wget -q https://golang.org/dl/go1.16.5.linux-amd64.tar.gz - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin @@ -49,15 +49,14 @@ steps: - apt-get update && apt-get install -y rubygems rpm nsis - gem install --no-document fpm - mkdir -p /usr/local/go/bin - - wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz + - wget -q https://golang.org/dl/go1.16.5.linux-amd64.tar.gz - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - export PATH="$(go env GOPATH)/bin:$PATH" - RELEASE_TAG=$DRONE_TAG - - echo $RELEASE_TAG - - make -j4 RELEASE_BUILD=true publish + - make -j4 RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish - name: publish image: plugins/github-release environment: @@ -67,8 +66,8 @@ steps: api_key: $GITHUB_KEY files: /drone/src/dist/* draft: true -# when: -# event: tag + when: + event: tag --- kind: pipeline type: docker @@ -91,7 +90,7 @@ steps: commands: - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - apk update && apk add make bash wget git qemu - - wget https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 + - wget -q https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 - mkdir -p ~/.docker/cli-plugins - cp buildx-v0.5.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx - chmod a+x ~/.docker/cli-plugins/docker-buildx @@ -106,6 +105,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 0e3d4f13065b357b85560fc55af20da8ab27400201dcca471609c4fecc52e7a1 +hmac: b4522c5f605b42a625c3f4ddd9938688459dd16ed0adc3f3abf1a40f3574afd2 ... From 014ffb2dfdf1bdc044bfcae0b3a32d2a7335bf5d Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 16:52:20 -0400 Subject: [PATCH 034/101] Fix drone issues Former-commit-id: bbb95ba0e61160a73c5a3673f497e55215ba9947 --- .drone/drone.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index fa50dc8549d6..4cb97a36774a 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -46,7 +46,10 @@ steps: - name: create-release image: rfratto/seego commands: - - apt-get update && apt-get install -y rubygems rpm nsis + - apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release + - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - + - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" + - apt-get update && apt-get install -y rubygems rpm nsis docker-ce docker-ce-cli containerd.io - gem install --no-document fpm - mkdir -p /usr/local/go/bin - wget -q https://golang.org/dl/go1.16.5.linux-amd64.tar.gz @@ -105,6 +108,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: b4522c5f605b42a625c3f4ddd9938688459dd16ed0adc3f3abf1a40f3574afd2 +hmac: f384e403811e1770a22ef62a071d2679967c207a81202783389c8a3d4b787bbe ... From 39a6f6c3df45b01409560727da2b7245e054ae77 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 17:02:48 -0400 Subject: [PATCH 035/101] Fix docker not being available Former-commit-id: 4387301690a26a838340474e65b8f0049df958b3 --- .drone/drone.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 4cb97a36774a..8f8b74c2f21a 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -45,6 +45,9 @@ trigger: steps: - name: create-release image: rfratto/seego + volumes: + - name: docker + path: /var/run/docker.sock commands: - apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - @@ -71,6 +74,11 @@ steps: draft: true when: event: tag + +volumes: +- name: docker + host: + path: /var/run/docker.sock --- kind: pipeline type: docker @@ -108,6 +116,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: f384e403811e1770a22ef62a071d2679967c207a81202783389c8a3d4b787bbe +hmac: 23e4dcb7c314653b378f8c5b97734427ba9df7c94fd842e75d839cf75f08568e ... From 2aded666c93738b269503fa2ada888967e818562 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 17:11:17 -0400 Subject: [PATCH 036/101] Set build in container flag Former-commit-id: 7ed76a916b5f72de0b31d064cf30e465dbe3b8b6 --- .drone/drone.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 8f8b74c2f21a..e08b7ff3d1e1 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -62,7 +62,7 @@ steps: - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - export PATH="$(go env GOPATH)/bin:$PATH" - RELEASE_TAG=$DRONE_TAG - - make -j4 RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish + - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish - name: publish image: plugins/github-release environment: @@ -74,7 +74,7 @@ steps: draft: true when: event: tag - + volumes: - name: docker host: @@ -116,6 +116,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 23e4dcb7c314653b378f8c5b97734427ba9df7c94fd842e75d839cf75f08568e +hmac: 2c5a38030ab9a70a1d3cdaf436a746c0844fe40878ba2077dd9245238699ebe3 ... From 9cd2bb405757889c1d7ea60a6b6ee59df5a08c30 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Thu, 8 Jul 2021 17:22:30 -0400 Subject: [PATCH 037/101] fix Former-commit-id: 2623c6eab23dbaa1b202cb0e842081cd59a220e0 --- .drone/drone.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index e08b7ff3d1e1..f53bdfdd4e3b 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -48,11 +48,17 @@ steps: volumes: - name: docker path: /var/run/docker.sock + environment: + DOCKER_LOGIN: + from_secret: DOCKER_LOGIN + DOCKER_PASSWORD: + from_secret: DOCKER_PASSWORD commands: - apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" - apt-get update && apt-get install -y rubygems rpm nsis docker-ce docker-ce-cli containerd.io + - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - gem install --no-document fpm - mkdir -p /usr/local/go/bin - wget -q https://golang.org/dl/go1.16.5.linux-amd64.tar.gz @@ -116,6 +122,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 2c5a38030ab9a70a1d3cdaf436a746c0844fe40878ba2077dd9245238699ebe3 +hmac: 53a2c096a9477d060cefdd7a867f7b3a25ef9ae9149996d7b3065f4776a3f5ee ... From 2313038f07d7bed49a4cf6d00707def1e67bbe2f Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Fri, 9 Jul 2021 11:40:35 -0400 Subject: [PATCH 038/101] fix Former-commit-id: c27a8ff9a83debf9dd83099709e16f9d22bcaae7 --- .drone/drone.yml | 26 ++++++++++++++------------ Makefile | 4 ++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index f53bdfdd4e3b..be894cc6df56 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -53,6 +53,8 @@ steps: from_secret: DOCKER_LOGIN DOCKER_PASSWORD: from_secret: DOCKER_PASSWORD + GITHUB_TOKEN: + from_secret: GITHUB_KEY commands: - apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - @@ -69,17 +71,17 @@ steps: - export PATH="$(go env GOPATH)/bin:$PATH" - RELEASE_TAG=$DRONE_TAG - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish -- name: publish - image: plugins/github-release - environment: - GITHUB_KEY: - from_secret: GITHUB_KEY - settings: - api_key: $GITHUB_KEY - files: /drone/src/dist/* - draft: true - when: - event: tag +# - name: publish +# image: plugins/github-release +# environment: +# GITHUB_KEY: +# from_secret: GITHUB_KEY +# settings: +# api_key: $GITHUB_KEY +# files: /drone/src/dist/* +# draft: true +# when: +# event: tag volumes: - name: docker @@ -122,6 +124,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 53a2c096a9477d060cefdd7a867f7b3a25ef9ae9149996d7b3065f4776a3f5ee +hmac: c5433753ba699c6e9472f59cfc9346c61387951408edd05372d6396557ac2c54 ... diff --git a/Makefile b/Makefile index 6f0b130b74a6..3fe0e37670db 100644 --- a/Makefile +++ b/Makefile @@ -282,7 +282,6 @@ packaging/centos-systemd/.uptodate: $(wildcard packaging/centos-systemd/*) dist-packages: dist-packages-amd64 dist-packages-arm64 dist-packages-armv6 dist-packages-armv7 ifeq ($(BUILD_IN_CONTAINER), true) - @echo !!! Building in container container_make = docker run --rm \ -v $(shell pwd):/src/agent:delegated \ @@ -371,4 +370,5 @@ clean-dist: rm -rf dist .PHONY: clean -publish: dist \ No newline at end of file +publish: dist + ./tools/release \ No newline at end of file From b44451bb0893ca0fb31d351e568c78225214c5e9 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Sun, 11 Jul 2021 11:23:56 -0400 Subject: [PATCH 039/101] fix Former-commit-id: 06d8e36170b2dcf3ef46cf530c81424108506788 --- .drone/drone.yml | 13 +------------ Makefile | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index be894cc6df56..bed725f21c39 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -71,17 +71,6 @@ steps: - export PATH="$(go env GOPATH)/bin:$PATH" - RELEASE_TAG=$DRONE_TAG - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish -# - name: publish -# image: plugins/github-release -# environment: -# GITHUB_KEY: -# from_secret: GITHUB_KEY -# settings: -# api_key: $GITHUB_KEY -# files: /drone/src/dist/* -# draft: true -# when: -# event: tag volumes: - name: docker @@ -124,6 +113,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: c5433753ba699c6e9472f59cfc9346c61387951408edd05372d6396557ac2c54 +hmac: dc1bd2e973ceede26c6b1eb745e2baf5d46d4d09ea2ab610403dc580b4eb1bbf ... diff --git a/Makefile b/Makefile index 3fe0e37670db..66f7710514a4 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,15 @@ SHELL = /usr/bin/env bash ############# # Docker image info -IMAGE_PREFIX ?= mrdgrafana +IMAGE_PREFIX ?= grafana IMAGE_TAG ?= $(shell ./tools/image-tag) TARGETPLATFORM ?= normal # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, # and seego is used for building binaries instead of go. +# If using CROSS_BUILD the preferred method is to use +# `drone exec --trusted --pipeline ./.drone/drona.yaml` from the root directory CROSS_BUILD ?= true # Certain aspects of the build are done in containers for consistency. @@ -111,10 +113,9 @@ all: protos agent agentctl agent: cmd/agent/agent agentctl: cmd/agentctl/agentctl +# TargetPlatform is set by the buildx + cmd/agent/agent: cmd/agent/main.go - @echo $(TARGETPLATFORM) - @echo $(IMAGE_TAG) - @echo $(RELEASE_BUILD) ifeq ($(TARGETPLATFORM),normal) export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) endif @@ -197,6 +198,7 @@ example-dashboards: # # We use rfratto/seego as a base for building these cross-platform images. # seego provides a docker image with gcc toolchains for all of these platforms. +# OSXCROSS_PATH is set by the seego docker container # # A custom grafana/agent/seego image is built on top of the base image with # specific overrides. grafana/agent/seego is not pushed to Docker Hub and @@ -371,4 +373,11 @@ clean-dist: .PHONY: clean publish: dist - ./tools/release \ No newline at end of file + ./tools/release + +# Drone signs the yaml, you will need to specify DRONE_TOKEN, which can be found by logging into your profile in drone +.PHONY: drone +drone: + drone lint .drone/drone.yml --trusted + drone --server https://drone.grafana.net sign --save grafana/agent .drone/drone.yml + \ No newline at end of file From 548d93a833ed90156609c3df1c6d56856a535cc5 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Sun, 11 Jul 2021 11:24:48 -0400 Subject: [PATCH 040/101] remove dead code Former-commit-id: b074c9ea2d3281f025302afec4a3fc6ac2e21c77 --- go_wrapper.sh | 147 -------------------------------------------------- 1 file changed, 147 deletions(-) delete mode 100755 go_wrapper.sh diff --git a/go_wrapper.sh b/go_wrapper.sh deleted file mode 100755 index 64c9de708140..000000000000 --- a/go_wrapper.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env bash - -FOUND_CC="" -FOUND_CXX="" -FOUND_LD_PATH="" -CC_EXTRA="" -CXX_EXTRA="" - -CGO_ENABLED=${CGO_ENABLED:-$(go env CGO_ENABLED)} -GOARCH=$(go env GOARCH) -GOOS=$(go env GOOS) -GOARM=$(go env GOARM) - -main() { - echo ">>> discovering toolchain for GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM}" - - case "$GOOS" in - linux) configure_linux ;; - darwin) configure_darwin ;; - freebsd) configure_bsd ;; - windows) configure_windows ;; - *) - echo ">>> ERROR: unsupported GOOS value $GOOS" - exit 1 - esac - - echo ">>> discovered CC ${FOUND_CC}" - echo ">>> discovered CXX ${FOUND_CXX}" - echo ">>> extra C flags: ${CC_EXTRA}" - - echo ">>> CGO_ENABLED=${CGO_ENABLED} CC=$FOUND_CC CXX=$FOUND_CXX go $@" - - # I'm skeptical that this is the best way to do it because it's so - # annoying, but it works at least. - # - # Export environment variables we want to retain when running go - # as the new user. Even though we preserve the path, we have to use - # the full path to go since sudo won't read the PATH for it. - - export CC="$FOUND_CC $CC_EXTRA" - export CXX="$FOUND_CXX $CC_EXTRA" - - export CGO_CFLAGS=$CC_EXTRA - export CGO_CXX_CFLAGS=$CC_EXTRA - export CGO_LDFLAGS=$CC_EXTRA - - export PATH=$PATH - if [ ! -z "$FOUND_LD_PATH" ]; then - export LD_LIBRARY_PATH="$FOUND_LD_PATH:$LD_LIBRARY_PATH" - fi - - export GOCACHE=$(pwd)/.cache -} - -configure_linux() { - toolchain_prefix="" - - case "$GOARCH" in - # Do nothing for native archs - amd64 | 386) ;; - - arm) toolchain_prefix="arm-linux-gnueabi-" ;; - arm64) toolchain_prefix="aarch64-linux-gnu-" ;; - - ppc64) toolchain_prefix="powerpc-linux-gnu-" ;; - ppc64le) toolchain_prefix="powerpc64le-linux-gnu-" ;; - - mips) toolchain_prefix="mips-linux-gnu-" ;; - mipsle) toolchain_prefix="mipsel-linux-gnu-" ;; - mips64) toolchain_prefix="mips64-linux-gnuabi64-" ;; - mips64le) toolchain_prefix="mips64el-linux-gnuabi64-" ;; - - s390x) toolchain_prefix="s390x-linux-gnu-" ;; - - *) - echo ">>> ERROR: unsupported linux GOARCH value $GOARCH" - echo ">>> supported values: amd64, 386, arm, arm64, ppc64, ppc64le, mips, mipsle, mips64, mips64le, s390x" - exit 1 - esac - - if [ "$GOARCH" == "arm" ] && [ "$GOARM" == "7" ]; then - toolchain_prefix="arm-linux-gnueabihf-" - fi - - FOUND_CC="${toolchain_prefix}gcc" - FOUND_CXX="${toolchain_prefix}g++" -} - -configure_darwin() { - case "$GOARCH" in - amd64) - FOUND_CC="x86_64-apple-darwin20.2-clang" - FOUND_CXX="x86_64-apple-darwin20.2-clang++" - FOUND_LD_PATH="$OSXCROSS_PATH/lib" - ;; - arm64) - FOUND_CC="arm64-apple-darwin20.2-clang" - FOUND_CXX="arm64-apple-darwin20.2-clang++" - FOUND_LD_PATH="$OSXCROSS_PATH/lib" - ;; - *) - echo ">>> ERROR: unsupported darwin GOARCH value $GOARCH" - echo ">>> supported values: amd64, arm64" - exit 1 - esac -} - -configure_bsd() { - case "$GOARCH" in - amd64) - FOUND_CC="clang" - FOUND_CXX="clang++" - CC_EXTRA="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" - ;; - 386) - FOUND_CC="clang" - FOUND_CXX="clang++" - CC_EXTRA="-target i386-pc-freebsd11 --sysroot=/usr/freebsd/i386-pc-freebsd11 -v" - ;; - - *) - echo ">>> ERROR: unsupported bsd GOARCH value $GOARCH" - echo ">>> supported values: amd64, 386" - exit 1 - esac -} - -configure_windows() { - case "$GOARCH" in - 386) - FOUND_CC="i686-w64-mingw32-gcc" - FOUND_CXX="i686-w64-mingw32-g++" - ;; - amd64) - FOUND_CC="x86_64-w64-mingw32-gcc" - FOUND_CXX="x86_64-w64-mingw32-g++" - ;; - - *) - echo ">>> ERROR: unsupported windows GOARCH value $GOARCH" - echo ">>> supported values: 386, amd64" - exit 1 - esac -} -main -echo $CC - From aeb1820d4f205052a86843abc109febe8838193e Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 09:47:11 -0400 Subject: [PATCH 041/101] comments Former-commit-id: eee8e0ca9315d4746423573cfbe0541b3e1f987a --- .drone/drone.yml | 32 ++++++++++++++++++++++++++++++-- Makefile | 2 +- cmd/agent/Dockerfile.buildx | 3 --- tools/test-packages | 17 ++++------------- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index bed725f21c39..644bf1698710 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -1,4 +1,8 @@ --- +# IMPORTANT: Any changes to this file have to be signed, this can be done by running make drone +# Note that you will need to already have added DRONE_TOKEN as an environment variable +--- +# Ensures that linting is done properly kind: pipeline name: Lint platform: @@ -12,9 +16,10 @@ steps: - apt-get update -y && apt-get install -y libsystemd-dev - make lint --- +# Generates executables and ensures they are built kind: pipeline type: docker -name: Dist +name: Make Executables platform: os: linux arch: amd64 @@ -32,6 +37,28 @@ steps: - export PATH=$PATH:/usr/local/go/bin - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist --- +# Run golang unit tests +kind: pipeline +type: docker +name: Test +platform: + os: linux + arch: amd64 + +steps: +- name: distribute + image: rfratto/seego + commands: + - apt-get update && apt-get install -y rubygems rpm nsis apt-transport-https ca-certificates curl gnupg lsb-release + - gem install --no-document fpm + - mkdir -p /usr/local/go/bin + - wget -q https://golang.org/dl/go1.16.5.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz + - rm go1.16.5.linux-amd64.tar.gz + - export PATH=$PATH:/usr/local/go/bin + - make BUILD_IN_CONTAINER=false test +--- +# Create artifacts and draft release, ONLY used when a tag is pushed kind: pipeline type: docker name: Release @@ -77,6 +104,7 @@ volumes: host: path: /var/run/docker.sock --- +# Build and push containers kind: pipeline type: docker name: Containerize @@ -113,6 +141,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: dc1bd2e973ceede26c6b1eb745e2baf5d46d4d09ea2ab610403dc580b4eb1bbf +hmac: 25dc50fe5bb6e8d8c867ce8d8a3cd402ea691a75933fe42383dcd346dcfc05a6 ... diff --git a/Makefile b/Makefile index 66f7710514a4..c56ddcd791ac 100644 --- a/Makefile +++ b/Makefile @@ -364,7 +364,7 @@ endif enforce-release-tag: @sh -c '[ -n "${RELEASE_TAG}" ] || (echo \$$RELEASE_TAG environment variable not set; exit 1)' -test-packages: enforce-release-tag seego dist-packages-amd64 packaging/centos-systemd/.uptodate packaging/debian-systemd/.uptodate +test-packages: enforce-release-tag dist-packages-amd64 packaging/centos-systemd/.uptodate packaging/debian-systemd/.uptodate ./tools/test-packages $(IMAGE_PREFIX) $(PACKAGE_VERSION) $(PACKAGE_RELEASE) .PHONY: test-package diff --git a/cmd/agent/Dockerfile.buildx b/cmd/agent/Dockerfile.buildx index 378589b876cf..d914f505078a 100644 --- a/cmd/agent/Dockerfile.buildx +++ b/cmd/agent/Dockerfile.buildx @@ -17,9 +17,6 @@ WORKDIR /src/agent ARG RELEASE_BUILD=true ARG IMAGE_TAG -# Rename seego's /go_wrapper.sh to /seego.sh for readability in the -# Makefile. -# RUN cp /go_wrapper.sh /seego.sh RUN make clean && IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false make agent FROM debian:buster-slim diff --git a/tools/test-packages b/tools/test-packages index f9570572320e..019964d142be 100755 --- a/tools/test-packages +++ b/tools/test-packages @@ -6,7 +6,6 @@ readonly IMAGE_PREFIX=$1 readonly VERSION=$2 readonly RELEASE=$3 readonly DISABLE_CLEANUP=${DISABLE_CLEANUP:-0} -readonly DRONE=${DRONE:-"false"} readonly GID=${GID:-$(id -g)} @@ -22,10 +21,7 @@ function cleanup() { fi } -if [[ "${DRONE}" = "false" ]]; -then - trap cleanup EXIT -fi +trap cleanup EXIT function test_with_systemd() { local -r image=$1 @@ -43,11 +39,6 @@ function test_with_systemd() { docker exec -i "${container}" /bin/bash -c "${remove_command}" } -if [[ "${DRONE}" = "true" ]]; -then - echo "In drone not running grafana agent tests" - exit 0 -else - test_with_systemd "${IMAGE_PREFIX}"/centos-systemd "rpm -i /dist/grafana-agent-${VERSION}-${RELEASE}.amd64.rpm" "rpm -e grafana-agent" - test_with_systemd "${IMAGE_PREFIX}"/debian-systemd "dpkg -i /dist/grafana-agent-${VERSION}-${RELEASE}.amd64.deb" "dpkg -r grafana-agent" -fi \ No newline at end of file + +test_with_systemd "${IMAGE_PREFIX}"/centos-systemd "rpm -i /dist/grafana-agent-${VERSION}-${RELEASE}.x86_64.rpm" "rpm -e grafana-agent" +test_with_systemd "${IMAGE_PREFIX}"/debian-systemd "dpkg -i /dist/grafana-agent-${VERSION}-${RELEASE}.x86_64.deb" "dpkg -r grafana-agent" From 525f0f64814f5c93357fa169dcf6cc3e96ce4587 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 10:11:24 -0400 Subject: [PATCH 042/101] sign Former-commit-id: c29ec0372aa0ecb686219fe8337d8d214702a12f --- .drone/drone.yml | 15 +++++---------- Makefile | 25 +++++-------------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 644bf1698710..31192b889bea 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -1,8 +1,4 @@ --- -# IMPORTANT: Any changes to this file have to be signed, this can be done by running make drone -# Note that you will need to already have added DRONE_TOKEN as an environment variable ---- -# Ensures that linting is done properly kind: pipeline name: Lint platform: @@ -16,10 +12,9 @@ steps: - apt-get update -y && apt-get install -y libsystemd-dev - make lint --- -# Generates executables and ensures they are built kind: pipeline type: docker -name: Make Executables +name: Dist platform: os: linux arch: amd64 @@ -37,7 +32,6 @@ steps: - export PATH=$PATH:/usr/local/go/bin - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist --- -# Run golang unit tests kind: pipeline type: docker name: Test @@ -58,7 +52,6 @@ steps: - export PATH=$PATH:/usr/local/go/bin - make BUILD_IN_CONTAINER=false test --- -# Create artifacts and draft release, ONLY used when a tag is pushed kind: pipeline type: docker name: Release @@ -104,13 +97,15 @@ volumes: host: path: /var/run/docker.sock --- -# Build and push containers kind: pipeline type: docker name: Containerize platform: os: linux arch: amd64 +trigger: + event: + - tag steps: - name: Build Containers @@ -141,6 +136,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 25dc50fe5bb6e8d8c867ce8d8a3cd402ea691a75933fe42383dcd346dcfc05a6 +hmac: ef23d4b90ddca3f05c791fa16797fbffd5ed102935109b5a1bbdfa74620b8e87 ... diff --git a/Makefile b/Makefile index c56ddcd791ac..c36283d34f86 100644 --- a/Makefile +++ b/Makefile @@ -115,27 +115,11 @@ agentctl: cmd/agentctl/agentctl # TargetPlatform is set by the buildx -cmd/agent/agent: cmd/agent/main.go -ifeq ($(TARGETPLATFORM),normal) - export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/amd64) - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/arm64) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/arm/v7) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/arm/v6) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif - $(NETGO_CHECK) +cmd/agent/agent: cmd/agent/main.go basebuild +cmd/agentctl/agentctl: cmd/agentctl/main.go basebuild -cmd/agentctl/agentctl: cmd/agentctl/main.go - @echo $(TARGETPLATFORM) +basebuild: ifeq ($(TARGETPLATFORM),normal) export CGO_ENABLED=1 GO111MODULE=auto ; go build $(CGO_FLAGS) -o $@ ./$(@D) endif @@ -146,13 +130,14 @@ ifeq ($(TARGETPLATFORM),linux/arm64) export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/arm/v7) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/arm/v6) export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif $(NETGO_CHECK) + agent-image: docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . From 96e17992fa4d747defc6203181d2e82ba965eb3c Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 10:29:24 -0400 Subject: [PATCH 043/101] comments Former-commit-id: 5c320aa2a473c7bcf46ea1882d6d079c99bafd0f --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4c47273acc78..4285fefcddbd 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SHELL = /usr/bin/env bash ############# # Docker image info -IMAGE_PREFIX ?= grafana +IMAGE_PREFIX ?= mrdgrafana IMAGE_TAG ?= $(shell ./tools/image-tag) TARGETPLATFORM ?= normal @@ -81,6 +81,7 @@ docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx +docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) endif ######## @@ -169,10 +170,10 @@ agent-image: $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . agent-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . agentctl-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . agent-operator-image: $(docker-build) -t $(IMAGE_PREFIX)/agent-operator:latest -t $(IMAGE_PREFIX)/agent-operator:$(IMAGE_TAG) -f cmd/agent-operator/$(DOCKERFILE) . From d211d6c5d739f7d36f3a95240fb7f6026740821c Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 11:00:34 -0400 Subject: [PATCH 044/101] comments Former-commit-id: acacde9de4ddeb6f09c77e45a1bbedc41ed83c3a --- Makefile | 3 --- go.mod | 5 ++++- go.sum | 27 ++++++++------------------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 4285fefcddbd..1cc180740a71 100644 --- a/Makefile +++ b/Makefile @@ -169,9 +169,6 @@ endif agent-image: $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . -agent-image: - $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . - agentctl-image: $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . diff --git a/go.mod b/go.mod index 18ef50f1164f..8be8199b0ddb 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( go.opentelemetry.io/collector v0.29.0 go.uber.org/atomic v1.8.0 go.uber.org/zap v1.17.0 - golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 + golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 google.golang.org/grpc v1.38.0 gopkg.in/alecthomas/kingpin.v2 v2.2.6 gopkg.in/yaml.v2 v2.4.0 @@ -68,6 +68,9 @@ require ( // Replace directives from Prometheus replace k8s.io/klog => github.com/simonpasquier/klog-gokit v0.1.0 +// TODO Replace this with mapnos merge, once it is merged +replace github.com/Shopify/sarama => github.com/Shopify/sarama v1.29.1 + // Replace directives from Cortex replace ( git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999 diff --git a/go.sum b/go.sum index 039a49301511..1c4c42a237a7 100644 --- a/go.sum +++ b/go.sum @@ -153,10 +153,8 @@ github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdko github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/SAP/go-hdb v0.12.0/go.mod h1:etBT+FAi1t5k3K3tf5vQTnosgYmhDkRi8jEnQqCnxF0= github.com/SermoDigital/jose v0.0.0-20180104203859-803625baeddc/go.mod h1:ARgCUhI1MHQH+ONky/PAtmVHQrP5JlGY0F3poXOp/fA= -github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/sarama v1.27.1/go.mod h1:g5s5osgELxgM+Md9Qni9rzo7Rbt+vvFQI4bt/Mc93II= -github.com/Shopify/sarama v1.29.0 h1:ARid8o8oieau9XrHI55f/L3EoRAhm9px6sonbD7yuUE= -github.com/Shopify/sarama v1.29.0/go.mod h1:2QpgD79wpdAESqNQMxNc0KYMkycd4slxGdV3TWSVqrU= +github.com/Shopify/sarama v1.29.1 h1:wBAacXbYVLmWieEA/0X/JagDdCZ8NVFOfS6l6+2u5S0= +github.com/Shopify/sarama v1.29.1/go.mod h1:mdtqvCSg8JOxk8PmpTNGyo6wzd4BMm4QXSfDnTXmgkE= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= @@ -488,7 +486,6 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8 github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= -github.com/frankban/quicktest v1.10.2/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s= github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -1098,7 +1095,6 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8= @@ -1401,7 +1397,6 @@ github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHu github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A= github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4/v4 v4.1.1/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= @@ -1498,7 +1493,6 @@ github.com/prometheus/statsd_exporter v0.18.1-0.20201124082027-8b2b4c1a2b49/go.m github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rafaeljusto/redigomock v0.0.0-20190202135759-257e089e14a1/go.mod h1:JaY6n2sDr+z2WTsXkOmNRUfDy6FN0L6Nk7x06ndm4tY= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= @@ -1851,14 +1845,13 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1973,11 +1966,11 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210324051636-2c4c8ecb7826/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210427231257-85d9c07bbe3a/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210505214959-0714010a04ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210510120150-4163338589ed h1:p9UgmWI9wKpfYmgaV/IZKGdXc5qEK45tDwwwDyjS26I= golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20170807180024-9a379c6b3e95/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -2125,8 +2118,9 @@ golang.org/x/sys v0.0.0-20210503080704-8803ae5d1324/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 h1:faDu4veV+8pcThn4fewv6TVlNCezafGoC1gM/mxQLbQ= golang.org/x/sys v0.0.0-20210611083646-a4fc73990273/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= @@ -2432,11 +2426,6 @@ gopkg.in/ini.v1 v1.52.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo= -gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eRhxkJMWSIz9Q= -gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4= -gopkg.in/jcmturner/gokrb5.v7 v7.5.0/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= -gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8= gopkg.in/ldap.v3 v3.1.0/go.mod h1:dQjCc0R0kfyFjIlWNMH1DORwUASZyDxo2Ry1B51dXaQ= gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= From 1ae2949747a71ab820a92cce5a872d56473c732a Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 16:52:41 -0400 Subject: [PATCH 045/101] comments Former-commit-id: 8acfe153eb57fe355b76612b49a252e6d45800ac --- .drone/drone.yml | 3 +- Governance.md | 156 +++++++++++++++++++++++ Makefile | 95 ++++++++------ buildx-v0.5.1.linux-amd64.REMOVED.git-id | 1 + 4 files changed, 212 insertions(+), 43 deletions(-) create mode 100644 Governance.md create mode 100644 buildx-v0.5.1.linux-amd64.REMOVED.git-id diff --git a/.drone/drone.yml b/.drone/drone.yml index 31192b889bea..954cf3589e16 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -129,6 +129,7 @@ steps: - docker buildx create --name multiarch --driver docker-container --use - make CROSS_BUILD=true RELEASE_BUILD=true agent-image - make CROSS_BUILD=true RELEASE_BUILD=true agentctl-image + - docker buildx rm multiarch volumes: - name: docker @@ -136,6 +137,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: ef23d4b90ddca3f05c791fa16797fbffd5ed102935109b5a1bbdfa74620b8e87 +hmac: 7ecbeab4e9191c2ec769bd5481d6b243ce6e72520bb9cc45a63afa2a20df5e46 ... diff --git a/Governance.md b/Governance.md new file mode 100644 index 000000000000..c4b340f4dc84 --- /dev/null +++ b/Governance.md @@ -0,0 +1,156 @@ +--- +title: Governance +--- +# Governance + +This document describes the rules and governance of the project. It is meant to be followed by all the developers of the project and the Grafana Agent community. Common terminology used in this governance document are listed below: + +- **Team members**: Any members of the private [team mailing list][team]. + +- **Maintainers**: Maintainers lead an individual project or parts thereof ([`MAINTAINERS.md`][maintainers]). + +- **Projects**: A single repository in the Grafana GitHub organization and listed below is referred to as a project: + - Grafana Agent + +- **The Grafana Agent project**: The sum of all activities performed under this governance, concerning one or more repositories or the community. + +## Values + +The Grafana Agent developers and community are expected to follow the values defined in the [Code of Conduct][coc]. Furthermore, the Grafana Agent community strives for kindness, giving feedback effectively, and building a welcoming environment. The Grafana Agent developers generally decide by consensus and only resort to conflict resolution by a majority vote if consensus cannot be reached. + +## Projects + +Each project must have a [`MAINTAINERS.md`][maintainers] file with at least one maintainer. Where a project has a release process, access and documentation should be such that more than one person can perform a release. Where a project has a release process, access and documentation should be such that more than one person can perform a release. Releases should be announced on the [GitHub Discussions][discussions] page. Any new projects should be first proposed on the [team mailing list][team] following the voting procedures listed below. + +## Decision making + +### Team members + +Team member status may be given to those who have made ongoing contributions to the Grafana Agent project for at least 3 months. This is usually in the form of code improvements and/or notable work on documentation, but organizing events or user support could also be taken into account. + +New members may be proposed by any existing member by email to the [team mailing list][team]. It is highly desirable to reach consensus about acceptance of a new member. However, the proposal is ultimately voted on by a formal [supermajority vote](#supermajority-vote). + +If the new member proposal is accepted, the proposed team member should be contacted privately via email to confirm or deny their acceptance of team membership. This email will also be CC'd to the [team mailing list][team] for record-keeping purposes. + +If they choose to accept, the [onboarding](#onboarding) procedure is followed. + +Team members may retire at any time by emailing [the team][team]. + +Team members can be removed by [supermajority vote](#supermajority-vote) on [the team mailing list][team]. +For this vote, the member in question is not eligible to vote and does not count towards the quorum. +Any removal vote can cover only one single person. + +Upon death of a member, they leave the team automatically. + +In case a member leaves, the [offboarding](#offboarding) procedure is applied. + +The current team members are: + +- Matt Durham - [mattdurham](https://github.com/mattdurham) ([Grafana Labs](https://grafana.com)) +- Joe Elliott - [joe-elliott](https://github.com/joe-elliott) ([Grafana Labs](https://grafana.com)) +- Robert Fratto - [rfratto](https://github.com/rfratto) ([Grafana Labs](https://grafana.com)) +- Richard Hartmann - [RichiH](https://github.com/RichiH) ([Grafana Labs](https://grafana.com)) +- Mario Rodriguez - [mapno](https://github.com/mapno) ([Grafana Labs](https://grafana.com)) + +### Maintainers + +Maintainers lead one or more project(s) or parts thereof and serve as a point of conflict resolution amongst the contributors to this project. Ideally, maintainers are also team members, but exceptions are possible for suitable maintainers that, for whatever reason, are not yet team members. + +Changes in maintainership have to be announced on the [developers mailing list][devs]. They are decided by [rough consensus](#consensus) and formalized by changing the [`MAINTAINERS.md`][maintainers] file of the respective repository. + +Maintainers are granted commit rights to all projects covered by this governance. + +A maintainer or committer may resign by notifying the [team mailing list][team]. A maintainer with no project activity for a year is considered to have resigned. Maintainers that wish to resign are encouraged to propose another team member to take over the project. + +A project may have multiple maintainers, as long as the responsibilities are clearly agreed upon between them. This includes coordinating who handles which issues and pull requests. + +### Technical decisions + +Technical decisions that only affect a single project are made informally by the maintainer of this project, and [rough consensus](#consensus) is assumed. Technical decisions that span multiple parts of the project should be discussed and made on the [developer mailing list][devs]. + +Decisions are usually made by [rough consensus](#consensus). If no consensus can be reached, the matter may be resolved by [majority vote](#majority-vote). + +### Governance changes + +Changes to this document are made by Grafana Labs. + +### Other matters + +Any matter that needs a decision may be called to a vote by any member if they deem it necessary. For private or personnel matters, discussion and voting takes place on the [team mailing list][team], otherwise on the [developer mailing list][devs]. + +## Voting + +The Grafana Agent project usually runs by informal consensus, however sometimes a formal decision must be made. + +Depending on the subject matter, as laid out [above](#decision-making), different methods of voting are used. + +For all votes, voting must be open for at least one week. The end date should be clearly stated in the call to vote. A vote may be called and closed early if enough votes have come in one way so that further votes cannot change the final decision. + +In all cases, all and only [team members](#team-members) are eligible to vote, with the sole exception of the forced removal of a team member, in which said member is not eligible to vote. + +Discussion and votes on personnel matters (including but not limited to team membership and maintainership) are held in private on the [team mailing list][team]. All other discussion and votes are held in public on the [developer mailing list][devs]. + +For public discussions, anyone interested is encouraged to participate. Formal power to object or vote is limited to [team members](#team-members). + +### Consensus + +The default decision making mechanism for the Grafana Agent project is [rough][rough] consensus. This means that any decision on technical issues is considered supported by the [team][team] as long as nobody objects or the objection has been considered but not necessarily accommodated. + +Silence on any consensus decision is implicit agreement and equivalent to explicit agreement. Explicit agreement may be stated at will. Decisions may, but do not need to be called out and put up for decision on the [developers mailing list][devs] at any time and by anyone. + +Consensus decisions can never override or go against the spirit of an earlier explicit vote. + +If any [team member](#team-members) raises objections, the team members work together towards a solution that all involved can accept. This solution is again subject to rough consensus. + +In case no consensus can be found, but a decision one way or the other must be made, any [team member](#team-members) may call a formal [majority vote](#majority-vote). + +### Majority vote + +Majority votes must be called explicitly in a separate thread on the appropriate mailing list. The subject must be prefixed with `[VOTE]`. In the body, the call to vote must state the proposal being voted on. It should reference any discussion leading up to this point. + +Votes may take the form of a single proposal, with the option to vote yes or no, or the form of multiple alternatives. + +A vote on a single proposal is considered successful if more vote in favor than against. + +If there are multiple alternatives, members may vote for one or more alternatives, or vote “no” to object to all alternatives. It is not possible to cast an “abstain” vote. A vote on multiple alternatives is considered decided in favor of one alternative if it has received the most votes in favor, and a vote from more than half of those voting. Should no alternative reach this quorum, another vote on a reduced number of options may be called separately. + +### Supermajority vote + +Supermajority votes must be called explicitly in a separate thread on the appropriate mailing list. The subject must be prefixed with `[VOTE]`. In the body, the call to vote must state the proposal being voted on. It should reference any discussion leading up to this point. + +Votes may take the form of a single proposal, with the option to vote yes or no, or the form of multiple alternatives. + +A vote on a single proposal is considered successful if at least two thirds of those eligible to vote vote in favor. + +If there are multiple alternatives, members may vote for one or more alternatives, or vote “no” to object to all alternatives. A vote on multiple alternatives is considered decided in favor of one alternative if it has received the most votes in favor, and a vote from at least two thirds of those eligible to vote. Should no alternative reach this quorum, another vote on a reduced number of options may be called separately. + +## On- / Offboarding + +### Onboarding + +The new member is + +- added to the list of [team members](#team-members). Ideally by sending a PR of their own, at least approving said PR. +- announced on the [developers mailing list][devs] by an existing team member. Ideally, the new member replies in this thread, acknowledging team membership. +- added to the projects with commit rights. +- added to the [team mailing list][team]. + + +### Offboarding + +The ex-member is + +- removed from the list of [team members](#team-members). Ideally by sending a PR of their own, at least approving said PR. In case of forced removal, no approval is needed. +- removed from the projects. Optionally, they can retain maintainership of one or more repositories if the [team](#team-members) agrees. +- removed from the team mailing list and demoted to a normal member of the other mailing lists. +- not allowed to call themselves an active team member any more, nor allowed to imply this to be the case. +- added to a list of previous members if they so choose. + +If needed, we reserve the right to publicly announce removal. + +[coc]: https://github.com/grafana/agent/blob/main/CODE_OF_CONDUCT.md +[devs]: https://groups.google.com/forum/#!forum/grafana-agent-developers +[maintainers]: https://github.com/grafana/agent/blob/main/MAINTAINERS.md +[rough]: https://tools.ietf.org/html/rfc7282 +[team]: https://groups.google.com/forum/#!forum/grafana-agent-team +[discussions]: https://github.com/grafana/agent/discussions diff --git a/Makefile b/Makefile index 1cc180740a71..de455b51ef21 100644 --- a/Makefile +++ b/Makefile @@ -13,16 +13,14 @@ TARGETPLATFORM ?= normal # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, # and seego is used for building binaries instead of go. -# If using CROSS_BUILD the preferred method is to use -# `drone exec --trusted --pipeline ./.drone/drona.yaml` from the root directory -CROSS_BUILD ?= false +CROSS_BUILD ?= true # Certain aspects of the build are done in containers for consistency. # If you have the correct tools installed and want to speed up development, # run make BUILD_IN_CONTAINER=false , or you can set BUILD_IN_CONTAINER=true # as an environment variable. BUILD_IN_CONTAINER ?= true -BUILD_IMAGE_VERSION := 0.11.0 +BUILD_IMAGE_VERSION := 0.10.0 BUILD_IMAGE := $(IMAGE_PREFIX)/agent-build-image:$(BUILD_IMAGE_VERSION) # Enables the binary to be built with optimizations (i.e., doesn't strip the image of @@ -54,12 +52,12 @@ GO_FLAGS = $(DEBUG_GO_FLAGS) endif NETGO_CHECK = @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ - rm $@; \ - echo "\nYour go standard library was built without the 'netgo' build tag."; \ - echo "To fix that, run"; \ - echo " sudo go clean -i net"; \ - echo " sudo go install -tags netgo std"; \ - false; \ + rm $@; \ + echo "\nYour go standard library was built without the 'netgo' build tag."; \ + echo "To fix that, run"; \ + echo " sudo go clean -i net"; \ + echo " sudo go install -tags netgo std"; \ + false; \ } # Protobuf files @@ -81,9 +79,9 @@ docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx -docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) endif + ######## # CRDs # ######## @@ -136,22 +134,37 @@ agent-operator: cmd/agent-operator/agent-operator # TargetPlatform is set by the buildx -cmd/agent/agent: cmd/agent/main.go basebuild +cmd/agent/agent: cmd/agent/main.go +ifeq ($(TARGETPLATFORM),normal) + export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),linux/amd64) + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),linux/arm64) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),linux/arm/v7) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif +ifeq ($(TARGETPLATFORM),linux/arm/v6) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) +endif + $(NETGO_CHECK) -cmd/agentctl/agentctl: cmd/agentctl/main.go basebuild -basebuild: +cmd/agentctl/agentctl: cmd/agentctl/main.go ifeq ($(TARGETPLATFORM),normal) - export CGO_ENABLED=1 GO111MODULE=auto ; go build $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/amd64) - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/arm64) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/arm/v7) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) endif ifeq ($(TARGETPLATFORM),linux/arm/v6) export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) @@ -166,14 +179,12 @@ else endif $(NETGO_CHECK) -agent-image: - $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . -agentctl-image: - $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . +agent-image: + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . -agent-operator-image: - $(docker-build) -t $(IMAGE_PREFIX)/agent-operator:latest -t $(IMAGE_PREFIX)/agent-operator:$(IMAGE_TAG) -f cmd/agent-operator/$(DOCKERFILE) . +agentctl-image: + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . install: CGO_ENABLED=1 go install $(CGO_FLAGS) ./cmd/agent @@ -228,47 +239,47 @@ dist: dist-agent dist-agentctl dist-packages .PHONY: dist dist-agent: dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe -dist/agent-linux-amd64: +dist/agent-linux-amd64: export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-arm64: +dist/agent-linux-arm64: export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-armv6: +dist/agent-linux-armv6: export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-armv7: +dist/agent-linux-armv7: export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-mipsle: +dist/agent-linux-mipsle: export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++;go build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-darwin-amd64: +dist/agent-darwin-amd64: export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-darwin-arm64: +dist/agent-darwin-arm64: export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-windows-amd64.exe: +dist/agent-windows-amd64.exe: export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe cp dist/agent-windows-amd64.exe ./packaging/windows cp LICENSE ./packaging/windows makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis -dist/agent-freebsd-amd64: +dist/agent-freebsd-amd64: export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agent dist-agentctl: dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 -dist/agentctl-linux-amd64: +dist/agentctl-linux-amd64: export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc CCX=g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-arm64: +dist/agentctl-linux-arm64: export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-armv6: +dist/agentctl-linux-armv6: export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-armv7: +dist/agentctl-linux-armv7: export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-mipsle: +dist/agentctl-linux-mipsle: export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-darwin-amd64: +dist/agentctl-darwin-amd64: export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-darwin-arm64: +dist/agentctl-darwin-arm64: export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-windows-amd64.exe: +dist/agentctl-windows-amd64.exe: export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-freebsd-amd64: +dist/agentctl-freebsd-amd64: export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl diff --git a/buildx-v0.5.1.linux-amd64.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.REMOVED.git-id new file mode 100644 index 000000000000..bdc808182bcb --- /dev/null +++ b/buildx-v0.5.1.linux-amd64.REMOVED.git-id @@ -0,0 +1 @@ +dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file From 73ee17b79eda4e568ee739c81d11c7f830bee43f Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 16:53:09 -0400 Subject: [PATCH 046/101] comments Former-commit-id: 3a4048091967d0222c4155ad8999dd7a64e45179 --- buildx-v0.5.1.linux-amd64.REMOVED.git-id | 1 - 1 file changed, 1 deletion(-) delete mode 100644 buildx-v0.5.1.linux-amd64.REMOVED.git-id diff --git a/buildx-v0.5.1.linux-amd64.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.REMOVED.git-id deleted file mode 100644 index bdc808182bcb..000000000000 --- a/buildx-v0.5.1.linux-amd64.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file From 36f1e61ce9b8f9c330de8a1ef2129571f99144bd Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 17:08:20 -0400 Subject: [PATCH 047/101] comments Former-commit-id: d7e3103e5ca8caa330623560f208f87d6cecbf21 --- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index de455b51ef21..4c1b609f7245 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,7 @@ docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx +docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) endif @@ -133,7 +134,6 @@ agentctl: cmd/agentctl/agentctl agent-operator: cmd/agent-operator/agent-operator # TargetPlatform is set by the buildx - cmd/agent/agent: cmd/agent/main.go ifeq ($(TARGETPLATFORM),normal) export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) @@ -181,10 +181,13 @@ endif agent-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . agentctl-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + +agent-operator-image: + $(docker-build) -t $(IMAGE_PREFIX)/agent-operator:latest -t $(IMAGE_PREFIX)/agent-operator:$(IMAGE_TAG) -f cmd/agent-operator/$(DOCKERFILE) . install: CGO_ENABLED=1 go install $(CGO_FLAGS) ./cmd/agent From ae16bf023f7c77f5daacc77c7c78d7a4acf0fa41 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 17:09:17 -0400 Subject: [PATCH 048/101] comments Former-commit-id: 84303ac4574e90d1bd944037c7414122df70970c --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4c1b609f7245..870f593493be 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ endif ######## -# CRDs # +# CRDs # ######## crds: From 2776ba0d322b6d628288379e3ee7e7d89604a964 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 17:28:01 -0400 Subject: [PATCH 049/101] comments Former-commit-id: 2c56ddcfe9d0be54894c4363c9e26c3fae69e8a8 --- Makefile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 870f593493be..773c41c91a28 100644 --- a/Makefile +++ b/Makefile @@ -79,12 +79,11 @@ docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx -docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) endif ######## -# CRDs # +# CRDs # ######## crds: @@ -134,6 +133,7 @@ agentctl: cmd/agentctl/agentctl agent-operator: cmd/agent-operator/agent-operator # TargetPlatform is set by the buildx + cmd/agent/agent: cmd/agent/main.go ifeq ($(TARGETPLATFORM),normal) export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) @@ -181,13 +181,12 @@ endif agent-image: - $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . - + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . agentctl-image: - $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . - + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . agent-operator-image: - $(docker-build) -t $(IMAGE_PREFIX)/agent-operator:latest -t $(IMAGE_PREFIX)/agent-operator:$(IMAGE_TAG) -f cmd/agent-operator/$(DOCKERFILE) . + docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent-operator:latest -t $(IMAGE_PREFIX)/agent-operator:$(IMAGE_TAG) -f cmd/agent-operator/$(DOCKERFILE) . + install: CGO_ENABLED=1 go install $(CGO_FLAGS) ./cmd/agent From b2b358d27653d9baaf9033084429d64903ca734e Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 21:31:56 -0400 Subject: [PATCH 050/101] comments Former-commit-id: 978dc7233c59d205a2d440238ce02c7da916356f --- Makefile | 60 +++++++++------------- buildx-v0.5.1.linux-amd64.1.REMOVED.git-id | 1 + buildx-v0.5.1.linux-amd64.2.REMOVED.git-id | 1 + buildx-v0.5.1.linux-amd64.3.REMOVED.git-id | 1 + buildx-v0.5.1.linux-amd64.4.REMOVED.git-id | 1 + buildx-v0.5.1.linux-amd64.5.REMOVED.git-id | 1 + buildx-v0.5.1.linux-amd64.REMOVED.git-id | 1 + 7 files changed, 31 insertions(+), 35 deletions(-) create mode 100644 buildx-v0.5.1.linux-amd64.1.REMOVED.git-id create mode 100644 buildx-v0.5.1.linux-amd64.2.REMOVED.git-id create mode 100644 buildx-v0.5.1.linux-amd64.3.REMOVED.git-id create mode 100644 buildx-v0.5.1.linux-amd64.4.REMOVED.git-id create mode 100644 buildx-v0.5.1.linux-amd64.5.REMOVED.git-id create mode 100644 buildx-v0.5.1.linux-amd64.REMOVED.git-id diff --git a/Makefile b/Makefile index 773c41c91a28..5ad19472e78a 100644 --- a/Makefile +++ b/Makefile @@ -76,12 +76,29 @@ PACKAGE_RELEASE := 1 DOCKERFILE = Dockerfile docker-build = docker build $(DOCKER_BUILD_FLAGS) - ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx +docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) +endif + +# Set the CGO, CC, CCX flags based on targetplatform, if non given assume 'native' to the device +CGO_CC_CCX = export CGO_ENABLED=1 GO111MODULE=auto + +ifeq ($(TARGETPLATFORM),linux/amd64) +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; +endif +ifeq ($(TARGETPLATFORM),linux/arm64) +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; +endif +ifeq ($(TARGETPLATFORM),linux/arm/v7) +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; +endif +ifeq ($(TARGETPLATFORM),linux/arm/v6) +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; endif + ######## # CRDs # ######## @@ -135,45 +152,18 @@ agent-operator: cmd/agent-operator/agent-operator # TargetPlatform is set by the buildx cmd/agent/agent: cmd/agent/main.go -ifeq ($(TARGETPLATFORM),normal) - export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/amd64) - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/arm64) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/arm/v7) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/arm/v6) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif + $(CGO_CC_CCX) go build $(CGO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) cmd/agentctl/agentctl: cmd/agentctl/main.go -ifeq ($(TARGETPLATFORM),normal) - export CGO_ENABLED=1 GO111MODULE=auto; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/amd64) - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/arm64) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/arm/v7) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif -ifeq ($(TARGETPLATFORM),linux/arm/v6) - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./$(@D) -endif + $(CGO_CC_CCX) go build $(CGO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) + cmd/agent-operator/agent-operator: cmd/agent-operator/main.go ifeq ($(CROSS_BUILD),false) - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) + CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)Samsung 870 EVO else GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) endif @@ -181,11 +171,11 @@ endif agent-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . + $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . agentctl-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . + $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . agent-operator-image: - docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) -t $(IMAGE_PREFIX)/agent-operator:latest -t $(IMAGE_PREFIX)/agent-operator:$(IMAGE_TAG) -f cmd/agent-operator/$(DOCKERFILE) . + $(docker-build) -t $(IMAGE_PREFIX)/agent-operator:latest -t $(IMAGE_PREFIX)/agent-operator:$(IMAGE_TAG) -f cmd/agent-operator/$(DOCKERFILE) . install: diff --git a/buildx-v0.5.1.linux-amd64.1.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.1.REMOVED.git-id new file mode 100644 index 000000000000..bdc808182bcb --- /dev/null +++ b/buildx-v0.5.1.linux-amd64.1.REMOVED.git-id @@ -0,0 +1 @@ +dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.2.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.2.REMOVED.git-id new file mode 100644 index 000000000000..bdc808182bcb --- /dev/null +++ b/buildx-v0.5.1.linux-amd64.2.REMOVED.git-id @@ -0,0 +1 @@ +dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.3.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.3.REMOVED.git-id new file mode 100644 index 000000000000..bdc808182bcb --- /dev/null +++ b/buildx-v0.5.1.linux-amd64.3.REMOVED.git-id @@ -0,0 +1 @@ +dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.4.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.4.REMOVED.git-id new file mode 100644 index 000000000000..bdc808182bcb --- /dev/null +++ b/buildx-v0.5.1.linux-amd64.4.REMOVED.git-id @@ -0,0 +1 @@ +dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.5.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.5.REMOVED.git-id new file mode 100644 index 000000000000..bdc808182bcb --- /dev/null +++ b/buildx-v0.5.1.linux-amd64.5.REMOVED.git-id @@ -0,0 +1 @@ +dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.REMOVED.git-id new file mode 100644 index 000000000000..bdc808182bcb --- /dev/null +++ b/buildx-v0.5.1.linux-amd64.REMOVED.git-id @@ -0,0 +1 @@ +dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file From 8495ad8e717ca4ee84506650af0a34c214338099 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 21:32:43 -0400 Subject: [PATCH 051/101] comments Former-commit-id: 61a5cfb2c85f22d8811f346160303cb80bc27648 --- buildx-v0.5.1.linux-amd64.1.REMOVED.git-id | 1 - buildx-v0.5.1.linux-amd64.2.REMOVED.git-id | 1 - buildx-v0.5.1.linux-amd64.3.REMOVED.git-id | 1 - buildx-v0.5.1.linux-amd64.4.REMOVED.git-id | 1 - buildx-v0.5.1.linux-amd64.5.REMOVED.git-id | 1 - buildx-v0.5.1.linux-amd64.REMOVED.git-id | 1 - 6 files changed, 6 deletions(-) delete mode 100644 buildx-v0.5.1.linux-amd64.1.REMOVED.git-id delete mode 100644 buildx-v0.5.1.linux-amd64.2.REMOVED.git-id delete mode 100644 buildx-v0.5.1.linux-amd64.3.REMOVED.git-id delete mode 100644 buildx-v0.5.1.linux-amd64.4.REMOVED.git-id delete mode 100644 buildx-v0.5.1.linux-amd64.5.REMOVED.git-id delete mode 100644 buildx-v0.5.1.linux-amd64.REMOVED.git-id diff --git a/buildx-v0.5.1.linux-amd64.1.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.1.REMOVED.git-id deleted file mode 100644 index bdc808182bcb..000000000000 --- a/buildx-v0.5.1.linux-amd64.1.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.2.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.2.REMOVED.git-id deleted file mode 100644 index bdc808182bcb..000000000000 --- a/buildx-v0.5.1.linux-amd64.2.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.3.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.3.REMOVED.git-id deleted file mode 100644 index bdc808182bcb..000000000000 --- a/buildx-v0.5.1.linux-amd64.3.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.4.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.4.REMOVED.git-id deleted file mode 100644 index bdc808182bcb..000000000000 --- a/buildx-v0.5.1.linux-amd64.4.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.5.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.5.REMOVED.git-id deleted file mode 100644 index bdc808182bcb..000000000000 --- a/buildx-v0.5.1.linux-amd64.5.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file diff --git a/buildx-v0.5.1.linux-amd64.REMOVED.git-id b/buildx-v0.5.1.linux-amd64.REMOVED.git-id deleted file mode 100644 index bdc808182bcb..000000000000 --- a/buildx-v0.5.1.linux-amd64.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -dea5ea9450ea48687106a67129fbb8d78330cdbc \ No newline at end of file From e0f72a22bd1ed525400ebf1c200f24a1c24dc58e Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 21:35:09 -0400 Subject: [PATCH 052/101] Update changelog Former-commit-id: 2348bf700da6c4586142cf7855e8c2f7611430ec --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3532615cbe52..9e4cb994c086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ # Main (unreleased) -- [ENHANCEMENT] Allow reloading configuration using `SIGHUP` signal. (@tharun208) - [FEATURE] Add TLS config options for tempo `remote_write`s. (@mapno) @@ -9,6 +8,10 @@ - [ENHANCEMENT] The Grafana Agent Operator will now default to deploying the matching release version of the Grafana Agent instead of v0.14.0. (@rfratto) + +- [ENHANCEMENT] Allow reloading configuration using `SIGHUP` signal. (@tharun208) + +- [ENHANCEMENT] Switch to drone for releases. (@mattdurham) - [ENHANCEMENT] Update OTel dependency to v0.29.0 (@mapno) From d12859709e242342619399f0ad5335ba153c3df6 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 22:32:29 -0400 Subject: [PATCH 053/101] comments Former-commit-id: 4ce65c6e508d9bb6268e6129e5736526202893ae --- Makefile | 90 ++++++++++++++++++++++++++++++++++++--------- tools/test-packages | 4 +- 2 files changed, 74 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 5ad19472e78a..0c7fb00600a7 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ TARGETPLATFORM ?= normal # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, # and seego is used for building binaries instead of go. -CROSS_BUILD ?= true +CROSS_BUILD ?= false # Certain aspects of the build are done in containers for consistency. # If you have the correct tools installed and want to speed up development, @@ -52,7 +52,6 @@ GO_FLAGS = $(DEBUG_GO_FLAGS) endif NETGO_CHECK = @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ - rm $@; \ echo "\nYour go standard library was built without the 'netgo' build tag."; \ echo "To fix that, run"; \ echo " sudo go clean -i net"; \ @@ -80,6 +79,22 @@ ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) endif +seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" grafana/agent/seego + +ifeq ($(DRONE),true) +ifeq ($(TARGETPLATFORM),linux/amd64) +CGO_CC_CCX = export GO111MODULE=auto CC=gcc CCX=g++; go +endif +ifeq ($(TARGETPLATFORM),linux/arm64) +CGO_CC_CCX = export CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go +endif +ifeq ($(TARGETPLATFORM),linux/arm/v7) +CGO_CC_CCX = export CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go +endif +ifeq ($(TARGETPLATFORM),linux/arm/v6) +CGO_CC_CCX = export CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; +endif +endif # Set the CGO, CC, CCX flags based on targetplatform, if non given assume 'native' to the device CGO_CC_CCX = export CGO_ENABLED=1 GO111MODULE=auto @@ -232,48 +247,87 @@ dist: dist-agent dist-agentctl dist-packages dist-agent: dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe dist/agent-linux-amd64: - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv6: - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv7: - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-mipsle: - export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++;go build $(CGO_FLAGS) -o $@ ./cmd/agent +ifeq ($(DRONE),true) + export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agent +else + export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent +endif dist/agent-darwin-amd64: +ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-darwin-arm64: +else + export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent +endif +dist/agent-darwin-arm64: +ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-windows-amd64.exe: - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent +else + export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent +endif +dist/agent-windows-amd64.exe: +ifeq ($(DRONE),true) + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent +else + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent +endif dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe cp dist/agent-windows-amd64.exe ./packaging/windows cp LICENSE ./packaging/windows makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis -dist/agent-freebsd-amd64: +dist/agent-freebsd-amd64: +ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agent +else + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent +endif dist-agentctl: dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 dist/agentctl-linux-amd64: - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc CCX=g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-arm64: - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv6: - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv7: - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-mipsle: +ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +else + export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl +endif dist/agentctl-darwin-amd64: +ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +else + export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl +endif dist/agentctl-darwin-arm64: - export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +ifeq ($(DRONE),true) + export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +else + export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl +endif dist/agentctl-windows-amd64.exe: - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +ifeq ($(DRONE),true) + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +else + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl +endif dist/agentctl-freebsd-amd64: +ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl - +else + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl +endif build-image/.uptodate: build-image/Dockerfile docker pull $(BUILD_IMAGE) || docker build -t $(BUILD_IMAGE) $(@D) diff --git a/tools/test-packages b/tools/test-packages index 019964d142be..503b90670ce8 100755 --- a/tools/test-packages +++ b/tools/test-packages @@ -40,5 +40,5 @@ function test_with_systemd() { docker exec -i "${container}" /bin/bash -c "${remove_command}" } -test_with_systemd "${IMAGE_PREFIX}"/centos-systemd "rpm -i /dist/grafana-agent-${VERSION}-${RELEASE}.x86_64.rpm" "rpm -e grafana-agent" -test_with_systemd "${IMAGE_PREFIX}"/debian-systemd "dpkg -i /dist/grafana-agent-${VERSION}-${RELEASE}.x86_64.deb" "dpkg -r grafana-agent" +test_with_systemd "${IMAGE_PREFIX}"/centos-systemd "rpm -i /dist/grafana-agent-${VERSION}-${RELEASE}.amd64.rpm" "rpm -e grafana-agent" +test_with_systemd "${IMAGE_PREFIX}"/debian-systemd "dpkg -i /dist/grafana-agent-${VERSION}-${RELEASE}.amd64.deb" "dpkg -r grafana-agent" From d656dba7c30a445772947dfb0f57a6fa6f11cad3 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 22:51:35 -0400 Subject: [PATCH 054/101] test build Former-commit-id: fbf9ecce939445eebec6ad5754bcbcd55e0a5e80 --- .drone/drone.yml | 12 ++++++------ Makefile | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 954cf3589e16..d334f28e5a2e 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -30,7 +30,7 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist + - make BUILD_IN_CONTAINER=false DRONE=true RELEASE_TAG=v0.0.0 dist --- kind: pipeline type: docker @@ -50,7 +50,7 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - make BUILD_IN_CONTAINER=false test + - make BUILD_IN_CONTAINER=false DRONE=true test --- kind: pipeline type: docker @@ -90,7 +90,7 @@ steps: - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - export PATH="$(go env GOPATH)/bin:$PATH" - RELEASE_TAG=$DRONE_TAG - - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish + - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG DRONE=true publish volumes: - name: docker @@ -127,8 +127,8 @@ steps: - chmod a+x ~/.docker/cli-plugins/docker-buildx - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker buildx create --name multiarch --driver docker-container --use - - make CROSS_BUILD=true RELEASE_BUILD=true agent-image - - make CROSS_BUILD=true RELEASE_BUILD=true agentctl-image + - make CROSS_BUILD=true RELEASE_BUILD=true DRONE=true agent-image + - make CROSS_BUILD=true RELEASE_BUILD=true DRONE=true agentctl-image - docker buildx rm multiarch volumes: @@ -137,6 +137,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 7ecbeab4e9191c2ec769bd5481d6b243ce6e72520bb9cc45a63afa2a20df5e46 +hmac: 51c1fd92a687166614a0d0560536fcfc393f8da7f0386f08ab251b7df17a7a69 ... diff --git a/Makefile b/Makefile index 0c7fb00600a7..7b404fe193b1 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) endif -seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" grafana/agent/seego +seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" rfratto/seego ifeq ($(DRONE),true) ifeq ($(TARGETPLATFORM),linux/amd64) From c82b874a5e3721c4432209942c1ea3076d8480fc Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 22:56:17 -0400 Subject: [PATCH 055/101] test build Former-commit-id: 1a845d8169a7c0ac5691024012e02fa0ea181bec --- Makefile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 7b404fe193b1..846d87dd2ad1 100644 --- a/Makefile +++ b/Makefile @@ -83,16 +83,16 @@ seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABL ifeq ($(DRONE),true) ifeq ($(TARGETPLATFORM),linux/amd64) -CGO_CC_CCX = export GO111MODULE=auto CC=gcc CCX=g++; go +seego = export GO111MODULE=auto CC=gcc CCX=g++; go endif ifeq ($(TARGETPLATFORM),linux/arm64) -CGO_CC_CCX = export CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go +seego = export CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go endif ifeq ($(TARGETPLATFORM),linux/arm/v7) -CGO_CC_CCX = export CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go +seego = export CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go endif ifeq ($(TARGETPLATFORM),linux/arm/v6) -CGO_CC_CCX = export CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; +seego = export CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go endif endif @@ -100,16 +100,16 @@ endif CGO_CC_CCX = export CGO_ENABLED=1 GO111MODULE=auto ifeq ($(TARGETPLATFORM),linux/amd64) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ ; +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ endif ifeq ($(TARGETPLATFORM),linux/arm64) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++ endif ifeq ($(TARGETPLATFORM),linux/arm/v7) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++ endif ifeq ($(TARGETPLATFORM),linux/arm/v6) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; endif @@ -167,12 +167,12 @@ agent-operator: cmd/agent-operator/agent-operator # TargetPlatform is set by the buildx cmd/agent/agent: cmd/agent/main.go - $(CGO_CC_CCX) go build $(CGO_FLAGS) -o $@ ./$(@D) + $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) cmd/agentctl/agentctl: cmd/agentctl/main.go - $(CGO_CC_CCX) go build $(CGO_FLAGS) -o $@ ./$(@D) + $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) From a246bf50ef89f3ce9eb596af370f8b52edbfc40b Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 22:59:27 -0400 Subject: [PATCH 056/101] test build Former-commit-id: 57c03502f9015b1b30b3d07b4e92168b2b78bc4d --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 846d87dd2ad1..1d1d68783b68 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ SHELL = /usr/bin/env bash IMAGE_PREFIX ?= mrdgrafana IMAGE_TAG ?= $(shell ./tools/image-tag) TARGETPLATFORM ?= normal +DRONE ?= false # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, From 4bf20287358a803a445de69dacf597c136cfd48c Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 23:20:58 -0400 Subject: [PATCH 057/101] test build Former-commit-id: 75305d795d361233d7678397644236370bc121a1 --- .drone/drone.yml | 11 +-- .drone/go_wrapper.sh | 161 +++++++++++++++++++++++++++++++++++++++++++ Makefile | 19 ++--- 3 files changed, 172 insertions(+), 19 deletions(-) create mode 100644 .drone/go_wrapper.sh diff --git a/.drone/drone.yml b/.drone/drone.yml index d334f28e5a2e..1e8f6086e558 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -30,7 +30,8 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - make BUILD_IN_CONTAINER=false DRONE=true RELEASE_TAG=v0.0.0 dist + - export DRONE=true + - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist --- kind: pipeline type: docker @@ -50,7 +51,8 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - make BUILD_IN_CONTAINER=false DRONE=true test + - export DRONE=true + - make BUILD_IN_CONTAINER=false test --- kind: pipeline type: docker @@ -90,7 +92,8 @@ steps: - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - export PATH="$(go env GOPATH)/bin:$PATH" - RELEASE_TAG=$DRONE_TAG - - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG DRONE=true publish + - export DRONE=true + - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish volumes: - name: docker @@ -137,6 +140,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 51c1fd92a687166614a0d0560536fcfc393f8da7f0386f08ab251b7df17a7a69 +hmac: 4224ec002ff93f34e5d432a3b93ca884081ca707b9f435b6097509d7e7e42d77 ... diff --git a/.drone/go_wrapper.sh b/.drone/go_wrapper.sh new file mode 100644 index 000000000000..91383be678d9 --- /dev/null +++ b/.drone/go_wrapper.sh @@ -0,0 +1,161 @@ +#!/usr/bin/env bash + +FOUND_CC="" +FOUND_CXX="" +FOUND_LD_PATH="" +CC_EXTRA="" +CXX_EXTRA="" + +CGO_ENABLED=${CGO_ENABLED:-$(go env CGO_ENABLED)} +GOARCH=$(go env GOARCH) +GOOS=$(go env GOOS) +GOARM=$(go env GOARM) + +main() { + echo ">>> discovering toolchain for GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM}" + + case "$GOOS" in + linux) configure_linux ;; + darwin) configure_darwin ;; + freebsd) configure_bsd ;; + windows) configure_windows ;; + *) + echo ">>> ERROR: unsupported GOOS value $GOOS" + exit 1 + esac + + echo ">>> discovered CC ${FOUND_CC}" + echo ">>> discovered CXX ${FOUND_CXX}" + echo ">>> extra C flags: ${CC_EXTRA}" + + echo ">>> CGO_ENABLED=${CGO_ENABLED} CC=$FOUND_CC CXX=$FOUND_CXX go $@" + + # If we run go directly, any files created on the bind mount + # will have awkward ownership. So we switch to a user with the + # same user and group IDs as source directory. We have to set a + # few things up so that sudo works without complaining later on. + uid=$(stat --format="%u" $(pwd)) + gid=$(stat --format="%g" $(pwd)) + echo "seego:x:$uid:$gid::$(pwd):/bin/bash" >>/etc/passwd + echo "seego:*:::::::" >>/etc/shadow + echo "seego ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers + + # I'm skeptical that this is the best way to do it because it's so + # annoying, but it works at least. + # + # Export environment variables we want to retain when running go + # as the new user. Even though we preserve the path, we have to use + # the full path to go since sudo won't read the PATH for it. + + export CC="$FOUND_CC $CC_EXTRA" + export CXX="$FOUND_CXX $CC_EXTRA" + + export CGO_CFLAGS=$CC_EXTRA + export CGO_CXX_CFLAGS=$CC_EXTRA + export CGO_LDFLAGS=$CC_EXTRA + + export PATH=$PATH + if [ ! -z "$FOUND_LD_PATH" ]; then + export LD_LIBRARY_PATH="$FOUND_LD_PATH:$LD_LIBRARY_PATH" + fi + + export GOCACHE=$(pwd)/.cache + + exec sudo -E \ + --preserve-env=PATH \ + --preserve-env=LD_LIBRARY_PATH \ + -u seego -- $(which go) "$@" +} + +configure_linux() { + toolchain_prefix="" + + case "$GOARCH" in + # Do nothing for native archs + amd64 | 386) ;; + + arm) toolchain_prefix="arm-linux-gnueabi-" ;; + arm64) toolchain_prefix="aarch64-linux-gnu-" ;; + + ppc64) toolchain_prefix="powerpc-linux-gnu-" ;; + ppc64le) toolchain_prefix="powerpc64le-linux-gnu-" ;; + + mips) toolchain_prefix="mips-linux-gnu-" ;; + mipsle) toolchain_prefix="mipsel-linux-gnu-" ;; + mips64) toolchain_prefix="mips64-linux-gnuabi64-" ;; + mips64le) toolchain_prefix="mips64el-linux-gnuabi64-" ;; + + s390x) toolchain_prefix="s390x-linux-gnu-" ;; + + *) + echo ">>> ERROR: unsupported linux GOARCH value $GOARCH" + echo ">>> supported values: amd64, 386, arm, arm64, ppc64, ppc64le, mips, mipsle, mips64, mips64le, s390x" + exit 1 + esac + + if [ "$GOARCH" == "arm" ] && [ "$GOARM" == "7" ]; then + toolchain_prefix="arm-linux-gnueabihf-" + fi + + FOUND_CC="${toolchain_prefix}gcc" + FOUND_CXX="${toolchain_prefix}g++" +} + +configure_darwin() { + case "$GOARCH" in + amd64) + FOUND_CC="x86_64-apple-darwin20.2-clang" + FOUND_CXX="x86_64-apple-darwin20.2-clang++" + FOUND_LD_PATH="$OSXCROSS_PATH/lib" + ;; + arm64) + FOUND_CC="arm64-apple-darwin20.2-clang" + FOUND_CXX="arm64-apple-darwin20.2-clang++" + FOUND_LD_PATH="$OSXCROSS_PATH/lib" + ;; + *) + echo ">>> ERROR: unsupported darwin GOARCH value $GOARCH" + echo ">>> supported values: amd64, arm64" + exit 1 + esac +} + +configure_bsd() { + case "$GOARCH" in + amd64) + FOUND_CC="clang" + FOUND_CXX="clang++" + CC_EXTRA="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" + ;; + 386) + FOUND_CC="clang" + FOUND_CXX="clang++" + CC_EXTRA="-target i386-pc-freebsd11 --sysroot=/usr/freebsd/i386-pc-freebsd11 -v" + ;; + + *) + echo ">>> ERROR: unsupported bsd GOARCH value $GOARCH" + echo ">>> supported values: amd64, 386" + exit 1 + esac +} + +configure_windows() { + case "$GOARCH" in + 386) + FOUND_CC="i686-w64-mingw32-gcc" + FOUND_CXX="i686-w64-mingw32-g++" + ;; + amd64) + FOUND_CC="x86_64-w64-mingw32-gcc" + FOUND_CXX="x86_64-w64-mingw32-g++" + ;; + + *) + echo ">>> ERROR: unsupported windows GOARCH value $GOARCH" + echo ">>> supported values: 386, amd64" + exit 1 + esac +} + +main "$@" \ No newline at end of file diff --git a/Makefile b/Makefile index 1d1d68783b68..38d2fed2c1c9 100644 --- a/Makefile +++ b/Makefile @@ -81,22 +81,11 @@ DOCKERFILE = Dockerfile.buildx docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) endif seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" rfratto/seego - +$(info DRONE is $(DRONE)) ifeq ($(DRONE),true) -ifeq ($(TARGETPLATFORM),linux/amd64) -seego = export GO111MODULE=auto CC=gcc CCX=g++; go -endif -ifeq ($(TARGETPLATFORM),linux/arm64) -seego = export CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++; go -endif -ifeq ($(TARGETPLATFORM),linux/arm/v7) -seego = export CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go -endif -ifeq ($(TARGETPLATFORM),linux/arm/v6) -seego = export CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; go + seego = bash ./go_wrapper.sh go endif -endif - +$(info seego is $(seego)) # Set the CGO, CC, CCX flags based on targetplatform, if non given assume 'native' to the device CGO_CC_CCX = export CGO_ENABLED=1 GO111MODULE=auto @@ -110,7 +99,7 @@ ifeq ($(TARGETPLATFORM),linux/arm/v7) CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++ endif ifeq ($(TARGETPLATFORM),linux/arm/v6) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++; +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++ endif From ed06d3ad017d7edd50ba37f8d9eefb7b35782c6e Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 12 Jul 2021 23:31:49 -0400 Subject: [PATCH 058/101] test build Former-commit-id: 76b79a46ee44fc2214ee43b9c5bb77be3c5b9a05 --- .drone/drone.yml | 9 +++------ Makefile | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 1e8f6086e558..954cf3589e16 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -30,7 +30,6 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - export DRONE=true - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist --- kind: pipeline @@ -51,7 +50,6 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - export DRONE=true - make BUILD_IN_CONTAINER=false test --- kind: pipeline @@ -92,7 +90,6 @@ steps: - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - export PATH="$(go env GOPATH)/bin:$PATH" - RELEASE_TAG=$DRONE_TAG - - export DRONE=true - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish volumes: @@ -130,8 +127,8 @@ steps: - chmod a+x ~/.docker/cli-plugins/docker-buildx - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker buildx create --name multiarch --driver docker-container --use - - make CROSS_BUILD=true RELEASE_BUILD=true DRONE=true agent-image - - make CROSS_BUILD=true RELEASE_BUILD=true DRONE=true agentctl-image + - make CROSS_BUILD=true RELEASE_BUILD=true agent-image + - make CROSS_BUILD=true RELEASE_BUILD=true agentctl-image - docker buildx rm multiarch volumes: @@ -140,6 +137,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 4224ec002ff93f34e5d432a3b93ca884081ca707b9f435b6097509d7e7e42d77 +hmac: 7ecbeab4e9191c2ec769bd5481d6b243ce6e72520bb9cc45a63afa2a20df5e46 ... diff --git a/Makefile b/Makefile index 38d2fed2c1c9..0a2864e1a099 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ endif seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" rfratto/seego $(info DRONE is $(DRONE)) ifeq ($(DRONE),true) - seego = bash ./go_wrapper.sh go + seego = bash ./.drone/go_wrapper.sh endif $(info seego is $(seego)) # Set the CGO, CC, CCX flags based on targetplatform, if non given assume 'native' to the device From 9efcadada126c5af74ce02fe4ee80a413bda5f11 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 13 Jul 2021 09:28:24 -0400 Subject: [PATCH 059/101] test build Former-commit-id: 9517eaea078fcf0dc9dd0a0c05726e5cca5e3b4a --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0a2864e1a099..c5ea56d22ae9 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ DOCKER_BUILD_FLAGS = --build-arg RELEASE_BUILD=$(RELEASE_BUILD) --build-arg IMAG # We need a separate set of flags for CGO, where building with -static can # cause problems with some C libraries. -CGO_FLAGS := -ldflags="-s -w $(GO_LDFLAGS)" -tags 'netgo' +CGO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "netgo" DEBUG_CGO_FLAGS := -gcflags "all=-N -l" -ldflags "-s -w $(GO_LDFLAGS)" -tags "netgo" # If we're not building the release, use the debug flags instead. ifeq ($(RELEASE_BUILD),false) @@ -201,7 +201,7 @@ test: CGO_ENABLED=1 go test $(CGO_FLAGS) -cover -coverprofile=cover-norace.out -p=4 ./pkg/integrations/node_exporter ./pkg/loki clean: - rm -r -f cmd/agent/agent + rm -rf cmd/agent/agent go clean ./... example-kubernetes: From 17288261f58cb9f1f087a3357b5146cc58b6df3e Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 13 Jul 2021 10:13:51 -0400 Subject: [PATCH 060/101] test build Former-commit-id: 9f57b5dd0c74b60f7584c42314b7f8eee8e83116 --- .gitignore | 1 + Governance.md | 2 +- Makefile | 39 +++++++++++++++++++++++++++++++++------ tools/seego/Dockerfile | 5 +---- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index fe6908e99d45..85e730ded16e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ packaging/windows/LICENSE packaging/windows/agent-windows-amd64.exe .DS_Store +buildx-v* diff --git a/Governance.md b/Governance.md index c4b340f4dc84..c4123c67a653 100644 --- a/Governance.md +++ b/Governance.md @@ -10,7 +10,7 @@ This document describes the rules and governance of the project. It is meant to - **Maintainers**: Maintainers lead an individual project or parts thereof ([`MAINTAINERS.md`][maintainers]). - **Projects**: A single repository in the Grafana GitHub organization and listed below is referred to as a project: - - Grafana Agent + - Grafana Agent - **The Grafana Agent project**: The sum of all activities performed under this governance, concerning one or more repositories or the community. diff --git a/Makefile b/Makefile index c5ea56d22ae9..1020dfb92d45 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ CROSS_BUILD ?= false # run make BUILD_IN_CONTAINER=false , or you can set BUILD_IN_CONTAINER=true # as an environment variable. BUILD_IN_CONTAINER ?= true -BUILD_IMAGE_VERSION := 0.10.0 +BUILD_IMAGE_VERSION := 0.11.0 BUILD_IMAGE := $(IMAGE_PREFIX)/agent-build-image:$(BUILD_IMAGE_VERSION) # Enables the binary to be built with optimizations (i.e., doesn't strip the image of @@ -80,15 +80,21 @@ ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) endif + +# seego is used by default when running bare make commands such as `make dist` this uses an image that has all the necessary libraries to cross build +# when using drone the docker in docker is more problematic so instead we boot into seego and run raw commands seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" rfratto/seego -$(info DRONE is $(DRONE)) + +# If being called from the drone executable this will be set to true, in this case we want the go_wrapper to set the +# CC and CCX and other flags for the appropriate architecture ifeq ($(DRONE),true) seego = bash ./.drone/go_wrapper.sh endif -$(info seego is $(seego)) + # Set the CGO, CC, CCX flags based on targetplatform, if non given assume 'native' to the device CGO_CC_CCX = export CGO_ENABLED=1 GO111MODULE=auto +# TARGETPLATFORM is specifically called from `docker buildx --platform`, this is mainly used when pushing docker image manifests ifeq ($(TARGETPLATFORM),linux/amd64) CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ endif @@ -154,23 +160,44 @@ agent: cmd/agent/agent agentctl: cmd/agentctl/agentctl agent-operator: cmd/agent-operator/agent-operator -# TargetPlatform is set by the buildx + + +# In general DRONE variable should overwrite any other options, if DRONE is not set then fallback to normal behavior cmd/agent/agent: cmd/agent/main.go +ifeq ($(DRONE),true) $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) +else +ifeq ($(CROSS_BUILD),false) + CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) +else + @CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) +endif +endif $(NETGO_CHECK) cmd/agentctl/agentctl: cmd/agentctl/main.go +ifeq ($(DRONE),true) $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) - $(NETGO_CHECK) +else +ifeq ($(CROSS_BUILD),false) + CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) +else + @CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) +endif +endif cmd/agent-operator/agent-operator: cmd/agent-operator/main.go +ifeq ($(DRONE),true) + $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) +else ifeq ($(CROSS_BUILD),false) - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)Samsung 870 EVO + CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) else GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) +endif endif $(NETGO_CHECK) diff --git a/tools/seego/Dockerfile b/tools/seego/Dockerfile index fdee9a079990..25f7377255c0 100644 --- a/tools/seego/Dockerfile +++ b/tools/seego/Dockerfile @@ -8,7 +8,4 @@ RUN rm -rf /usr/local/go \ && curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ && tar -C /usr/local -xzf golang.tar.gz \ - && rm golang.tar.gz -COPY go_wrapper.sh / -RUN chmod +x /go_wrapper.sh -ENTRYPOINT ["/go_wrapper.sh"] + && rm golang.tar.gz \ No newline at end of file From 295525863ad943b05ef35f92600c99d3847f48d2 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 13 Jul 2021 13:20:53 -0400 Subject: [PATCH 061/101] test build Former-commit-id: 6c37355e27ab0ad77f2f8f348d94308c52bfd13b --- .github/workflows/containerize.yml | 81 ------------------ .github/workflows/release.yml | 131 ----------------------------- .github/workflows/test.yml | 54 ------------ Makefile | 98 +++++++++++++++------ tools/seego/Dockerfile | 4 +- 5 files changed, 73 insertions(+), 295 deletions(-) delete mode 100644 .github/workflows/containerize.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/containerize.yml b/.github/workflows/containerize.yml deleted file mode 100644 index d2838d1caeb9..000000000000 --- a/.github/workflows/containerize.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Containerize -on: - push: - branches: - - main -jobs: - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Get build dependencies - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.16 - uses: actions/setup-go@v1 - with: - go-version: 1.16 - id: go - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Test - run: make test - agent-container: - name: Build agent Container - runs-on: ubuntu-latest - needs: test - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Login to Docker Hub - run: docker login -u '${{ secrets.DOCKER_USER }}' -p '${{ secrets.DOCKER_PASS }}' - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Make Containers - run: CROSS_BUILD=true RELEASE_BUILD=true make agent-image - agentctl-container: - name: Build agentctl Container - runs-on: ubuntu-latest - needs: test - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Login to Docker Hub - run: docker login -u '${{ secrets.DOCKER_USER }}' -p '${{ secrets.DOCKER_PASS }}' - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Make Containers - run: CROSS_BUILD=true RELEASE_BUILD=true make agentctl-image - agent-operator-container: - name: Build agent-operator Container - runs-on: ubuntu-latest - needs: test - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Login to Docker Hub - run: docker login -u '${{ secrets.DOCKER_USER }}' -p '${{ secrets.DOCKER_PASS }}' - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Make Containers - run: CROSS_BUILD=true RELEASE_BUILD=true make agent-operator-image diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index a58882ffffa6..000000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,131 +0,0 @@ -name: Release -on: - push: - tags: - - '*' -jobs: - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Get build dependencies - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.16 - uses: actions/setup-go@v1 - with: - go-version: 1.16 - id: go - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Test - run: make test - agent-container: - name: Build agent Container - runs-on: ubuntu-latest - needs: test - steps: - - name: Get build dependencies - run: sudo apt-get update && sudo apt-get install binfmt-support qemu-user-static - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Login to Docker Hub - run: docker login -u '${{ secrets.DOCKER_USER }}' -p '${{ secrets.DOCKER_PASS }}' - - - name: Prepare buildx - run: | - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker buildx create --name builder --driver docker-container --use - docker buildx inspect --bootstrap - - - name: Build container - run: | - export RELEASE_TAG=${GITHUB_REF##*/} - CROSS_BUILD=true RELEASE_BUILD=true make agent-image - agentctl-container: - name: Build agentctl Container - runs-on: ubuntu-latest - needs: test - steps: - - name: Get build dependencies - run: sudo apt-get update && sudo apt-get install binfmt-support qemu-user-static - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Login to Docker Hub - run: docker login -u '${{ secrets.DOCKER_USER }}' -p '${{ secrets.DOCKER_PASS }}' - - - name: Prepare buildx - run: | - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker buildx create --name builder --driver docker-container --use - docker buildx inspect --bootstrap - - - name: Build container - run: | - export RELEASE_TAG=${GITHUB_REF##*/} - CROSS_BUILD=true RELEASE_BUILD=true make agentctl-image - agent-operator-container: - name: Build agent-operator Container - runs-on: ubuntu-latest - needs: test - steps: - - name: Get build dependencies - run: sudo apt-get update && sudo apt-get install binfmt-support qemu-user-static - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Login to Docker Hub - run: docker login -u '${{ secrets.DOCKER_USER }}' -p '${{ secrets.DOCKER_PASS }}' - - - name: Prepare buildx - run: | - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker buildx create --name builder --driver docker-container --use - docker buildx inspect --bootstrap - - - name: Build container - run: | - export RELEASE_TAG=${GITHUB_REF##*/} - CROSS_BUILD=true RELEASE_BUILD=true make agent-operator-image - release: - name: Release - needs: test - runs-on: ubuntu-latest - steps: - - name: Get build dependencies - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.16 - uses: actions/setup-go@v1 - with: - go-version: 1.16 - id: go - - - name: Install gox and ghr - run: | - pushd / - GO111MODULE=on go get -u \ - github.com/mitchellh/gox \ - github.com/tcnksm/ghr - popd - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Make Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # This is required so gox and ghr are available - export PATH="$(go env GOPATH)/bin:$PATH" - - export RELEASE_TAG=${GITHUB_REF##*/} - - make -j4 RELEASE_BUILD=true publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 861e06a06d3b..000000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Test -on: [pull_request] -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Get build dependencies - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.16 - uses: actions/setup-go@v1 - with: - go-version: 1.16 - id: go - - name: Install golangci-lint - run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/local/bin v1.37.1 - - name: Checkout code - uses: actions/checkout@v2 - - name: Lint - run: make lint - - test: - name: Test - strategy: - matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.platform }} - steps: - - name: Get build dependencies - run: sudo apt-get update && sudo apt-get install libsystemd-dev - if: matrix.platform == 'ubuntu-latest' - - - name: Set up Go 1.16 - uses: actions/setup-go@v1 - with: - go-version: 1.16 - id: go - - name: Checkout code - uses: actions/checkout@v2 - - name: Build - run: make cmd/agent/agent cmd/agentctl/agentctl cmd/agent-operator/agent-operator - - name: Test - run: make test - - package: - name: Test Packages - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Test Packages - run: RELEASE_TAG=v0.0.0 make test-packages diff --git a/Makefile b/Makefile index 1020dfb92d45..966259f40f44 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ IMAGE_PREFIX ?= mrdgrafana IMAGE_TAG ?= $(shell ./tools/image-tag) TARGETPLATFORM ?= normal DRONE ?= false +# This is normally set by the caller but when building the agent windows installer it needs to be set to something +RELEASE_TAG ?= v0.0.0 # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, @@ -83,7 +85,7 @@ endif # seego is used by default when running bare make commands such as `make dist` this uses an image that has all the necessary libraries to cross build # when using drone the docker in docker is more problematic so instead we boot into seego and run raw commands -seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" rfratto/seego +seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" grafana/agent/seego # If being called from the drone executable this will be set to true, in this case we want the go_wrapper to set the # CC and CCX and other flags for the appropriate architecture @@ -164,7 +166,8 @@ agent-operator: cmd/agent-operator/agent-operator # In general DRONE variable should overwrite any other options, if DRONE is not set then fallback to normal behavior -cmd/agent/agent: cmd/agent/main.go + +cmd/agent/agent: check-seego cmd/agent/main.go ifeq ($(DRONE),true) $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) else @@ -177,7 +180,7 @@ endif $(NETGO_CHECK) -cmd/agentctl/agentctl: cmd/agentctl/main.go +cmd/agentctl/agentctl: check-seego cmd/agentctl/main.go ifeq ($(DRONE),true) $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) else @@ -225,7 +228,7 @@ lint: # for packages that have known race detection issues test: CGO_ENABLED=1 go test $(CGO_FLAGS) -race -cover -coverprofile=cover.out -p=4 ./... - CGO_ENABLED=1 go test $(CGO_FLAGS) -cover -coverprofile=cover-norace.out -p=4 ./pkg/integrations/node_exporter ./pkg/loki + CGO_ENABLED=1 go test $(CGO_FLAGS) -cover -coverprofile=cover-norace.out -p=4 ./pkg/integrations/node_exporter ./pkg/logs clean: rm -rf cmd/agent/agent @@ -262,83 +265,122 @@ dist: dist-agent dist-agentctl dist-packages pushd dist && sha256sum * > SHA256SUMS && popd .PHONY: dist -dist-agent: dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe -dist/agent-linux-amd64: +dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe + +dist/agent-linux-amd64: seego export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-arm64: + +dist/agent-linux-arm64: seego export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-armv6: + +dist/agent-linux-armv6: seego export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-armv7: + +dist/agent-linux-armv7: seego export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -dist/agent-linux-mipsle: + +dist/agent-linux-mipsle: seego ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agent else export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif -dist/agent-darwin-amd64: + +dist/agent-darwin-amd64: seego ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent else export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif -dist/agent-darwin-arm64: + +dist/agent-darwin-arm64: seego ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent else export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif -dist/agent-windows-amd64.exe: + +dist/agent-windows-amd64.exe: seego ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent else export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif + dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe - cp dist/agent-windows-amd64.exe ./packaging/windows - cp LICENSE ./packaging/windows - makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis -dist/agent-freebsd-amd64: +ifeq ($(DRONE),true) + cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis +else +ifeq ($(BUILD_IN_CONTAINER),true) + docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" --entrypoint "cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT=../../dist/grafana-agent-installer.exe ./packaging/windows/install_script.nsis" grafana/agent/seego +else + cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis +endif +endif + +dist/agent-freebsd-amd64: seego ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agent else export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif -dist-agentctl: dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 -dist/agentctl-linux-amd64: +dist-agentctl: seego dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 + +dist/agentctl-linux-amd64: seego export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-arm64: + +dist/agentctl-linux-arm64: seego export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-armv6: + +dist/agentctl-linux-armv6: seego export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-armv7: + +dist/agentctl-linux-armv7: seego export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-linux-mipsle: + +dist/agentctl-linux-mipsle: seego ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif -dist/agentctl-darwin-amd64: + +dist/agentctl-darwin-amd64: seego ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif -dist/agentctl-darwin-arm64: + +dist/agentctl-darwin-arm64: seego ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else - export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif -dist/agentctl-windows-amd64.exe: + +dist/agentctl-windows-amd64.exe: seego ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl +endif + +seego: tools/seego/Dockerfile +ifeq ($(DRONE), false) + docker build -t grafana/agent/seego tools/seego +endif + +# Makes seego if CROSS_BUILD is true. +check-seego: +ifeq ($(DRONE),false) +ifeq ($(CROSS_BUILD),true) +ifeq ($(BUILD_IN_CONTAINER),true) + $(MAKE) seego +endif +endif endif + dist/agentctl-freebsd-amd64: ifeq ($(DRONE),true) export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl @@ -453,7 +495,7 @@ endif enforce-release-tag: @sh -c '[ -n "${RELEASE_TAG}" ] || (echo \$$RELEASE_TAG environment variable not set; exit 1)' -test-packages: enforce-release-tag dist-packages-amd64 packaging/centos-systemd/.uptodate packaging/debian-systemd/.uptodate +test-packages: enforce-release-tag seego dist-packages-amd64 packaging/centos-systemd/.uptodate packaging/debian-systemd/.uptodate ./tools/test-packages $(IMAGE_PREFIX) $(PACKAGE_VERSION) $(PACKAGE_RELEASE) .PHONY: test-package diff --git a/tools/seego/Dockerfile b/tools/seego/Dockerfile index 25f7377255c0..2bb4f3a8a771 100644 --- a/tools/seego/Dockerfile +++ b/tools/seego/Dockerfile @@ -8,4 +8,6 @@ RUN rm -rf /usr/local/go \ && curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ && tar -C /usr/local -xzf golang.tar.gz \ - && rm golang.tar.gz \ No newline at end of file + && rm golang.tar.gz +RUN apt-get update +RUN apt-get install -y nsis \ No newline at end of file From a068161b050aa58d2b9ce884721567c1b081d6a9 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 13 Jul 2021 13:23:05 -0400 Subject: [PATCH 062/101] test build Former-commit-id: 738b53b67ee7667a4a85a0a128ad0bc2196f9d9d --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 966259f40f44..ad749dfdeda5 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SHELL = /usr/bin/env bash ############# # Docker image info -IMAGE_PREFIX ?= mrdgrafana +IMAGE_PREFIX ?= grafana IMAGE_TAG ?= $(shell ./tools/image-tag) TARGETPLATFORM ?= normal DRONE ?= false From 9dae635afb828ed9345c9c3111259e46c4d26d2c Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 13 Jul 2021 13:44:06 -0400 Subject: [PATCH 063/101] test build Former-commit-id: d3a389e78ec6b5536caabb2b0f96d6d2b8f02038 --- Makefile | 145 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 68 deletions(-) diff --git a/Makefile b/Makefile index ad749dfdeda5..b6a6532239cd 100644 --- a/Makefile +++ b/Makefile @@ -8,11 +8,29 @@ SHELL = /usr/bin/env bash # Docker image info IMAGE_PREFIX ?= grafana IMAGE_TAG ?= $(shell ./tools/image-tag) -TARGETPLATFORM ?= normal DRONE ?= false # This is normally set by the caller but when building the agent windows installer it needs to be set to something RELEASE_TAG ?= v0.0.0 +# Set the CGO, CC, CCX flags based on targetplatform, if non given assume 'native' to the device +CGO_CC_CCX = export CGO_ENABLED=1 GO111MODULE=auto + +# TARGETPLATFORM is specifically called from `docker buildx --platform`, this is mainly used when pushing docker image manifests, normal generally means NON DRONE builds +TARGETPLATFORM ?= normal +ifeq ($(TARGETPLATFORM),linux/amd64) +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ +endif +ifeq ($(TARGETPLATFORM),linux/arm64) +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++ +endif +ifeq ($(TARGETPLATFORM),linux/arm/v7) +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++ +endif +ifeq ($(TARGETPLATFORM),linux/arm/v6) +CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++ +endif + + # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, # and seego is used for building binaries instead of go. @@ -55,11 +73,12 @@ GO_FLAGS = $(DEBUG_GO_FLAGS) endif NETGO_CHECK = @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ - echo "\nYour go standard library was built without the 'netgo' build tag."; \ - echo "To fix that, run"; \ - echo " sudo go clean -i net"; \ - echo " sudo go install -tags netgo std"; \ - false; \ + rm $@; \ + echo "\nYour go standard library was built without the 'netgo' build tag."; \ + echo "To fix that, run"; \ + echo " sudo go clean -i net"; \ + echo " sudo go install -tags netgo std"; \ + false; \ } # Protobuf files @@ -77,41 +96,22 @@ PACKAGE_RELEASE := 1 DOCKERFILE = Dockerfile + +# seego is used by default when running bare make commands such as `make dist` this uses an image that has all the necessary libraries to cross build +# when using drone the docker in docker is more problematic so instead drone uses seego has the base image then calls make running "raw" commands +seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" -e "GOMIPS=$$GOMIPS" grafana/agent/seego docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx -docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 $(DOCKER_BUILD_FLAGS) +docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) endif -# seego is used by default when running bare make commands such as `make dist` this uses an image that has all the necessary libraries to cross build -# when using drone the docker in docker is more problematic so instead we boot into seego and run raw commands -seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" grafana/agent/seego - # If being called from the drone executable this will be set to true, in this case we want the go_wrapper to set the # CC and CCX and other flags for the appropriate architecture ifeq ($(DRONE),true) seego = bash ./.drone/go_wrapper.sh endif -# Set the CGO, CC, CCX flags based on targetplatform, if non given assume 'native' to the device -CGO_CC_CCX = export CGO_ENABLED=1 GO111MODULE=auto - -# TARGETPLATFORM is specifically called from `docker buildx --platform`, this is mainly used when pushing docker image manifests -ifeq ($(TARGETPLATFORM),linux/amd64) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ -endif -ifeq ($(TARGETPLATFORM),linux/arm64) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++ -endif -ifeq ($(TARGETPLATFORM),linux/arm/v7) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++ -endif -ifeq ($(TARGETPLATFORM),linux/arm/v6) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++ -endif - - - ######## # CRDs # ######## @@ -172,9 +172,9 @@ ifeq ($(DRONE),true) $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) else ifeq ($(CROSS_BUILD),false) - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) + CGO_ENABLED=1 go build $(CGO_FLAGS) -o $@ ./$(@D) else - @CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) + CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) endif endif $(NETGO_CHECK) @@ -185,9 +185,9 @@ ifeq ($(DRONE),true) $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) else ifeq ($(CROSS_BUILD),false) - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) + CGO_ENABLED=1 go build $(CGO_FLAGS) -o $@ ./$(@D) else - @CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) + CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) endif endif @@ -265,46 +265,50 @@ dist: dist-agent dist-agentctl dist-packages pushd dist && sha256sum * > SHA256SUMS && popd .PHONY: dist -dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe +#################### +# BEGIN AGENT DIST # +#################### + +dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe dist/agent-linux-amd64: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv6: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv7: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-mipsle: seego ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif dist/agent-darwin-amd64: seego ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif dist/agent-darwin-arm64: seego ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif dist/agent-windows-amd64.exe: seego ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe @@ -312,7 +316,7 @@ ifeq ($(DRONE),true) cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis else ifeq ($(BUILD_IN_CONTAINER),true) - docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" --entrypoint "cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT=../../dist/grafana-agent-installer.exe ./packaging/windows/install_script.nsis" grafana/agent/seego + docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" --entrypoint "cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT=../../dist/grafana-agent-installer.exe ./packaging/windows/install_script.nsis" grafana/agent/seego else cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis endif @@ -320,52 +324,64 @@ endif dist/agent-freebsd-amd64: seego ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif + +####################### +# BEGIN AGENTCTL DIST # +####################### + dist-agentctl: seego dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 dist/agentctl-linux-amd64: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-arm64: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv6: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv7: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-mipsle: seego ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else - export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif dist/agentctl-darwin-amd64: seego ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else - export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif dist/agentctl-darwin-arm64: seego ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else endif dist/agentctl-windows-amd64.exe: seego ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif +dist/agentctl-freebsd-amd64: +ifeq ($(DRONE),true) + CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl +else + CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl +endif + seego: tools/seego/Dockerfile ifeq ($(DRONE), false) docker build -t grafana/agent/seego tools/seego @@ -381,13 +397,6 @@ endif endif endif -dist/agentctl-freebsd-amd64: -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -else - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -endif - build-image/.uptodate: build-image/Dockerfile docker pull $(BUILD_IMAGE) || docker build -t $(BUILD_IMAGE) $(@D) touch $@ From a70f516b3b04ef614dd9cc4fe18f42aa03f4837e Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 13 Jul 2021 14:45:43 -0400 Subject: [PATCH 064/101] Cleanup Former-commit-id: c44965e65f3aaf350408495704c63b7a4f3904c2 --- .drone/drone.yml | 10 ++++----- Makefile | 56 ++++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 954cf3589e16..6665815434c0 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -30,7 +30,7 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - make BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist + - make DRONE=true BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist --- kind: pipeline type: docker @@ -50,7 +50,7 @@ steps: - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - make BUILD_IN_CONTAINER=false test + - make DRONE=true BUILD_IN_CONTAINER=false test --- kind: pipeline type: docker @@ -127,8 +127,8 @@ steps: - chmod a+x ~/.docker/cli-plugins/docker-buildx - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker buildx create --name multiarch --driver docker-container --use - - make CROSS_BUILD=true RELEASE_BUILD=true agent-image - - make CROSS_BUILD=true RELEASE_BUILD=true agentctl-image + - make DRONE=true CROSS_BUILD=true RELEASE_BUILD=true agent-image + - make DRONE=true CROSS_BUILD=true RELEASE_BUILD=true agentctl-image - docker buildx rm multiarch volumes: @@ -137,6 +137,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 7ecbeab4e9191c2ec769bd5481d6b243ce6e72520bb9cc45a63afa2a20df5e46 +hmac: 4068ab750b156d97a68a5a0cdda0ca71f21d2bad13208bc1cdffdab1cf246e52 ... diff --git a/Makefile b/Makefile index b6a6532239cd..eabe690759dc 100644 --- a/Makefile +++ b/Makefile @@ -272,43 +272,43 @@ dist: dist-agent dist-agentctl dist-packages dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe dist/agent-linux-amd64: seego - CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: seego - CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv6: seego - CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv7: seego - CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-mipsle: seego ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif dist/agent-darwin-amd64: seego ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif dist/agent-darwin-arm64: seego ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif dist/agent-windows-amd64.exe: seego ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe @@ -324,9 +324,9 @@ endif dist/agent-freebsd-amd64: seego ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agent else - CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent endif @@ -337,53 +337,53 @@ endif dist-agentctl: seego dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 dist/agentctl-linux-amd64: seego - CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-arm64: seego - CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv6: seego - CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv7: seego - CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-mipsle: seego ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else - CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif dist/agentctl-darwin-amd64: seego ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else - CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif dist/agentctl-darwin-arm64: seego ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else endif dist/agentctl-windows-amd64.exe: seego ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else - CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif dist/agentctl-freebsd-amd64: ifeq ($(DRONE),true) - CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl else - CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl endif seego: tools/seego/Dockerfile -ifeq ($(DRONE), false) +ifeq ($(DRONE),false) docker build -t grafana/agent/seego tools/seego endif From 542aafed082d7ef2b4067c2954662f9e7bbacbb7 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 13 Jul 2021 15:07:24 -0400 Subject: [PATCH 065/101] Remove release.key Former-commit-id: 1f743bf78f0d99292bc2dd93c8e4b88b0b3e764a --- Release.key | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Release.key diff --git a/Release.key b/Release.key deleted file mode 100644 index e69de29bb2d1..000000000000 From 145e448b4c95102f6e8fc61195020685684753db Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 13 Jul 2021 16:23:07 -0400 Subject: [PATCH 066/101] Fix for windows installer build Former-commit-id: b8221d527e481e8ba10026daab3a53eb1b2a0d69 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index eabe690759dc..7afb2452f553 100644 --- a/Makefile +++ b/Makefile @@ -316,9 +316,9 @@ ifeq ($(DRONE),true) cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis else ifeq ($(BUILD_IN_CONTAINER),true) - docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" --entrypoint "cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT=../../dist/grafana-agent-installer.exe ./packaging/windows/install_script.nsis" grafana/agent/seego + docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" --entrypoint "cp ./dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT=../../dist/grafana-agent-installer.exe ./packaging/windows/install_script.nsis" grafana/agent/seego else - cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis + cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT./dist/grafana-agent-installer.exe ./packaging/windows/install_script.nsis endif endif From aaec782a0faf08671afb05eb1ac5247333429361 Mon Sep 17 00:00:00 2001 From: mattdurham Date: Tue, 13 Jul 2021 17:17:52 -0400 Subject: [PATCH 067/101] Allow windows installer builds Former-commit-id: a977ecbd5cef9b9e48cf2b44eafe92d00afa3d45 --- Makefile | 5 ++++- packaging/windows/Dockerfile | 8 +------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 7afb2452f553..83b337f0a83b 100644 --- a/Makefile +++ b/Makefile @@ -316,7 +316,10 @@ ifeq ($(DRONE),true) cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis else ifeq ($(BUILD_IN_CONTAINER),true) - docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" --entrypoint "cp ./dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT=../../dist/grafana-agent-installer.exe ./packaging/windows/install_script.nsis" grafana/agent/seego + cp ./dist/agent-windows-amd64.exe ./packaging/windows + cp LICENSE ./packaging/windows + docker build -t windows_installer ./packaging/windows + docker run --rm -t -v "${PWD}:/home" windows_installer else cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT./dist/grafana-agent-installer.exe ./packaging/windows/install_script.nsis endif diff --git a/packaging/windows/Dockerfile b/packaging/windows/Dockerfile index b74c81e477f8..07b8881d0776 100644 --- a/packaging/windows/Dockerfile +++ b/packaging/windows/Dockerfile @@ -1,10 +1,4 @@ FROM debian RUN apt-get update && \ apt-get install -y nsis -RUN mkdir app -WORKDIR /home -COPY logo.ico logo.ico -COPY install_script.nsis install_script.nsis -COPY agent-windows-amd64.exe agent-windows-amd64.exe -COPY LICENSE LICENSE -ENTRYPOINT makensis -V4 -DVERSION=$VERSION /home/install_script.nsis \ No newline at end of file +ENTRYPOINT makensis -V4 -DVERSION=$VERSION -DOUT="/home/dist/grafana-agent-installer.exe" /home/packaging/windows/install_script.nsis \ No newline at end of file From 93f0709d0c52df7360812ad86ab93c44f35697bb Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 11:03:08 -0400 Subject: [PATCH 068/101] Simplify makefile --- Makefile | 155 ++++++++++++++++++------------------------------------- 1 file changed, 51 insertions(+), 104 deletions(-) diff --git a/Makefile b/Makefile index 83b337f0a83b..927f12243684 100644 --- a/Makefile +++ b/Makefile @@ -12,24 +12,35 @@ DRONE ?= false # This is normally set by the caller but when building the agent windows installer it needs to be set to something RELEASE_TAG ?= v0.0.0 + +CGO_ENABLED_VAR=${CGO_ENABLED:-$(shell go env CGO_ENABLED)} + + # Set the CGO, CC, CCX flags based on targetplatform, if non given assume 'native' to the device CGO_CC_CCX = export CGO_ENABLED=1 GO111MODULE=auto # TARGETPLATFORM is specifically called from `docker buildx --platform`, this is mainly used when pushing docker image manifests, normal generally means NON DRONE builds TARGETPLATFORM ?= normal -ifeq ($(TARGETPLATFORM),linux/amd64) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=auto CC=gcc CCX=g++ -endif -ifeq ($(TARGETPLATFORM),linux/arm64) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++ -endif -ifeq ($(TARGETPLATFORM),linux/arm/v7) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++ -endif -ifeq ($(TARGETPLATFORM),linux/arm/v6) -CGO_CC_CCX = export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++ -endif +# This function sets up all the appropriate flags for a drone or local build, this is actually a list of chained if statements with the false +# condition being the next if, its reformatted to look more like a series of if elses +define SetBuildVarsConditional +export CGO_ENABLED=1 $(if $(filter $(1),linux/amd64),GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ +$(if $(filter $(1),linux/arm64),GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ +$(if $(filter $(1),linux/arm/v7),GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ +$(if $(filter $(1),linux/arm/v6),GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ +$(if $(filter $(1),darwin/amd64),GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ +$(if $(filter $(1),darwin/arm64),GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ +$(if $(filter $(1),windows),GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++, \ +$(if $(filter $(1),mipls),GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++, \ +$(if $(filter $(1),freebsd),GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" , $(error invalid flag $(1))) \ +)))))))) +endef + + +ifneq ($(TARGETPLATFORM),normal) +ALL_CGO_BUILD_FLAGS = $(call SetBuildVarsConditional $(TARGETPLATFORM)) +endif # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, @@ -68,9 +79,9 @@ DOCKER_BUILD_FLAGS = --build-arg RELEASE_BUILD=$(RELEASE_BUILD) --build-arg IMAG CGO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "netgo" DEBUG_CGO_FLAGS := -gcflags "all=-N -l" -ldflags "-s -w $(GO_LDFLAGS)" -tags "netgo" # If we're not building the release, use the debug flags instead. -ifeq ($(RELEASE_BUILD),false) +#ifeq ($(RELEASE_BUILD),false) GO_FLAGS = $(DEBUG_GO_FLAGS) -endif +#endif NETGO_CHECK = @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ rm $@; \ @@ -104,12 +115,11 @@ docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) +# docker-build = docker buildx build --push --platform linux/arm64 $(DOCKER_BUILD_FLAGS) endif -# If being called from the drone executable this will be set to true, in this case we want the go_wrapper to set the -# CC and CCX and other flags for the appropriate architecture -ifeq ($(DRONE),true) - seego = bash ./.drone/go_wrapper.sh +ifeq ($(CROSS_BUILD),false) +seego = go endif ######## @@ -168,40 +178,17 @@ agent-operator: cmd/agent-operator/agent-operator # In general DRONE variable should overwrite any other options, if DRONE is not set then fallback to normal behavior cmd/agent/agent: check-seego cmd/agent/main.go -ifeq ($(DRONE),true) - $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) -else -ifeq ($(CROSS_BUILD),false) - CGO_ENABLED=1 go build $(CGO_FLAGS) -o $@ ./$(@D) -else - CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) -endif -endif + $(ALL_CGO_BUILD_FLAGS) ; $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) cmd/agentctl/agentctl: check-seego cmd/agentctl/main.go -ifeq ($(DRONE),true) - $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) -else -ifeq ($(CROSS_BUILD),false) - CGO_ENABLED=1 go build $(CGO_FLAGS) -o $@ ./$(@D) -else - CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM); $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) -endif -endif + $(ALL_CGO_BUILD_FLAGS) ; $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) + $(NETGO_CHECK) cmd/agent-operator/agent-operator: cmd/agent-operator/main.go -ifeq ($(DRONE),true) - $(CGO_CC_CCX); go build $(CGO_FLAGS) -o $@ ./$(@D) -else -ifeq ($(CROSS_BUILD),false) - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) -else - GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) -endif -endif + $(ALL_CGO_BUILD_FLAGS) ; $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) @@ -270,46 +257,29 @@ dist: dist-agent dist-agentctl dist-packages #################### dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe - dist/agent-linux-amd64: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,linux/amd64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,linux/arm64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv6: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,linux/arm/v6) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv7: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,linux/arm/v7) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-mipsle: seego -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agent -else - export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -endif + $(call SetBuildVarsConditional,linux/mipsle) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-darwin-amd64: seego -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent -else - export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -endif + $(call SetBuildVarsConditional,darwin/amd64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-darwin-arm64: seego -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agent -else - export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -endif + $(call SetBuildVarsConditional,darwin/arm64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-windows-amd64.exe: seego -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agent -else - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -endif + $(call SetBuildVarsConditional,windows) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe ifeq ($(DRONE),true) @@ -326,11 +296,7 @@ endif endif dist/agent-freebsd-amd64: seego -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agent -else - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent -endif + $(call SetBuildVarsConditional,freebsd); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent ####################### @@ -340,50 +306,31 @@ endif dist-agentctl: seego dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 dist/agentctl-linux-amd64: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,linux/amd64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-arm64: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,linux/arm64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv6: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,linux/arm/v6); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv7: seego - export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,linux/arm/v7); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-mipsle: seego -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -else - export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -endif + $(call SetBuildVarsConditional,linux/mipsle); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-darwin-amd64: seego -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -else - export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -endif + $(call SetBuildVarsConditional,darwin/amd64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-darwin-arm64: seego -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -else -endif + $(call SetBuildVarsConditional,darwin/arm64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-windows-amd64.exe: seego -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -else - export CGO_ENABLED=1 GOOS=windows GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -endif + $(call SetBuildVarsConditional,windows); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-freebsd-amd64: -ifeq ($(DRONE),true) - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" ; go build $(CGO_FLAGS) -o $@ ./cmd/agentctl -else - export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -endif +dist/agentctl-freebsd-amd64: + $(call SetBuildVarsConditional,freebsd); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl seego: tools/seego/Dockerfile ifeq ($(DRONE),false) From 69bfaf8748485c6924013476e6505beb7c7eed2b Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 11:17:58 -0400 Subject: [PATCH 069/101] Remove unused files --- .drone/go_wrapper.sh | 161 --------------------------------- cmd/agentctl/Dockerfile.buildx | 2 - 2 files changed, 163 deletions(-) delete mode 100644 .drone/go_wrapper.sh diff --git a/.drone/go_wrapper.sh b/.drone/go_wrapper.sh deleted file mode 100644 index 91383be678d9..000000000000 --- a/.drone/go_wrapper.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash - -FOUND_CC="" -FOUND_CXX="" -FOUND_LD_PATH="" -CC_EXTRA="" -CXX_EXTRA="" - -CGO_ENABLED=${CGO_ENABLED:-$(go env CGO_ENABLED)} -GOARCH=$(go env GOARCH) -GOOS=$(go env GOOS) -GOARM=$(go env GOARM) - -main() { - echo ">>> discovering toolchain for GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM}" - - case "$GOOS" in - linux) configure_linux ;; - darwin) configure_darwin ;; - freebsd) configure_bsd ;; - windows) configure_windows ;; - *) - echo ">>> ERROR: unsupported GOOS value $GOOS" - exit 1 - esac - - echo ">>> discovered CC ${FOUND_CC}" - echo ">>> discovered CXX ${FOUND_CXX}" - echo ">>> extra C flags: ${CC_EXTRA}" - - echo ">>> CGO_ENABLED=${CGO_ENABLED} CC=$FOUND_CC CXX=$FOUND_CXX go $@" - - # If we run go directly, any files created on the bind mount - # will have awkward ownership. So we switch to a user with the - # same user and group IDs as source directory. We have to set a - # few things up so that sudo works without complaining later on. - uid=$(stat --format="%u" $(pwd)) - gid=$(stat --format="%g" $(pwd)) - echo "seego:x:$uid:$gid::$(pwd):/bin/bash" >>/etc/passwd - echo "seego:*:::::::" >>/etc/shadow - echo "seego ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers - - # I'm skeptical that this is the best way to do it because it's so - # annoying, but it works at least. - # - # Export environment variables we want to retain when running go - # as the new user. Even though we preserve the path, we have to use - # the full path to go since sudo won't read the PATH for it. - - export CC="$FOUND_CC $CC_EXTRA" - export CXX="$FOUND_CXX $CC_EXTRA" - - export CGO_CFLAGS=$CC_EXTRA - export CGO_CXX_CFLAGS=$CC_EXTRA - export CGO_LDFLAGS=$CC_EXTRA - - export PATH=$PATH - if [ ! -z "$FOUND_LD_PATH" ]; then - export LD_LIBRARY_PATH="$FOUND_LD_PATH:$LD_LIBRARY_PATH" - fi - - export GOCACHE=$(pwd)/.cache - - exec sudo -E \ - --preserve-env=PATH \ - --preserve-env=LD_LIBRARY_PATH \ - -u seego -- $(which go) "$@" -} - -configure_linux() { - toolchain_prefix="" - - case "$GOARCH" in - # Do nothing for native archs - amd64 | 386) ;; - - arm) toolchain_prefix="arm-linux-gnueabi-" ;; - arm64) toolchain_prefix="aarch64-linux-gnu-" ;; - - ppc64) toolchain_prefix="powerpc-linux-gnu-" ;; - ppc64le) toolchain_prefix="powerpc64le-linux-gnu-" ;; - - mips) toolchain_prefix="mips-linux-gnu-" ;; - mipsle) toolchain_prefix="mipsel-linux-gnu-" ;; - mips64) toolchain_prefix="mips64-linux-gnuabi64-" ;; - mips64le) toolchain_prefix="mips64el-linux-gnuabi64-" ;; - - s390x) toolchain_prefix="s390x-linux-gnu-" ;; - - *) - echo ">>> ERROR: unsupported linux GOARCH value $GOARCH" - echo ">>> supported values: amd64, 386, arm, arm64, ppc64, ppc64le, mips, mipsle, mips64, mips64le, s390x" - exit 1 - esac - - if [ "$GOARCH" == "arm" ] && [ "$GOARM" == "7" ]; then - toolchain_prefix="arm-linux-gnueabihf-" - fi - - FOUND_CC="${toolchain_prefix}gcc" - FOUND_CXX="${toolchain_prefix}g++" -} - -configure_darwin() { - case "$GOARCH" in - amd64) - FOUND_CC="x86_64-apple-darwin20.2-clang" - FOUND_CXX="x86_64-apple-darwin20.2-clang++" - FOUND_LD_PATH="$OSXCROSS_PATH/lib" - ;; - arm64) - FOUND_CC="arm64-apple-darwin20.2-clang" - FOUND_CXX="arm64-apple-darwin20.2-clang++" - FOUND_LD_PATH="$OSXCROSS_PATH/lib" - ;; - *) - echo ">>> ERROR: unsupported darwin GOARCH value $GOARCH" - echo ">>> supported values: amd64, arm64" - exit 1 - esac -} - -configure_bsd() { - case "$GOARCH" in - amd64) - FOUND_CC="clang" - FOUND_CXX="clang++" - CC_EXTRA="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" - ;; - 386) - FOUND_CC="clang" - FOUND_CXX="clang++" - CC_EXTRA="-target i386-pc-freebsd11 --sysroot=/usr/freebsd/i386-pc-freebsd11 -v" - ;; - - *) - echo ">>> ERROR: unsupported bsd GOARCH value $GOARCH" - echo ">>> supported values: amd64, 386" - exit 1 - esac -} - -configure_windows() { - case "$GOARCH" in - 386) - FOUND_CC="i686-w64-mingw32-gcc" - FOUND_CXX="i686-w64-mingw32-g++" - ;; - amd64) - FOUND_CC="x86_64-w64-mingw32-gcc" - FOUND_CXX="x86_64-w64-mingw32-g++" - ;; - - *) - echo ">>> ERROR: unsupported windows GOARCH value $GOARCH" - echo ">>> supported values: 386, amd64" - exit 1 - esac -} - -main "$@" \ No newline at end of file diff --git a/cmd/agentctl/Dockerfile.buildx b/cmd/agentctl/Dockerfile.buildx index 0785afbc7b40..9838c7a6de06 100644 --- a/cmd/agentctl/Dockerfile.buildx +++ b/cmd/agentctl/Dockerfile.buildx @@ -17,9 +17,7 @@ WORKDIR /src/agent ARG RELEASE_BUILD=true ARG IMAGE_TAG -# Rename seego's /go_wrapper.sh to /seego.sh for readability in the # Makefile. -# RUN cp /go_wrapper.sh /seego.sh RUN make clean && IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false make agentctl FROM debian:buster-slim From a56ccd89e189ee04c01fbcf2df071e55a8448604 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 11:21:07 -0400 Subject: [PATCH 070/101] Add test back to github --- .github/workflows/test.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 000000000000..b7c059ecb953 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,21 @@ +name: Test +on: [pull_request] +jobs: + test: + name: Test + strategy: + matrix: + platform: [macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Set up Go 1.16 + uses: actions/setup-go@v1 + with: + go-version: 1.16 + id: go + - name: Checkout code + uses: actions/checkout@v2 + - name: Build + run: make cmd/agent/agent cmd/agentctl/agentctl cmd/agent-operator/agent-operator + - name: Test + run: make test \ No newline at end of file From 864647e63dfbfb023c5b4fd773f03b136db4e8ed Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 11:47:22 -0400 Subject: [PATCH 071/101] Fix normal makes --- Makefile | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 927f12243684..37618a89e2f9 100644 --- a/Makefile +++ b/Makefile @@ -13,34 +13,29 @@ DRONE ?= false RELEASE_TAG ?= v0.0.0 -CGO_ENABLED_VAR=${CGO_ENABLED:-$(shell go env CGO_ENABLED)} - - -# Set the CGO, CC, CCX flags based on targetplatform, if non given assume 'native' to the device -CGO_CC_CCX = export CGO_ENABLED=1 GO111MODULE=auto - # TARGETPLATFORM is specifically called from `docker buildx --platform`, this is mainly used when pushing docker image manifests, normal generally means NON DRONE builds -TARGETPLATFORM ?= normal +TARGETPLATFORM ?=normal # This function sets up all the appropriate flags for a drone or local build, this is actually a list of chained if statements with the false -# condition being the next if, its reformatted to look more like a series of if elses +# condition being the next if, its reformatted to look more like a series of if elses. The normal basically adds a noop so the ; used later on isnt +# left hanging define SetBuildVarsConditional -export CGO_ENABLED=1 $(if $(filter $(1),linux/amd64),GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ -$(if $(filter $(1),linux/arm64),GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ -$(if $(filter $(1),linux/arm/v7),GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ -$(if $(filter $(1),linux/arm/v6),GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ -$(if $(filter $(1),darwin/amd64),GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ -$(if $(filter $(1),darwin/arm64),GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ -$(if $(filter $(1),windows),GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++, \ -$(if $(filter $(1),mipls),GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++, \ -$(if $(filter $(1),freebsd),GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" , $(error invalid flag $(1))) \ -)))))))) +$(if $(filter $(1),normal),export CGO_ENABLED=1, \ +$(if $(filter $(1),linux/amd64),export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ +$(if $(filter $(1),linux/arm64),export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ +$(if $(filter $(1),linux/arm/v7),export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ +$(if $(filter $(1),linux/arm/v6),export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ +$(if $(filter $(1),darwin/amd64),export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ +$(if $(filter $(1),darwin/arm64),export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ +$(if $(filter $(1),windows),export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++, \ +$(if $(filter $(1),mipls),export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++, \ +$(if $(filter $(1),freebsd),export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" , $(error invalid flag $(1))) \ +))))))))) endef +ALL_CGO_BUILD_FLAGS = $(call SetBuildVarsConditional,$(TARGETPLATFORM)) + -ifneq ($(TARGETPLATFORM),normal) -ALL_CGO_BUILD_FLAGS = $(call SetBuildVarsConditional $(TARGETPLATFORM)) -endif # Setting CROSS_BUILD=true enables cross-compiling `agent` and `agentctl` for # different architectures. When true, docker buildx is used instead of docker, From 856634ac9a180e4ba6c3b67db0df8189ffe1a1ea Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 12:11:17 -0400 Subject: [PATCH 072/101] Reorder changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e0cd1d8dc1..8ae6b86b71a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,12 @@ the matching release version of the Grafana Agent instead of v0.14.0. (@rfratto) -- [ENHANCEMENT] Switch to drone for releases. (@mattdurham) - - [ENHANCEMENT] Update OTel dependency to v0.29.0 (@mapno) - [ENHANCEMENT] Allow reloading configuration using `SIGHUP` signal. (@tharun208) +- [ENHANCEMENT] Switch to drone for releases. (@mattdurham) + - [BUGFIX] Fix race condition that may occur and result in a panic when initializing scraping service cluster. (@rfratto) From cf2b22560b168270046712d2264b9e497944d905 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 12:12:50 -0400 Subject: [PATCH 073/101] Fix arm64 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 37618a89e2f9..ddd831798272 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ TARGETPLATFORM ?=normal define SetBuildVarsConditional $(if $(filter $(1),normal),export CGO_ENABLED=1, \ $(if $(filter $(1),linux/amd64),export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ -$(if $(filter $(1),linux/arm64),export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ +$(if $(filter $(1),linux/arm64),export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=gcc CCX=g++, \ $(if $(filter $(1),linux/arm/v7),export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ $(if $(filter $(1),linux/arm/v6),export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ $(if $(filter $(1),darwin/amd64),export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ From 310f92b5a6a9c370d2c8a38c4c120f171b58be66 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 12:14:24 -0400 Subject: [PATCH 074/101] Arm fix --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ddd831798272..158ca81fcf60 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ TARGETPLATFORM ?=normal define SetBuildVarsConditional $(if $(filter $(1),normal),export CGO_ENABLED=1, \ $(if $(filter $(1),linux/amd64),export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ -$(if $(filter $(1),linux/arm64),export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=gcc CCX=g++, \ +$(if $(filter $(1),linux/arm64),export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++, \ $(if $(filter $(1),linux/arm/v7),export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ $(if $(filter $(1),linux/arm/v6),export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ $(if $(filter $(1),darwin/amd64),export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ From b85a25b600b82cd20b1d33f11b0fe8792d7c50c8 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 12:15:45 -0400 Subject: [PATCH 075/101] Remove comment lines --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 158ca81fcf60..f3e7a6695c18 100644 --- a/Makefile +++ b/Makefile @@ -74,9 +74,9 @@ DOCKER_BUILD_FLAGS = --build-arg RELEASE_BUILD=$(RELEASE_BUILD) --build-arg IMAG CGO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "netgo" DEBUG_CGO_FLAGS := -gcflags "all=-N -l" -ldflags "-s -w $(GO_LDFLAGS)" -tags "netgo" # If we're not building the release, use the debug flags instead. -#ifeq ($(RELEASE_BUILD),false) +ifeq ($(RELEASE_BUILD),false) GO_FLAGS = $(DEBUG_GO_FLAGS) -#endif +endif NETGO_CHECK = @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ rm $@; \ From 941c182a4c8a18b78307bd4d99e381554ba77f8c Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 13:26:41 -0400 Subject: [PATCH 076/101] rename governance --- Governance.md => GOVERNANCE.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Governance.md => GOVERNANCE.md (100%) diff --git a/Governance.md b/GOVERNANCE.md similarity index 100% rename from Governance.md rename to GOVERNANCE.md From 4909d48d02eca1e8631b94db382ab4c86f6acaf2 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Mon, 19 Jul 2021 16:38:19 -0400 Subject: [PATCH 077/101] use seego --- .github/workflows/test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000000..b7c059ecb953 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Test +on: [pull_request] +jobs: + test: + name: Test + strategy: + matrix: + platform: [macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Set up Go 1.16 + uses: actions/setup-go@v1 + with: + go-version: 1.16 + id: go + - name: Checkout code + uses: actions/checkout@v2 + - name: Build + run: make cmd/agent/agent cmd/agentctl/agentctl cmd/agent-operator/agent-operator + - name: Test + run: make test \ No newline at end of file From 45363efecbd17de58e9414e054ac30bf905599cf Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 08:57:30 -0400 Subject: [PATCH 078/101] Simplify seego usage --- .github/workflows/test.yaml | 21 --------------------- Makefile | 29 ++++++++++++++--------------- 2 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index b7c059ecb953..000000000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: Test -on: [pull_request] -jobs: - test: - name: Test - strategy: - matrix: - platform: [macos-latest, windows-latest] - runs-on: ${{ matrix.platform }} - steps: - - name: Set up Go 1.16 - uses: actions/setup-go@v1 - with: - go-version: 1.16 - id: go - - name: Checkout code - uses: actions/checkout@v2 - - name: Build - run: make cmd/agent/agent cmd/agentctl/agentctl cmd/agent-operator/agent-operator - - name: Test - run: make test \ No newline at end of file diff --git a/Makefile b/Makefile index f3e7a6695c18..e1c3f29f0871 100644 --- a/Makefile +++ b/Makefile @@ -16,20 +16,17 @@ RELEASE_TAG ?= v0.0.0 # TARGETPLATFORM is specifically called from `docker buildx --platform`, this is mainly used when pushing docker image manifests, normal generally means NON DRONE builds TARGETPLATFORM ?=normal -# This function sets up all the appropriate flags for a drone or local build, this is actually a list of chained if statements with the false -# condition being the next if, its reformatted to look more like a series of if elses. The normal basically adds a noop so the ; used later on isnt -# left hanging define SetBuildVarsConditional -$(if $(filter $(1),normal),export CGO_ENABLED=1, \ -$(if $(filter $(1),linux/amd64),export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=gcc CCX=g++, \ -$(if $(filter $(1),linux/arm64),export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CCX=aarch64-linux-gnu-g++, \ -$(if $(filter $(1),linux/arm/v7),export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ -$(if $(filter $(1),linux/arm/v6),export CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc CCX=arm-linux-gnueabi-g++, \ -$(if $(filter $(1),darwin/amd64),export CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=x86_64-apple-darwin20.2-clang CCX=x86_64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ -$(if $(filter $(1),darwin/arm64),export CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC=arm64-apple-darwin20.2-clang CCX=arm64-apple-darwin20.2-clang++ LD_LIBRARY_PATH=$(OSXCROSS_PATH)/lib, \ -$(if $(filter $(1),windows),export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++, \ -$(if $(filter $(1),mipls),export CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat CC=mipsel-linux-gnu-gcc CCX=mipsel-linux-gnu-f++, \ -$(if $(filter $(1),freebsd),export CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64 CC=clang CCX=clang++ CGO_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_CXX_CFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" CGO_LDFLAGS="-target x86_64-pc-freebsd11 --sysroot=/usr/freebsd/x86_64-pc-freebsd11" , $(error invalid flag $(1))) \ +$(if $(filter $(1),normal),CGO_ENABLED=1, \ +$(if $(filter $(1),linux/amd64),CGO_ENABLED=1 GOOS=linux GOARCH=amd64, \ +$(if $(filter $(1),linux/arm64),CGO_ENABLED=1 GOOS=linux GOARCH=arm64, \ +$(if $(filter $(1),linux/arm/v7),CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7, \ +$(if $(filter $(1),linux/arm/v6),CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6, \ +$(if $(filter $(1),darwin/amd64),CGO_ENABLED=1 GOOS=darwin GOARCH=amd64, \ +$(if $(filter $(1),darwin/arm64),CGO_ENABLED=1 GOOS=darwin GOARCH=arm64, \ +$(if $(filter $(1),windows),CGO_ENABLED=1 GOOS=windows GOARCH=amd64, \ +$(if $(filter $(1),mipls),CGO_ENABLED=1 GOOS=linux GOARCH=mipsle, \ +$(if $(filter $(1),freebsd),CGO_ENABLED=1 GOOS=freebsd GOARCH=amd64, $(error invalid flag $(1))) \ ))))))))) endef @@ -110,13 +107,15 @@ docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) -# docker-build = docker buildx build --push --platform linux/arm64 $(DOCKER_BUILD_FLAGS) endif -ifeq ($(CROSS_BUILD),false) +ifeq ($(DRONE),true) +seego = "/go_wrapper.sh" +else ifeq ($(BUILD_IN_CONTAINER),false) seego = go endif + ######## # CRDs # ######## From c427997585115553d6615d087a2820c5a9d8145d Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 09:05:01 -0400 Subject: [PATCH 079/101] include fix for test --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b7c059ecb953..692c55d5ff88 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,6 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Build - run: make cmd/agent/agent cmd/agentctl/agentctl cmd/agent-operator/agent-operator + run: make BUILD_IN_CONTAINER=false cmd/agent/agent cmd/agentctl/agentctl cmd/agent-operator/agent-operator - name: Test - run: make test \ No newline at end of file + run: make BUILD_IN_CONTAINER=false test \ No newline at end of file From a7f35c23b121b9ac71c75f0824ac899047490410 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 09:40:33 -0400 Subject: [PATCH 080/101] Fix for dout --- Makefile | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index e1c3f29f0871..617e29f1239f 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ RELEASE_TAG ?= v0.0.0 # TARGETPLATFORM is specifically called from `docker buildx --platform`, this is mainly used when pushing docker image manifests, normal generally means NON DRONE builds TARGETPLATFORM ?=normal +# This is used to set all the environment variables to pass to the go build/seego/docker commands define SetBuildVarsConditional $(if $(filter $(1),normal),CGO_ENABLED=1, \ $(if $(filter $(1),linux/amd64),CGO_ENABLED=1 GOOS=linux GOARCH=amd64, \ @@ -109,6 +110,7 @@ DOCKERFILE = Dockerfile.buildx docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) endif +# we want to override the default seego behavior. Drone always builds locally inside seego and if build in container is false then use ifeq ($(DRONE),true) seego = "/go_wrapper.sh" else ifeq ($(BUILD_IN_CONTAINER),false) @@ -258,36 +260,32 @@ dist/agent-linux-arm64: seego $(call SetBuildVarsConditional,linux/arm64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv6: seego - $(call SetBuildVarsConditional,linux/arm/v6) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,linux/arm/v6) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-armv7: seego - $(call SetBuildVarsConditional,linux/arm/v7) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,linux/arm/v7) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-mipsle: seego - $(call SetBuildVarsConditional,linux/mipsle) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,linux/mipsle) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-darwin-amd64: seego - $(call SetBuildVarsConditional,darwin/amd64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,darwin/amd64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-darwin-arm64: seego - $(call SetBuildVarsConditional,darwin/arm64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,darwin/arm64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-windows-amd64.exe: seego - $(call SetBuildVarsConditional,windows) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,windows) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe -ifeq ($(DRONE),true) - cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis -else -ifeq ($(BUILD_IN_CONTAINER),true) cp ./dist/agent-windows-amd64.exe ./packaging/windows cp LICENSE ./packaging/windows +ifeq ($(BUILD_IN_CONTAINER),true) docker build -t windows_installer ./packaging/windows docker run --rm -t -v "${PWD}:/home" windows_installer else - cp dist/agent-windows-amd64.exe ./packaging/windows && cp LICENSE ./packaging/windows && makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT./dist/grafana-agent-installer.exe ./packaging/windows/install_script.nsis + makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis endif -endif dist/agent-freebsd-amd64: seego $(call SetBuildVarsConditional,freebsd); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent @@ -300,31 +298,31 @@ dist/agent-freebsd-amd64: seego dist-agentctl: seego dist/agentctl-linux-amd64 dist/agentctl-linux-arm64 dist/agentctl-linux-armv6 dist/agentctl-linux-armv7 dist/agentctl-darwin-amd64 dist/agentctl-darwin-arm64 dist/agentctl-windows-amd64.exe dist/agentctl-freebsd-amd64 dist/agentctl-linux-amd64: seego - $(call SetBuildVarsConditional,linux/amd64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,linux/amd64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-arm64: seego - $(call SetBuildVarsConditional,linux/arm64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,linux/arm64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv6: seego - $(call SetBuildVarsConditional,linux/arm/v6); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,linux/arm/v6); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-armv7: seego - $(call SetBuildVarsConditional,linux/arm/v7); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,linux/arm/v7); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-linux-mipsle: seego - $(call SetBuildVarsConditional,linux/mipsle); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,linux/mipsle); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-darwin-amd64: seego - $(call SetBuildVarsConditional,darwin/amd64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,darwin/amd64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-darwin-arm64: seego - $(call SetBuildVarsConditional,darwin/arm64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,darwin/arm64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-windows-amd64.exe: seego - $(call SetBuildVarsConditional,windows); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,windows); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-freebsd-amd64: - $(call SetBuildVarsConditional,freebsd); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl + $(call SetBuildVarsConditional,freebsd); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl seego: tools/seego/Dockerfile ifeq ($(DRONE),false) From f0f485eac376bf04289f3e737e45871daacda33f Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 09:42:14 -0400 Subject: [PATCH 081/101] Only build docker container if needed --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 617e29f1239f..1b7f09496514 100644 --- a/Makefile +++ b/Makefile @@ -326,8 +326,10 @@ dist/agentctl-freebsd-amd64: seego: tools/seego/Dockerfile ifeq ($(DRONE),false) +ifeq ($(BUILD_IN_CONTAINER),true) docker build -t grafana/agent/seego tools/seego endif +endif # Makes seego if CROSS_BUILD is true. check-seego: From 787e70a973e9124a62bcf267c494e3fbab74e50d Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 10:27:32 -0400 Subject: [PATCH 082/101] Add depends on --- .drone/drone.yml | 88 +++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 6665815434c0..ab1fb60380ac 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -11,10 +11,11 @@ steps: commands: - apt-get update -y && apt-get install -y libsystemd-dev - make lint + --- kind: pipeline type: docker -name: Dist +name: Test platform: os: linux arch: amd64 @@ -23,18 +24,21 @@ steps: - name: distribute image: rfratto/seego commands: - - apt-get update && apt-get install -y rubygems rpm nsis + - apt-get update && apt-get install -y rubygems rpm nsis apt-transport-https ca-certificates curl gnupg lsb-release - gem install --no-document fpm - mkdir -p /usr/local/go/bin - wget -q https://golang.org/dl/go1.16.5.linux-amd64.tar.gz - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - make DRONE=true BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist + - make DRONE=true BUILD_IN_CONTAINER=false test +depends_on: + - Lint + --- kind: pipeline type: docker -name: Test +name: Dist platform: os: linux arch: amd64 @@ -43,18 +47,20 @@ steps: - name: distribute image: rfratto/seego commands: - - apt-get update && apt-get install -y rubygems rpm nsis apt-transport-https ca-certificates curl gnupg lsb-release + - apt-get update && apt-get install -y rubygems rpm nsis - gem install --no-document fpm - mkdir -p /usr/local/go/bin - wget -q https://golang.org/dl/go1.16.5.linux-amd64.tar.gz - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - rm go1.16.5.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - - make DRONE=true BUILD_IN_CONTAINER=false test + - make DRONE=true BUILD_IN_CONTAINER=false RELEASE_TAG=v0.0.0 dist +depends_on: + - Test --- kind: pipeline type: docker -name: Release +name: Containerize platform: os: linux arch: amd64 @@ -63,8 +69,8 @@ trigger: - tag steps: -- name: create-release - image: rfratto/seego +- name: Build Containers + image: docker volumes: - name: docker path: /var/run/docker.sock @@ -73,24 +79,20 @@ steps: from_secret: DOCKER_LOGIN DOCKER_PASSWORD: from_secret: DOCKER_PASSWORD - GITHUB_TOKEN: - from_secret: GITHUB_KEY commands: - - apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release - - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - - - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" - - apt-get update && apt-get install -y rubygems rpm nsis docker-ce docker-ce-cli containerd.io - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - - gem install --no-document fpm - - mkdir -p /usr/local/go/bin - - wget -q https://golang.org/dl/go1.16.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz - - rm go1.16.5.linux-amd64.tar.gz - - export PATH=$PATH:/usr/local/go/bin - - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr - - export PATH="$(go env GOPATH)/bin:$PATH" - - RELEASE_TAG=$DRONE_TAG - - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish + - apk update && apk add make bash wget git qemu + - wget -q https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 + - mkdir -p ~/.docker/cli-plugins + - cp buildx-v0.5.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx + - chmod a+x ~/.docker/cli-plugins/docker-buildx + - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - docker buildx create --name multiarch --driver docker-container --use + - make DRONE=true CROSS_BUILD=true RELEASE_BUILD=true agent-image + - make DRONE=true CROSS_BUILD=true RELEASE_BUILD=true agentctl-image + - docker buildx rm multiarch +depends_on: + - Dist volumes: - name: docker @@ -99,7 +101,7 @@ volumes: --- kind: pipeline type: docker -name: Containerize +name: Release platform: os: linux arch: amd64 @@ -108,8 +110,8 @@ trigger: - tag steps: -- name: Build Containers - image: docker +- name: create-release + image: rfratto/seego volumes: - name: docker path: /var/run/docker.sock @@ -118,18 +120,26 @@ steps: from_secret: DOCKER_LOGIN DOCKER_PASSWORD: from_secret: DOCKER_PASSWORD + GITHUB_TOKEN: + from_secret: GITHUB_KEY commands: + - apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release + - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - + - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" + - apt-get update && apt-get install -y rubygems rpm nsis docker-ce docker-ce-cli containerd.io - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - - apk update && apk add make bash wget git qemu - - wget -q https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 - - mkdir -p ~/.docker/cli-plugins - - cp buildx-v0.5.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx - - chmod a+x ~/.docker/cli-plugins/docker-buildx - - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - docker buildx create --name multiarch --driver docker-container --use - - make DRONE=true CROSS_BUILD=true RELEASE_BUILD=true agent-image - - make DRONE=true CROSS_BUILD=true RELEASE_BUILD=true agentctl-image - - docker buildx rm multiarch + - gem install --no-document fpm + - mkdir -p /usr/local/go/bin + - wget -q https://golang.org/dl/go1.16.5.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz + - rm go1.16.5.linux-amd64.tar.gz + - export PATH=$PATH:/usr/local/go/bin + - GO111MODULE=on go get -u github.com/mitchellh/gox github.com/tcnksm/ghr + - export PATH="$(go env GOPATH)/bin:$PATH" + - RELEASE_TAG=$DRONE_TAG + - make -j4 BUILD_IN_CONTAINER=false RELEASE_BUILD=true RELEASE_TAG=$RELEASE_TAG publish +depends_on: + - Dist volumes: - name: docker @@ -137,6 +147,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 4068ab750b156d97a68a5a0cdda0ca71f21d2bad13208bc1cdffdab1cf246e52 +hmac: 9d4cd5d2a328651b94215cd0b722bd612ad3fbb5a8287182a144d8150664085e ... From cf0d0f4ebbdd3dd6e8d21857b03bc756fc7d8fc9 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 10:29:27 -0400 Subject: [PATCH 083/101] Fix naming --- .drone/drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index ab1fb60380ac..a2f3e9feeadb 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -21,7 +21,7 @@ platform: arch: amd64 steps: -- name: distribute +- name: test image: rfratto/seego commands: - apt-get update && apt-get install -y rubygems rpm nsis apt-transport-https ca-certificates curl gnupg lsb-release @@ -147,6 +147,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 9d4cd5d2a328651b94215cd0b722bd612ad3fbb5a8287182a144d8150664085e +hmac: 28ff14ebdeb71c36700f010e77cf80b30adb7d44588e10b05438703470939c1f ... From 6c04898c6a1588c0bf3cd5874883146413f17695 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 12:01:32 -0400 Subject: [PATCH 084/101] Unsilent any remaining output --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 1b7f09496514..801edf7204e9 100644 --- a/Makefile +++ b/Makefile @@ -76,7 +76,7 @@ ifeq ($(RELEASE_BUILD),false) GO_FLAGS = $(DEBUG_GO_FLAGS) endif -NETGO_CHECK = @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ +NETGO_CHECK = strings $@ | grep cgo_stub\\\.go >/dev/null || { \ rm $@; \ echo "\nYour go standard library was built without the 'netgo' build tag."; \ echo "To fix that, run"; \ @@ -124,8 +124,8 @@ endif crds: ifeq ($(BUILD_IN_CONTAINER),true) - @mkdir -p $(shell pwd)/.pkg - @mkdir -p $(shell pwd)/.cache + mkdir -p $(shell pwd)/.pkg + mkdir -p $(shell pwd)/.cache docker run -i \ -v $(shell pwd)/.cache:/go/cache \ -v $(shell pwd)/.pkg:/go/pkg \ @@ -148,8 +148,8 @@ touch-protos: %.pb.go: $(PROTO_DEFS) ifeq ($(BUILD_IN_CONTAINER),true) - @mkdir -p $(shell pwd)/.pkg - @mkdir -p $(shell pwd)/.cache + mkdir -p $(shell pwd)/.pkg + mkdir -p $(shell pwd)/.cache docker run -i \ -v $(shell pwd)/.cache:/go/cache \ -v $(shell pwd)/.pkg:/go/pkg \ @@ -254,7 +254,7 @@ dist: dist-agent dist-agentctl dist-packages dist-agent: seego dist/agent-linux-amd64 dist/agent-linux-arm64 dist/agent-linux-armv6 dist/agent-linux-armv7 dist/agent-darwin-amd64 dist/agent-darwin-arm64 dist/agent-windows-amd64.exe dist/agent-freebsd-amd64 dist/agent-windows-installer.exe dist/agent-linux-amd64: seego - $(call SetBuildVarsConditional,linux/amd64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent + $(call SetBuildVarsConditional,linux/amd64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-linux-arm64: seego $(call SetBuildVarsConditional,linux/arm64) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent @@ -446,7 +446,7 @@ $(PACKAGE_PREFIX).armv7.rpm: $(RPM_DEPS) endif enforce-release-tag: - @sh -c '[ -n "${RELEASE_TAG}" ] || (echo \$$RELEASE_TAG environment variable not set; exit 1)' + sh -c '[ -n "${RELEASE_TAG}" ] || (echo \$$RELEASE_TAG environment variable not set; exit 1)' test-packages: enforce-release-tag seego dist-packages-amd64 packaging/centos-systemd/.uptodate packaging/debian-systemd/.uptodate ./tools/test-packages $(IMAGE_PREFIX) $(PACKAGE_VERSION) $(PACKAGE_RELEASE) From dd9b8948549947d25da1ff3b725dbae89bfed695 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 12:37:53 -0400 Subject: [PATCH 085/101] unsilent --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 801edf7204e9..abed36c12777 100644 --- a/Makefile +++ b/Makefile @@ -321,7 +321,7 @@ dist/agentctl-darwin-arm64: seego dist/agentctl-windows-amd64.exe: seego $(call SetBuildVarsConditional,windows); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-freebsd-amd64: +dist/agentctl-freebsd-amd64: seego $(call SetBuildVarsConditional,freebsd); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl seego: tools/seego/Dockerfile From d22fbe156de643c2a170093c05e62ceba4506f61 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 12:55:05 -0400 Subject: [PATCH 086/101] Remove check-seego and switch to using docker by default --- Makefile | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index abed36c12777..618e9fbea938 100644 --- a/Makefile +++ b/Makefile @@ -173,12 +173,12 @@ agent-operator: cmd/agent-operator/agent-operator # In general DRONE variable should overwrite any other options, if DRONE is not set then fallback to normal behavior -cmd/agent/agent: check-seego cmd/agent/main.go +cmd/agent/agent: seego cmd/agent/main.go $(ALL_CGO_BUILD_FLAGS) ; $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) -cmd/agentctl/agentctl: check-seego cmd/agentctl/main.go +cmd/agentctl/agentctl: seego cmd/agentctl/main.go $(ALL_CGO_BUILD_FLAGS) ; $(seego) build $(CGO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) @@ -331,15 +331,6 @@ ifeq ($(BUILD_IN_CONTAINER),true) endif endif -# Makes seego if CROSS_BUILD is true. -check-seego: -ifeq ($(DRONE),false) -ifeq ($(CROSS_BUILD),true) -ifeq ($(BUILD_IN_CONTAINER),true) - $(MAKE) seego -endif -endif -endif build-image/.uptodate: build-image/Dockerfile docker pull $(BUILD_IMAGE) || docker build -t $(BUILD_IMAGE) $(@D) From 36270ac317785cba40919ba8b893368f1ef3d42d Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 13:03:47 -0400 Subject: [PATCH 087/101] Change triggers --- .drone/drone.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index a2f3e9feeadb..6cc451e37a7c 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -42,6 +42,9 @@ name: Dist platform: os: linux arch: amd64 +trigger: + event: + - tag steps: - name: distribute @@ -65,8 +68,8 @@ platform: os: linux arch: amd64 trigger: - event: - - tag + branch: + - master steps: - name: Build Containers @@ -147,6 +150,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 28ff14ebdeb71c36700f010e77cf80b30adb7d44588e10b05438703470939c1f +hmac: ea86d777863c66f544750a9cad7d819cef4d51ac6476aa501c10adad17af7424 ... From 368be32170f0496a727feb62bcb2772ff0a44ab6 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 13:04:15 -0400 Subject: [PATCH 088/101] rename master to main --- .drone/drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 6cc451e37a7c..42fdb930d1a5 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -69,7 +69,7 @@ platform: arch: amd64 trigger: branch: - - master + - main steps: - name: Build Containers @@ -150,6 +150,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: ea86d777863c66f544750a9cad7d819cef4d51ac6476aa501c10adad17af7424 +hmac: fbeeed31dae21b5120c38c4a88597ab4edd02579e03e739322e191588293bbb4 ... From 3bdf0d664b41f0abb18b7b8f227f9cbed48f9e3b Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 13:07:18 -0400 Subject: [PATCH 089/101] Fix dependency order now that Dist only triggers on tags --- .drone/drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 42fdb930d1a5..9347d08545bc 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -95,7 +95,7 @@ steps: - make DRONE=true CROSS_BUILD=true RELEASE_BUILD=true agentctl-image - docker buildx rm multiarch depends_on: - - Dist + - Lint volumes: - name: docker From c10d86a5efcf864c9310b68dc3e5e4428af5597a Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 13:07:35 -0400 Subject: [PATCH 090/101] Sign drone --- .drone/drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 9347d08545bc..73b47e0d44ef 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -150,6 +150,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: fbeeed31dae21b5120c38c4a88597ab4edd02579e03e739322e191588293bbb4 +hmac: 0ce87ea79164012f25134505c767ee8e5950fa35cacc4e17aea469dba94a1750 ... From 891f416ede5393267db70051923cc0b3febdb412 Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Tue, 20 Jul 2021 13:35:34 -0400 Subject: [PATCH 091/101] mount local go mod cache to seego if one exists --- Makefile | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 618e9fbea938..339bc7eedc80 100644 --- a/Makefile +++ b/Makefile @@ -100,21 +100,28 @@ PACKAGE_RELEASE := 1 DOCKERFILE = Dockerfile +# If Go is installed locally mount the local module cache so seego builds +# aren't too slow. +ifeq (, $(shell which go)) +MOD_MOUNT="" +else +MOD_MOUNT=-v "$(shell go env GOMODCACHE):/go/pkg/mod" +endif # seego is used by default when running bare make commands such as `make dist` this uses an image that has all the necessary libraries to cross build # when using drone the docker in docker is more problematic so instead drone uses seego has the base image then calls make running "raw" commands -seego = docker run --rm -t -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" -e "GOMIPS=$$GOMIPS" grafana/agent/seego +seego = docker run --rm -t $(MOD_MOUNT) -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e "CGO_ENABLED=$$CGO_ENABLED" -e "GOOS=$$GOOS" -e "GOARCH=$$GOARCH" -e "GOARM=$$GOARM" -e "GOMIPS=$$GOMIPS" grafana/agent/seego docker-build = docker build $(DOCKER_BUILD_FLAGS) ifeq ($(CROSS_BUILD),true) DOCKERFILE = Dockerfile.buildx docker-build = docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 $(DOCKER_BUILD_FLAGS) endif -# we want to override the default seego behavior. Drone always builds locally inside seego and if build in container is false then use +# we want to override the default seego behavior. Drone always builds locally inside seego and if build in container is false then use ifeq ($(DRONE),true) -seego = "/go_wrapper.sh" +seego = "/go_wrapper.sh" else ifeq ($(BUILD_IN_CONTAINER),false) -seego = go +seego = go endif @@ -188,9 +195,9 @@ cmd/agent-operator/agent-operator: cmd/agent-operator/main.go $(NETGO_CHECK) -agent-image: +agent-image: $(docker-build) -t $(IMAGE_PREFIX)/agent:latest -t $(IMAGE_PREFIX)/agent:$(IMAGE_TAG) -f cmd/agent/$(DOCKERFILE) . -agentctl-image: +agentctl-image: $(docker-build) -t $(IMAGE_PREFIX)/agentctl:latest -t $(IMAGE_PREFIX)/agentctl:$(IMAGE_TAG) -f cmd/agentctl/$(DOCKERFILE) . agent-operator-image: $(docker-build) -t $(IMAGE_PREFIX)/agent-operator:latest -t $(IMAGE_PREFIX)/agent-operator:$(IMAGE_TAG) -f cmd/agent-operator/$(DOCKERFILE) . @@ -278,15 +285,15 @@ dist/agent-windows-amd64.exe: seego $(call SetBuildVarsConditional,windows) ; $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent dist/agent-windows-installer.exe: dist/agent-windows-amd64.exe - cp ./dist/agent-windows-amd64.exe ./packaging/windows - cp LICENSE ./packaging/windows + cp ./dist/agent-windows-amd64.exe ./packaging/windows + cp LICENSE ./packaging/windows ifeq ($(BUILD_IN_CONTAINER),true) docker build -t windows_installer ./packaging/windows docker run --rm -t -v "${PWD}:/home" windows_installer else makensis -V4 -DVERSION=${RELEASE_TAG} -DOUT="../../dist/grafana-agent-installer.exe" ./packaging/windows/install_script.nsis endif - + dist/agent-freebsd-amd64: seego $(call SetBuildVarsConditional,freebsd); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agent @@ -312,13 +319,13 @@ dist/agentctl-linux-armv7: seego dist/agentctl-linux-mipsle: seego $(call SetBuildVarsConditional,linux/mipsle); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-darwin-amd64: seego +dist/agentctl-darwin-amd64: seego $(call SetBuildVarsConditional,darwin/amd64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-darwin-arm64: seego $(call SetBuildVarsConditional,darwin/arm64); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl -dist/agentctl-windows-amd64.exe: seego +dist/agentctl-windows-amd64.exe: seego $(call SetBuildVarsConditional,windows); $(seego) build $(CGO_FLAGS) -o $@ ./cmd/agentctl dist/agentctl-freebsd-amd64: seego From d6faab288d8b64afa5c5c1f8f704783fe19440b9 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:00:00 -0400 Subject: [PATCH 092/101] Clean up triggers --- .drone/drone.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 73b47e0d44ef..af598c08f6a7 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -42,9 +42,6 @@ name: Dist platform: os: linux arch: amd64 -trigger: - event: - - tag steps: - name: distribute @@ -68,8 +65,9 @@ platform: os: linux arch: amd64 trigger: - branch: - - main + ref: + - refs/heads/main + - refs/tags/v* steps: - name: Build Containers @@ -94,6 +92,8 @@ steps: - make DRONE=true CROSS_BUILD=true RELEASE_BUILD=true agent-image - make DRONE=true CROSS_BUILD=true RELEASE_BUILD=true agentctl-image - docker buildx rm multiarch + + depends_on: - Lint @@ -109,8 +109,8 @@ platform: os: linux arch: amd64 trigger: - event: - - tag + ref: + - refs/tags/v* steps: - name: create-release @@ -150,6 +150,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 0ce87ea79164012f25134505c767ee8e5950fa35cacc4e17aea469dba94a1750 +hmac: 38add315b1c28944ba1b0d1c36b3e883208399220a9f19b7f962dd9d75e6339f ... From 4c4107d83879b605988f667dbc92647f054626aa Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:02:12 -0400 Subject: [PATCH 093/101] Add trigger to dist --- .drone/drone.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index af598c08f6a7..f3646037a02f 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -42,6 +42,9 @@ name: Dist platform: os: linux arch: amd64 +trigger: + ref: + - refs/tags/v* steps: - name: distribute @@ -150,6 +153,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 38add315b1c28944ba1b0d1c36b3e883208399220a9f19b7f962dd9d75e6339f +hmac: 8568b191261d5895d9426c3c175e91cb69d347275226d774988ecde8db3329bc ... From 7ab5d4c8866f22b089af56d84080fde307b40ff9 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:22:40 -0400 Subject: [PATCH 094/101] testing change for synchronized --- .drone/drone.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index f3646037a02f..10306f13a6f8 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -4,6 +4,10 @@ name: Lint platform: os: linux arch: amd64 +when: + event: + include: + - push steps: - name: lint @@ -19,6 +23,10 @@ name: Test platform: os: linux arch: amd64 +when: + event: + include: + - push steps: - name: test @@ -153,6 +161,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 8568b191261d5895d9426c3c175e91cb69d347275226d774988ecde8db3329bc +hmac: 7bad93b9bac9c25d4b6ab7c172944afda0f90d409ebdcd35c6751f00ca8cd095 ... From b4b1e5759dbaa5c3b0cb32a6ce115ca9ce250d35 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:25:37 -0400 Subject: [PATCH 095/101] testing change for synchronized --- .drone/drone.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 10306f13a6f8..56bca54dc649 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -23,10 +23,10 @@ name: Test platform: os: linux arch: amd64 -when: - event: - include: - - push +trigger: + ref: + exclude: + - refs/pull/** steps: - name: test @@ -161,6 +161,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 7bad93b9bac9c25d4b6ab7c172944afda0f90d409ebdcd35c6751f00ca8cd095 +hmac: 001cb9be2916b8b25b029b7c3d1629ebc766952932efae639dd53c029ada92e3 ... From 552b457a89bd23143cf9d5eef131ec1a353e39cb Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:26:05 -0400 Subject: [PATCH 096/101] Undo changeS --- .drone/drone.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 56bca54dc649..2bccea147989 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -23,10 +23,6 @@ name: Test platform: os: linux arch: amd64 -trigger: - ref: - exclude: - - refs/pull/** steps: - name: test From 292281adb7e9d0de22a2fcfb903a3ae22d31562a Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:26:17 -0400 Subject: [PATCH 097/101] sign drone --- .drone/drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 2bccea147989..ef5d26f7bb9d 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -157,6 +157,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 001cb9be2916b8b25b029b7c3d1629ebc766952932efae639dd53c029ada92e3 +hmac: ae5861af3577c9ef1f568a743392fd59f431c362939928090a0e4a6be9394465 ... From 3c424b6923c103d8138a67508de4d4c25508b2f2 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:30:58 -0400 Subject: [PATCH 098/101] Prevent double build --- .drone/drone.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index ef5d26f7bb9d..681621fa1962 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -23,7 +23,11 @@ name: Test platform: os: linux arch: amd64 - +trigger: + ref: + - refs/heads/main + - refs/pull/*/head + steps: - name: test image: rfratto/seego @@ -157,6 +161,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: ae5861af3577c9ef1f568a743392fd59f431c362939928090a0e4a6be9394465 +hmac: 8f4d0652ed83dd00ae26f6bfdc3ff43d319eea90d4a131f1373d167f2b6582fd ... From c445764d7e1cc5295f0316b85a9a9be2128a4aca Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:32:22 -0400 Subject: [PATCH 099/101] remove extra check --- .drone/drone.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 681621fa1962..ef5d26f7bb9d 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -23,11 +23,7 @@ name: Test platform: os: linux arch: amd64 -trigger: - ref: - - refs/heads/main - - refs/pull/*/head - + steps: - name: test image: rfratto/seego @@ -161,6 +157,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 8f4d0652ed83dd00ae26f6bfdc3ff43d319eea90d4a131f1373d167f2b6582fd +hmac: ae5861af3577c9ef1f568a743392fd59f431c362939928090a0e4a6be9394465 ... From cc36e4ef8992b2b2a49ba1b5902cbe8fecddef1e Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:33:56 -0400 Subject: [PATCH 100/101] deduplicate build --- .drone/drone.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index ef5d26f7bb9d..bd60258adb3c 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -23,7 +23,16 @@ name: Test platform: os: linux arch: amd64 - +trigger: + event: + - push + - pull_request + - tag + ref: + - refs/heads/main + - refs/pull/*/head + - refs/tags/** + steps: - name: test image: rfratto/seego @@ -157,6 +166,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: ae5861af3577c9ef1f568a743392fd59f431c362939928090a0e4a6be9394465 +hmac: 7229c40ced8c5df3fa20a1196e2427c35db161ea4208a7322b460ab44ed57a36 ... From 1a779e2146a72b039daedf2311740889bda49f01 Mon Sep 17 00:00:00 2001 From: Matt Durham Date: Tue, 20 Jul 2021 14:37:26 -0400 Subject: [PATCH 101/101] deduplicate build --- .drone/drone.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index bd60258adb3c..2f6183f1d56a 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -4,10 +4,15 @@ name: Lint platform: os: linux arch: amd64 -when: +trigger: event: - include: - - push + - push + - pull_request + - tag + ref: + - refs/heads/main + - refs/pull/*/head + - refs/tags/** steps: - name: lint @@ -32,7 +37,7 @@ trigger: - refs/heads/main - refs/pull/*/head - refs/tags/** - + steps: - name: test image: rfratto/seego @@ -166,6 +171,6 @@ volumes: path: /var/run/docker.sock --- kind: signature -hmac: 7229c40ced8c5df3fa20a1196e2427c35db161ea4208a7322b460ab44ed57a36 +hmac: 13ae086c4ff0380f263dc4e3e7289bb82b0130e266cd6763e75cf0e451928225 ...