Merge branch 'source_develop' into ft/TD-74

# Conflicts:
#	hack/goreleaser.sh
This commit is contained in:
ivnmrtk 2022-05-19 12:32:33 +03:00
commit fb5011be59
8 changed files with 75 additions and 66 deletions

View File

@ -30,8 +30,7 @@ jobs:
uses: goreleaser/goreleaser-action@v2 uses: goreleaser/goreleaser-action@v2
with: with:
install-only: true install-only: true
# Newer goreleaser version doesn't allow builds with "latest" tag version: latest
version: v0.179.0
- name: Run GoReleaser - name: Run GoReleaser
run: make release-snapshot run: make release-snapshot
- name: Install Helm - name: Install Helm

View File

@ -1,58 +1,59 @@
project_name: botkube
before: before:
hooks: hooks:
- go mod download - go mod download
builds: builds:
- id: botkube - id: botkube
binary: botkube binary: botkube
main: cmd/botkube/main.go main: cmd/botkube/main.go
ldflags: &ldflags ldflags: &ldflags
- -s -w - -s -w
-X github.com/infracloudio/botkube/pkg/version.Version={{ .Tag }} -X github.com/infracloudio/botkube/pkg/version.Version={{ .Tag }}
-X github.com/infracloudio/botkube/pkg/version.GitCommitID={{ .Commit }} -X github.com/infracloudio/botkube/pkg/version.GitCommitID={{ .Commit }}
-X github.com/infracloudio/botkube/pkg/version.BuildDate={{ .Date }} -X github.com/infracloudio/botkube/pkg/version.BuildDate={{ .Date }}
env: env:
- CGO_ENABLED=0 - CGO_ENABLED=0
goos: goos:
- linux - linux
goarch: goarch:
- amd64 - amd64
- arm - arm
- arm64 - arm64
goarm: goarm:
- 7 - 7
snapshot: snapshot:
name_template: "{{ .Tag }}" name_template: "{{ .Tag }}"
changelog: changelog:
skip: true skip: true
dockers: dockers:
- image_templates: - image_templates:
- 'ghcr.io/infracloudio/botkube:{{ .Tag }}-amd64' - "ghcr.io/infracloudio/botkube:{{ .Tag }}-amd64"
use: buildx use: buildx
dockerfile: 'build/Dockerfile' dockerfile: "build/Dockerfile"
build_flag_templates: build_flag_templates:
- "--platform=linux/amd64" - "--platform=linux/amd64"
- "--build-arg=botkube_version={{ .Tag }}" - "--build-arg=botkube_version={{ .Tag }}"
- image_templates: - image_templates:
- 'ghcr.io/infracloudio/botkube:{{ .Tag }}-arm64' - "ghcr.io/infracloudio/botkube:{{ .Tag }}-arm64"
use: buildx use: buildx
goarch: arm64 goarch: arm64
dockerfile: 'build/Dockerfile' dockerfile: "build/Dockerfile"
build_flag_templates: build_flag_templates:
- "--platform=linux/arm64" - "--platform=linux/arm64"
- "--build-arg=botkube_version={{ .Tag }}" - "--build-arg=botkube_version={{ .Tag }}"
- image_templates: - image_templates:
- 'ghcr.io/infracloudio/botkube:{{ .Tag }}-armv7' - "ghcr.io/infracloudio/botkube:{{ .Tag }}-armv7"
use: buildx use: buildx
goarch: arm goarch: arm
goarm: 7 goarm: 7
dockerfile: 'build/Dockerfile' dockerfile: "build/Dockerfile"
build_flag_templates: build_flag_templates:
- "--platform=linux/arm" - "--platform=linux/arm"
- "--build-arg=botkube_version={{ .Tag }}" - "--build-arg=botkube_version={{ .Tag }}"
docker_manifests: docker_manifests:
- name_template: ghcr.io/infracloudio/botkube:{{ .Tag }} - name_template: ghcr.io/infracloudio/botkube:{{ .Tag }}
image_templates: image_templates:
- ghcr.io/infracloudio/botkube:{{ .Tag }}-amd64 - ghcr.io/infracloudio/botkube:{{ .Tag }}-amd64
- ghcr.io/infracloudio/botkube:{{ .Tag }}-arm64 - ghcr.io/infracloudio/botkube:{{ .Tag }}-arm64
- ghcr.io/infracloudio/botkube:{{ .Tag }}-armv7 - ghcr.io/infracloudio/botkube:{{ .Tag }}-armv7

View File

@ -29,12 +29,12 @@ Now you can build and run BotKube by one of the following ways
### Build the container image ### Build the container image
1. This will build BotKube and create a new container image tagged as `infracloudio/botkube:latest` 1. This will build BotKube and create a new container image tagged as `ghcr.io/infracloudio/botkube:v9.99.9-dev`
```sh ```sh
$ make build $ make build
$ make container-image $ make container-image
$ docker tag infracloudio/botkube:latest-amd64 <your_account>/botkube:latest $ docker tag ghcr.io/infracloudio/botkube:v9.99.9-dev-amd64 <your_account>/botkube:v9.99.9-dev
$ docker push <your_account>/botkube:latest $ docker push <your_account>/botkube:v9.99.9-dev
``` ```
Where `<your_account>` is Docker hub account to which you can push the image Where `<your_account>` is Docker hub account to which you can push the image
@ -53,7 +53,7 @@ Now you can build and run BotKube by one of the following ways
--set settings.clustername=<CLUSTER_NAME> \ --set settings.clustername=<CLUSTER_NAME> \
--set settings.kubectl.enabled=<ALLOW_KUBECTL> \ --set settings.kubectl.enabled=<ALLOW_KUBECTL> \
--set image.repository=<your_account>/botkube \ --set image.repository=<your_account>/botkube \
--set image.tag=latest \ --set image.tag=v9.99.9-dev \
infracloudio/botkube infracloudio/botkube
``` ```

View File

@ -50,7 +50,7 @@ gorelease:
@echo "Publishing release with goreleaser" @echo "Publishing release with goreleaser"
@./hack/goreleaser.sh release @./hack/goreleaser.sh release
# Build project and push dev images with latest tag # Build project and push dev images with v9.99.9-dev tag
release-snapshot: release-snapshot:
@./hack/goreleaser.sh release_snapshot @./hack/goreleaser.sh release_snapshot

1
go.mod
View File

@ -28,6 +28,7 @@ require (
github.com/sirupsen/logrus v1.7.0 github.com/sirupsen/logrus v1.7.0
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
go.uber.org/multierr v1.2.0 // indirect go.uber.org/multierr v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect

5
go.sum
View File

@ -513,8 +513,9 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201217014255-9d1352758620 h1:3wPMTskHO3+O6jqTEXyFcsnuxMQOqYSaHsDxcbUXpqA=
golang.org/x/crypto v0.0.0-20201217014255-9d1352758620/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201217014255-9d1352758620/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@ -582,6 +583,7 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211209124913-491a49abca63 h1:iocB37TsdFuN6IBRZ+ry36wrkoV51/tl5vOWqkcPGvY= golang.org/x/net v0.0.0-20211209124913-491a49abca63 h1:iocB37TsdFuN6IBRZ+ry36wrkoV51/tl5vOWqkcPGvY=
golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@ -645,6 +647,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk= golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/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-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=

View File

@ -29,18 +29,18 @@ prepare() {
release_snapshot() { release_snapshot() {
prepare prepare
export GORELEASER_CURRENT_TAG=latest export GORELEASER_CURRENT_TAG=v9.99.9-dev
goreleaser release --rm-dist --snapshot --skip-publish goreleaser release --rm-dist --snapshot --skip-publish
# Push images # Push images
docker push ghcr.io/valitydev/botkube:latest-amd64 docker push ghcr.io/valitydev/botkube:${GORELEASER_CURRENT_TAG}-amd64
docker push ghcr.io/valitydev/botkube:latest-arm64 docker push ghcr.io/valitydev/botkube:${GORELEASER_CURRENT_TAG}-arm64
docker push ghcr.io/valitydev/botkube:latest-armv7 docker push ghcr.io/valitydev/botkube:${GORELEASER_CURRENT_TAG}-armv7
# Create manifest # Create manifest
docker manifest create ghcr.io/valitydev/botkube:latest \ docker manifest create ghcr.io/valitydev/botkube:${GORELEASER_CURRENT_TAG} \
--amend ghcr.io/valitydev/botkube:latest-amd64 \ --amend ghcr.io/valitydev/botkube:${GORELEASER_CURRENT_TAG}-amd64 \
--amend ghcr.io/valitydev/botkube:latest-arm64 \ --amend ghcr.io/valitydev/botkube:${GORELEASER_CURRENT_TAG}-arm64 \
--amend ghcr.io/valitydev/botkube:latest-armv7 --amend ghcr.io/valitydev/botkube:${GORELEASER_CURRENT_TAG}-armv7
docker manifest push ghcr.io/valitydev/botkube:latest docker manifest push ghcr.io/valitydev/botkube:${GORELEASER_CURRENT_TAG}
} }
build() { build() {
@ -49,7 +49,7 @@ build() {
-v $PWD:/go/src/github.com/valitydev/botkube \ -v $PWD:/go/src/github.com/valitydev/botkube \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/valitydev/botkube \ -w /go/src/github.com/valitydev/botkube \
-e GORELEASER_CURRENT_TAG=latest \ -e GORELEASER_CURRENT_TAG=v9.99.9-dev \
goreleaser/goreleaser release --rm-dist --snapshot --skip-publish goreleaser/goreleaser release --rm-dist --snapshot --skip-publish
} }
@ -69,7 +69,7 @@ usage() {
Usage: ${0} [build|release|release_snapshot] Usage: ${0} [build|release|release_snapshot]
Where, Where,
build: Builds project with goreleaser without pushing images. build: Builds project with goreleaser without pushing images.
release_snapshot: Builds project without publishing release. It builds and pushes BotKube image with latest image tag. release_snapshot: Builds project without publishing release. It builds and pushes BotKube image with v9.99.9-dev image tag.
release: Makes and published release to GitHub release: Makes and published release to GitHub
EOM EOM
exit 1 exit 1

View File

@ -124,6 +124,11 @@ func New(object interface{}, eventType config.EventType, resource, clusterName s
event.Count = eventObj.Count event.Count = eventObj.Count
event.Action = eventObj.Action event.Action = eventObj.Action
event.TimeStamp = eventObj.LastTimestamp.Time event.TimeStamp = eventObj.LastTimestamp.Time
// Compatible with events.k8s.io/v1
if eventObj.LastTimestamp.IsZero() {
event.TimeStamp = eventObj.Series.LastObservedTime.Time
event.Count = eventObj.Series.Count
}
} }
return event return event
} }