From 38c2f9e52352fa29ca94e3b30631fef63e3f280e Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 25 Apr 2022 12:55:06 +0200 Subject: [PATCH] ci: refactor build tools and ci setup (#31) --- .dockerignore | 2 +- .drone.jsonnet | 67 +++++------------------- .drone.yml | 105 ++++++-------------------------------- .gitignore | 1 + .golangci.yml | 31 +++++++++++ Makefile | 96 ++++++++++++++++++++++++++++++++++ _docs/_index.md | 2 +- cmd/drone-matrix/main.go | 14 +++-- cmd/drone-matrix/tools.go | 8 --- docker/Dockerfile.amd64 | 2 +- docker/Dockerfile.arm | 2 +- docker/Dockerfile.arm64 | 2 +- go.mod | 7 --- go.sum | 19 ------- plugin/impl.go | 4 -- 15 files changed, 171 insertions(+), 191 deletions(-) create mode 100644 .golangci.yml create mode 100644 Makefile delete mode 100644 cmd/drone-matrix/tools.go diff --git a/.dockerignore b/.dockerignore index c13ca3f..92d6c40 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,2 @@ * -!release/ +!dist/ diff --git a/.drone.jsonnet b/.drone.jsonnet index 283bac4..958a9ba 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,6 +1,5 @@ local PipelineTest = { kind: 'pipeline', - image_pull_secrets: ['docker_config'], name: 'test', platform: { os: 'linux', @@ -8,14 +7,14 @@ local PipelineTest = { }, steps: [ { - name: 'staticcheck', + name: 'deps', image: 'golang:1.18', commands: [ - 'go run honnef.co/go/tools/cmd/staticcheck ./...', + 'make deps', ], volumes: [ { - name: 'gopath', + name: 'godeps', path: '/go', }, ], @@ -24,24 +23,11 @@ local PipelineTest = { name: 'lint', image: 'golang:1.18', commands: [ - 'go run golang.org/x/lint/golint -set_exit_status ./...', + 'make lint', ], volumes: [ { - name: 'gopath', - path: '/go', - }, - ], - }, - { - name: 'vet', - image: 'golang:1.18', - commands: [ - 'go vet ./...', - ], - volumes: [ - { - name: 'gopath', + name: 'godeps', path: '/go', }, ], @@ -50,11 +36,11 @@ local PipelineTest = { name: 'test', image: 'golang:1.18', commands: [ - 'go test -cover ./...', + 'make test', ], volumes: [ { - name: 'gopath', + name: 'godeps', path: '/go', }, ], @@ -62,7 +48,7 @@ local PipelineTest = { ], volumes: [ { - name: 'gopath', + name: 'godeps', temp: {}, }, ], @@ -74,7 +60,6 @@ local PipelineTest = { local PipelineBuildBinaries = { kind: 'pipeline', - image_pull_secrets: ['docker_config'], name: 'build-binaries', platform: { os: 'linux', @@ -85,34 +70,14 @@ local PipelineBuildBinaries = { name: 'build', image: 'techknowlogick/xgo:go-1.18.x', commands: [ - '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}', - 'mkdir -p release/', - "cd cmd/drone-matrix && xgo -ldflags \"-s -w -X main.version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-matrix .", - 'mv /build/* /drone/src/release/', - 'ls -l /drone/src/release/', + 'make release', ], }, { name: 'executable', image: 'alpine', commands: [ - '$(find release/ -executable -type f | grep drone-matrix-linux-amd64) --help', - ], - }, - { - name: 'compress', - image: 'alpine', - commands: [ - 'apk add upx', - 'find release/ -maxdepth 1 -executable -type f -exec upx {} \\;', - 'ls -lh release/', - ], - }, - { - name: 'checksum', - image: 'alpine', - commands: [ - 'cd release/ && sha256sum * > sha256sum.txt', + '$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help', ], }, { @@ -139,7 +104,7 @@ local PipelineBuildBinaries = { api_key: { from_secret: 'github_token', }, - files: ['release/*'], + files: ['dist/*'], title: '${DRONE_TAG}', note: 'CHANGELOG.md', }, @@ -160,7 +125,6 @@ local PipelineBuildBinaries = { local PipelineBuildContainer(arch='amd64') = { kind: 'pipeline', - image_pull_secrets: ['docker_config'], name: 'build-container-' + arch, platform: { os: 'linux', @@ -171,20 +135,16 @@ local PipelineBuildContainer(arch='amd64') = { name: 'build', image: 'golang:1.18', commands: [ - '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}', - 'go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/' + arch + '/drone-matrix ./cmd/drone-matrix', + 'make build', ], }, { name: 'dryrun', image: 'thegeeklab/drone-docker:19', settings: { - config: { from_secret: 'docker_config' }, dry_run: true, dockerfile: 'docker/Dockerfile.' + arch, repo: 'thegeeklab/${DRONE_REPO_NAME}', - username: { from_secret: 'docker_username' }, - password: { from_secret: 'docker_password' }, }, depends_on: ['build'], when: { @@ -195,7 +155,6 @@ local PipelineBuildContainer(arch='amd64') = { name: 'publish-dockerhub', image: 'thegeeklab/drone-docker:19', settings: { - config: { from_secret: 'docker_config' }, auto_tag: true, auto_tag_suffix: arch, dockerfile: 'docker/Dockerfile.' + arch, @@ -212,7 +171,6 @@ local PipelineBuildContainer(arch='amd64') = { name: 'publish-quay', image: 'thegeeklab/drone-docker:19', settings: { - config: { from_secret: 'docker_config' }, auto_tag: true, auto_tag_suffix: arch, dockerfile: 'docker/Dockerfile.' + arch, @@ -292,7 +250,6 @@ local PipelineDocs = { local PipelineNotifications = { kind: 'pipeline', - image_pull_secrets: ['docker_config'], name: 'notifications', platform: { os: 'linux', diff --git a/.drone.yml b/.drone.yml index 7993021..d003395 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,45 +7,34 @@ platform: arch: amd64 steps: - - name: staticcheck + - name: deps image: golang:1.18 commands: - - go run honnef.co/go/tools/cmd/staticcheck ./... + - make deps volumes: - - name: gopath + - name: godeps path: /go - name: lint image: golang:1.18 commands: - - go run golang.org/x/lint/golint -set_exit_status ./... + - make lint volumes: - - name: gopath - path: /go - - - name: vet - image: golang:1.18 - commands: - - go vet ./... - volumes: - - name: gopath + - name: godeps path: /go - name: test image: golang:1.18 commands: - - go test -cover ./... + - make test volumes: - - name: gopath + - name: godeps path: /go volumes: - - name: gopath + - name: godeps temp: {} -image_pull_secrets: - - docker_config - trigger: ref: - refs/heads/main @@ -64,28 +53,12 @@ steps: - name: build image: techknowlogick/xgo:go-1.18.x commands: - - "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - - mkdir -p release/ - - cd cmd/drone-matrix && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-matrix . - - mv /build/* /drone/src/release/ - - ls -l /drone/src/release/ + - make release - name: executable image: alpine commands: - - $(find release/ -executable -type f | grep drone-matrix-linux-amd64) --help - - - name: compress - image: alpine - commands: - - apk add upx - - find release/ -maxdepth 1 -executable -type f -exec upx {} \; - - ls -lh release/ - - - name: checksum - image: alpine - commands: - - cd release/ && sha256sum * > sha256sum.txt + - $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help - name: changelog-generate image: thegeeklab/git-chglog @@ -105,7 +78,7 @@ steps: api_key: from_secret: github_token files: - - release/* + - dist/* note: CHANGELOG.md overwrite: true title: ${DRONE_TAG} @@ -113,9 +86,6 @@ steps: ref: - refs/tags/** -image_pull_secrets: - - docker_config - trigger: ref: - refs/heads/main @@ -137,21 +107,14 @@ steps: - name: build image: golang:1.18 commands: - - "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - - go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/drone-matrix ./cmd/drone-matrix + - make build - name: dryrun image: thegeeklab/drone-docker:19 settings: - config: - from_secret: docker_config dockerfile: docker/Dockerfile.amd64 dry_run: true - password: - from_secret: docker_password repo: thegeeklab/${DRONE_REPO_NAME} - username: - from_secret: docker_username when: ref: - refs/pull/** @@ -163,8 +126,6 @@ steps: settings: auto_tag: true auto_tag_suffix: amd64 - config: - from_secret: docker_config dockerfile: docker/Dockerfile.amd64 password: from_secret: docker_password @@ -183,8 +144,6 @@ steps: settings: auto_tag: true auto_tag_suffix: amd64 - config: - from_secret: docker_config dockerfile: docker/Dockerfile.amd64 password: from_secret: quay_password @@ -199,9 +158,6 @@ steps: depends_on: - dryrun -image_pull_secrets: - - docker_config - trigger: ref: - refs/heads/main @@ -223,21 +179,14 @@ steps: - name: build image: golang:1.18 commands: - - "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - - go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/drone-matrix ./cmd/drone-matrix + - make build - name: dryrun image: thegeeklab/drone-docker:19 settings: - config: - from_secret: docker_config dockerfile: docker/Dockerfile.arm64 dry_run: true - password: - from_secret: docker_password repo: thegeeklab/${DRONE_REPO_NAME} - username: - from_secret: docker_username when: ref: - refs/pull/** @@ -249,8 +198,6 @@ steps: settings: auto_tag: true auto_tag_suffix: arm64 - config: - from_secret: docker_config dockerfile: docker/Dockerfile.arm64 password: from_secret: docker_password @@ -269,8 +216,6 @@ steps: settings: auto_tag: true auto_tag_suffix: arm64 - config: - from_secret: docker_config dockerfile: docker/Dockerfile.arm64 password: from_secret: quay_password @@ -285,9 +230,6 @@ steps: depends_on: - dryrun -image_pull_secrets: - - docker_config - trigger: ref: - refs/heads/main @@ -309,21 +251,14 @@ steps: - name: build image: golang:1.18 commands: - - "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - - go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm/drone-matrix ./cmd/drone-matrix + - make build - name: dryrun image: thegeeklab/drone-docker:19 settings: - config: - from_secret: docker_config dockerfile: docker/Dockerfile.arm dry_run: true - password: - from_secret: docker_password repo: thegeeklab/${DRONE_REPO_NAME} - username: - from_secret: docker_username when: ref: - refs/pull/** @@ -335,8 +270,6 @@ steps: settings: auto_tag: true auto_tag_suffix: arm - config: - from_secret: docker_config dockerfile: docker/Dockerfile.arm password: from_secret: docker_password @@ -355,8 +288,6 @@ steps: settings: auto_tag: true auto_tag_suffix: arm - config: - from_secret: docker_config dockerfile: docker/Dockerfile.arm password: from_secret: quay_password @@ -371,9 +302,6 @@ steps: depends_on: - dryrun -image_pull_secrets: - - docker_config - trigger: ref: - refs/heads/main @@ -513,9 +441,6 @@ steps: - success - failure -image_pull_secrets: - - docker_config - trigger: ref: - refs/heads/main @@ -529,6 +454,6 @@ depends_on: --- kind: signature -hmac: c6f1ed11d885e74ecf6b70f55f4de834c69fafc48e8e28d381ee10d3fb8d9757 +hmac: 08707ab293e9a34853d2568004f486b98ec758581ada47e84cadd6b4bfeb29ab ... diff --git a/.gitignore b/.gitignore index df012d1..50e1edc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/dist/ /release/ /drone-matrix* diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..7bb18ea --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,31 @@ +linters: + enable: + - gosimple + - deadcode + - typecheck + - govet + - errcheck + - staticcheck + - unused + - structcheck + - varcheck + - dupl + - gofmt + - misspell + - gocritic + - bidichk + - ineffassign + - revive + - gofumpt + - depguard + enable-all: false + disable-all: true + fast: false + +run: + timeout: 3m + +linters-settings: + gofumpt: + extra-rules: true + lang-version: "1.18" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d6b0519 --- /dev/null +++ b/Makefile @@ -0,0 +1,96 @@ +# renovate: datasource=github-releases depName=mvdan/gofumpt +GOFUMPT_PACKAGE_VERSION := v0.3.1 +# renovate: datasource=github-releases depName=golangci/golangci-lint +GOLANGCI_LINT_PACKAGE_VERSION := v1.45.2 + +EXECUTABLE := drone-matrix + +DIST := dist +DIST_DIRS := $(DIST) +IMPORT := github.com/thegeeklab/$(EXECUTABLE) + +GO ?= go +CWD ?= $(shell pwd) +PACKAGES ?= $(shell go list ./...) +SOURCES ?= $(shell find . -name "*.go" -type f) + +GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@$(GOFUMPT_PACKAGE_VERSION) +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_PACKAGE_VERSION) +XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest + +GENERATE ?= +XGO_VERSION := go-1.18.x +XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64 + +TAGS ?= netgo + +ifndef VERSION + ifneq ($(DRONE_TAG),) + VERSION ?= $(subst v,,$(DRONE_TAG)) + else + VERSION ?= $(shell git rev-parse --short HEAD) + endif +endif + +ifndef DATE + DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%S%z") +endif + +LDFLAGS += -s -w -X "main.BuildVersion=$(VERSION)" -X "main.BuildDate=$(DATE)" + +.PHONY: all +all: clean build + +.PHONY: clean +clean: + $(GO) clean -i ./... + rm -rf $(DIST_DIRS) + +.PHONY: fmt +fmt: + $(GO) run $(GOFUMPT_PACKAGE) -extra -w $(SOURCES) + +.PHONY: golangci-lint +golangci-lint: + $(GO) run $(GOLANGCI_LINT_PACKAGE) run + +.PHONY: lint +lint: golangci-lint + +.PHONY: generate +generate: + $(GO) generate $(GENERATE) + +.PHONY: test +test: + $(GO) test -v -coverprofile coverage.out $(PACKAGES) + +.PHONY: build +build: $(DIST)/$(EXECUTABLE) + +$(DIST)/$(EXECUTABLE): $(SOURCES) + $(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE) + +$(DIST_DIRS): + mkdir -p $(DIST_DIRS) + +.PHONY: xgo +xgo: | $(DIST_DIRS) + $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -v -ldflags '-extldflags "-static" $(LDFLAGS)' -tags '$(TAGS)' -targets '$(XGO_TARGETS)' -out $(EXECUTABLE) --pkg cmd/$(EXECUTABLE) . + cp /build/* $(CWD)/$(DIST) + ls -l $(CWD)/$(DIST) + +.PHONY: checksum +checksum: + cd $(DIST); $(foreach file,$(wildcard $(DIST)/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) + ls -l $(CWD)/$(DIST) + +.PHONY: release +release: xgo checksum + +.PHONY: deps +deps: + $(GO) mod download + $(GO) install $(GOFUMPT_PACKAGE) + $(GO) install $(GOLANGCI_LINT_PACKAGE) + $(GO) install $(XGO_PACKAGE) diff --git a/_docs/_index.md b/_docs/_index.md index 39f7a6c..9ec8847 100644 --- a/_docs/_index.md +++ b/_docs/_index.md @@ -27,7 +27,7 @@ export GOARCH=amd64 export CGO_ENABLED=0 export GO111MODULE=on -go build -v -a -tags netgo -o release/linux/amd64/drone-matrix +make build ``` Build the Docker image with the following command: diff --git a/cmd/drone-matrix/main.go b/cmd/drone-matrix/main.go index 3a0d513..38f933a 100644 --- a/cmd/drone-matrix/main.go +++ b/cmd/drone-matrix/main.go @@ -7,6 +7,7 @@ package main import ( + "fmt" "os" "github.com/drone-plugins/drone-matrix/plugin" @@ -16,19 +17,26 @@ import ( "github.com/urfave/cli/v2" ) -var version = "unknown" +var ( + BuildVersion = "devel" + BuildDate = "00000000" +) func main() { settings := &plugin.Settings{} if _, err := os.Stat("/run/drone/env"); err == nil { - godotenv.Overload("/run/drone/env") + _ = godotenv.Overload("/run/drone/env") + } + + cli.VersionPrinter = func(c *cli.Context) { + fmt.Printf("%s version=%s date=%s\n", c.App.Name, c.App.Version, BuildDate) } app := &cli.App{ Name: "drone-matrix", Usage: "build notifications for matrix", - Version: version, + Version: BuildVersion, Flags: append(settingsFlags(settings), urfave.Flags()...), Action: run(settings), } diff --git a/cmd/drone-matrix/tools.go b/cmd/drone-matrix/tools.go deleted file mode 100644 index 464dc0a..0000000 --- a/cmd/drone-matrix/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build tools - -package tools - -import ( - _ "golang.org/x/lint/golint" - _ "honnef.co/go/tools/cmd/staticcheck" -) diff --git a/docker/Dockerfile.amd64 b/docker/Dockerfile.amd64 index 8329d8e..6bea9d7 100644 --- a/docker/Dockerfile.amd64 +++ b/docker/Dockerfile.amd64 @@ -7,5 +7,5 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-matrix" -ADD release/amd64/drone-matrix /bin/ +ADD dist/drone-matrix /bin/ ENTRYPOINT [ "/bin/drone-matrix" ] diff --git a/docker/Dockerfile.arm b/docker/Dockerfile.arm index 7bf907e..3f4c448 100644 --- a/docker/Dockerfile.arm +++ b/docker/Dockerfile.arm @@ -7,5 +7,5 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-matrix" -ADD release/arm/drone-matrix /bin/ +ADD dist/drone-matrix /bin/ ENTRYPOINT [ "/bin/drone-matrix" ] diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index 3521f1e..117ff9a 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -7,5 +7,5 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-matrix" -ADD release/arm64/drone-matrix /bin/ +ADD dist/drone-matrix /bin/ ENTRYPOINT [ "/bin/drone-matrix" ] diff --git a/go.mod b/go.mod index 672642c..abd2385 100644 --- a/go.mod +++ b/go.mod @@ -10,12 +10,9 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 github.com/thegeeklab/drone-template-lib/v2 v2.1.0 github.com/urfave/cli/v2 v2.4.0 - golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 - honnef.co/go/tools v0.3.0 ) require ( - github.com/BurntSushi/toml v1.0.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.1.1 // indirect github.com/Masterminds/sprig/v3 v3.2.2 // indirect @@ -32,10 +29,6 @@ require ( github.com/sirupsen/logrus v1.8.1 // indirect github.com/spf13/cast v1.4.1 // indirect golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 // indirect - golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb // indirect - golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect golang.org/x/net v0.0.0-20220325170049-de3da57026de // indirect golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect - golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/go.sum b/go.sum index 8ebd0e6..a49778c 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,4 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= -github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= @@ -71,20 +69,11 @@ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2 github.com/urfave/cli/v2 v2.4.0 h1:m2pxjjDFgDxSPtO8WSdbndj17Wu2y8vOT86wE/tjr+I= github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 h1:S25/rfnfsMVgORT4/J61MJ7rdyseOZOyvLIrZEZ7s6s= golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb h1:fP6C8Xutcp5AlakmT/SkQot0pMicROAsEX7OfNPuG10= -golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220325170049-de3da57026de h1:pZB1TWnKi+o4bENlbzAgLrEbY4RMYmUIRobMcSmfeYc= golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -102,12 +91,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e h1:lVQAEpHVTmp9WjosvG0WcHRqP3JZv97KkBX4YDdaDfU= -golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -115,5 +98,3 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= -honnef.co/go/tools v0.3.0 h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU= -honnef.co/go/tools v0.3.0/go.mod h1:vlRD9XErLMGT+mDuofSr0mMMquscM/1nQqtRSsh6m70= diff --git a/plugin/impl.go b/plugin/impl.go index a240b54..58875c5 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -36,7 +36,6 @@ func (p *Plugin) Validate() error { // Execute provides the implementation of the plugin. func (p *Plugin) Execute() error { m, err := gomatrix.NewClient(p.settings.Homeserver, prepend("@", p.settings.UserID), p.settings.AccessToken) - if err != nil { return fmt.Errorf("failed to initialize client: %w", err) } @@ -48,7 +47,6 @@ func (p *Plugin) Execute() error { Password: p.settings.Password, InitialDeviceDisplayName: "Drone", }) - if err != nil { return fmt.Errorf("failed to authenticate user: %w", err) } @@ -57,13 +55,11 @@ func (p *Plugin) Execute() error { } joined, err := m.JoinRoom(prepend("!", p.settings.RoomID), "", nil) - if err != nil { return fmt.Errorf("failed to join room: %w", err) } message, err := template.RenderTrim(p.settings.Template, p.pipeline) - if err != nil { return fmt.Errorf("failed to render template: %w", err) }