Skip to content

Commit

Permalink
Merge pull request #350 from moira-alert/develop
Browse files Browse the repository at this point in the history
Release 2.5
  • Loading branch information
borovskyav authored Apr 12, 2019
2 parents 8fb1287 + 0e3d04c commit 4c03982
Show file tree
Hide file tree
Showing 249 changed files with 11,929 additions and 8,157 deletions.
16 changes: 3 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ services:
- redis-server
language: go
go:
- 1.11.2
- 1.11.5
git:
depth: 1000
addons:
apt:
packages: rpm
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/9992cd0d36a6ba9bb40b
on_success: change
on_failure: always
on_start: never
slack:
secure: ZzUtFRyc8lJfO1+qVf/oWd3PK7x3gb/MiC4U4atMmHQX2Vr+zHBZiVijK91sBhozJ7oP0GWkgmVqbKG5GDqEGur7Nt0aNfx9GU2d6dqvFeQGY910EDK9wmdSCMk3gfZ1d1ur2NmkyxNRlbDnlHIGdTgzqrKsvlhk9BxLw1D1/1Ap57pZxkCGsu9VP/NUZhywo8T7HhLyarKO3iBhNFQqR1ifVHS0KjDS6p+4JXg74Ufq91WEWw+/L6NMSO9DPDu1i4HHp6rNE2rjR/0O5Nl8AtIApFOpdjh/9vNv9Mm/S/8PpfPo4nuhL1YGsdCd2dRf9owMQVfVgxZVNK/wyt+NxbG3IuuUf0Nve4wgnKLBaiqLgHw++uLS/+jADY/d9EN4Pb0oLQ5S0cKhFjJ63B3z0MsGoYkZCvpBvHKcOt2zWmiK+ugx2Er2KRSonGYpHHLdGxvlUFuWf5vBh/dnyxYMtnbtryW0xIabHKkXT2lr00xdNRNYYZPAfN0Rdp6BJjzel1yPnj71aNW7qmauMqiCZDjjiLZ6nvL7WEvsJoQyz84LNSv9zQK2XEaGF3bA8OOf6Mse25PWoCUjHwOQQncdLKTb0/RQOWykLAHIjagKotXV8RtTNXN3kYQwUAst7cYESYeTlqB510dKge74R6rQOrrMCInGuDfzZ3+duqVXip4=
on_success: never
on_failure: always
before_install:
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
Expand Down Expand Up @@ -59,12 +55,6 @@ deploy:
skip_cleanup: true
on:
branch: develop
- provider: script
script:
- make docker_latest_images
skip_cleanup: true
on:
branch: master
- provider: script
script:
- make docker_release_images
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.api
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.2 as builder
FROM golang:1.11.5 as builder

WORKDIR /go/src/github.com/moira-alert/moira
COPY . /go/src/github.com/moira-alert/moira/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.checker
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.2 as builder
FROM golang:1.11.5 as builder

WORKDIR /go/src/github.com/moira-alert/moira
COPY . /go/src/github.com/moira-alert/moira/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.filter
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.2 as builder
FROM golang:1.11.5 as builder

WORKDIR /go/src/github.com/moira-alert/moira
COPY . /go/src/github.com/moira-alert/moira/
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile.notifier
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.2 as builder
FROM golang:1.11.5 as builder

WORKDIR /go/src/github.com/moira-alert/moira
COPY . /go/src/github.com/moira-alert/moira/
Expand All @@ -16,7 +16,6 @@ FROM alpine
RUN apk add --no-cache ca-certificates && update-ca-certificates

COPY pkg/notifier/notifier.yml /etc/moira/notifier.yml
COPY pkg/notifier/fancy-template.html /etc/moira/fancy-template.html

COPY --from=builder /go/src/github.com/moira-alert/moira/build/notifier /usr/bin/notifier
COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /usr/local/go/lib/time/
Expand Down
54 changes: 25 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
MARK_NIGHTLY := "nightly"
MARK_UNSTABLE := "unstable"
GIT_BRANCH := "unknown"
GIT_HASH := $(shell git log --pretty=format:%H -n 1)
GIT_HASH_SHORT := $(shell echo "${GIT_HASH}" | cut -c1-6)
GIT_HASH_SHORT := $(shell echo "${GIT_HASH}" | cut -c1-7)
GIT_TAG := $(shell git describe --always --tags --abbrev=0 | tail -c+2)
GIT_COMMIT := $(shell git rev-list v${GIT_TAG}..HEAD --count)
GIT_COMMIT_DATE := $(shell git show -s --format=%ci | cut -d\ -f1)
GO_VERSION := $(shell go version | cut -d' ' -f3)
FEATURE_VERSION := ${GIT_TAG}-${GIT_BRANCH}
DEVELOP_VERSION := nightly-${GIT_HASH_SHORT}
VERSION := ${GIT_TAG}.${GIT_COMMIT}
VERSION_FEATURE := ${GIT_TAG}-${GIT_BRANCH}
VERSION_DEVELOP := ${GIT_COMMIT_DATE}-${GIT_HASH_SHORT}
VERSION_RELEASE := ${GIT_TAG}.${GIT_COMMIT}
VENDOR := "SKB Kontur"
URL := "https://github.com/moira-alert/moira"
LICENSE := "MIT"
Expand All @@ -23,7 +26,7 @@ prepare:
lint: prepare
go get -u github.com/alecthomas/gometalinter
gometalinter --install
gometalinter ./... --vendor --skip mock --disable=errcheck --disable=gocyclo --disable=gosec --deadline=5m
gometalinter ./... --aggregate --vendor --skip mock --disable=errcheck --disable=gocyclo --disable=gosec --deadline=5m

.PHONY: test
test: prepare
Expand All @@ -32,7 +35,7 @@ test: prepare
.PHONY: build
build: prepare
for service in "filter" "notifier" "api" "checker" "cli" ; do \
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-X main.MoiraVersion=${VERSION} -X main.GoVersion=${GO_VERSION} -X main.GitCommit=${GIT_HASH}" -o build/$$service github.com/moira-alert/moira/cmd/$$service ; \
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-X main.MoiraVersion=${VERSION_RELEASE} -X main.GoVersion=${GO_VERSION} -X main.GitCommit=${GIT_HASH}" -o build/$$service github.com/moira-alert/moira/cmd/$$service ; \
done

.PHONY: clean
Expand All @@ -52,9 +55,8 @@ tar:
cp pkg/$$service/moira-$$service.service build/root/$$service/usr/lib/systemd/system/moira-$$service.service ; \
done
cp pkg/filter/storage-schemas.conf build/root/filter/etc/moira/storage-schemas.conf
cp pkg/notifier/*.html build/root/notifier/etc/moira/
for service in "filter" "notifier" "api" "checker" "cli" ; do \
tar -czvPf build/moira-$$service-${VERSION}.tar.gz -C build/root/$$service . ; \
tar -czvPf build/moira-$$service-${VERSION_RELEASE}.tar.gz -C build/root/$$service . ; \
done

.PHONY: rpm
Expand All @@ -67,12 +69,12 @@ rpm: tar
--url ${URL} \
--license ${LICENSE} \
--name "moira-$$service" \
--version "${VERSION}" \
--version "${VERSION_RELEASE}" \
--iteration "1" \
--config-files "/etc/moira/$$service.yml" \
--after-install "./pkg/$$service/postinst" \
-p build \
build/moira-$$service-${VERSION}.tar.gz ; \
build/moira-$$service-${VERSION_RELEASE}.tar.gz ; \
done
fpm -t rpm \
-s "tar" \
Expand All @@ -81,13 +83,13 @@ rpm: tar
--url ${URL} \
--license ${LICENSE} \
--name "moira-filter" \
--version "${VERSION}" \
--version "${VERSION_RELEASE}" \
--iteration "1" \
--config-files "/etc/moira/filter.yml" \
--config-files "/etc/moira/storage-schemas.conf" \
--after-install "./pkg/filter/postinst" \
-p build \
build/moira-filter-${VERSION}.tar.gz
build/moira-filter-${VERSION_RELEASE}.tar.gz

.PHONY: deb
deb: tar
Expand All @@ -99,12 +101,12 @@ deb: tar
--url ${URL} \
--license ${LICENSE} \
--name "moira-$$service" \
--version "${VERSION}" \
--version "${VERSION_RELEASE}" \
--iteration "1" \
--config-files "/etc/moira/$$service.yml" \
--after-install "./pkg/$$service/postinst" \
-p build \
build/moira-$$service-${VERSION}.tar.gz ; \
build/moira-$$service-${VERSION_RELEASE}.tar.gz ; \
done
fpm -t deb \
-s "tar" \
Expand All @@ -113,41 +115,35 @@ deb: tar
--url ${URL} \
--license ${LICENSE} \
--name "moira-filter" \
--version "${VERSION}" \
--version "${VERSION_RELEASE}" \
--iteration "1" \
--config-files "/etc/moira/filter.yml" \
--config-files "/etc/moira/storage-schemas.conf" \
--after-install "./pkg/filter/postinst" \
-p build \
build/moira-filter-${VERSION}.tar.gz
build/moira-filter-${VERSION_RELEASE}.tar.gz

.PHONY: packages
packages: clean build tar rpm deb

.PHONY: docker_feature_images
docker_feature_images:
for service in "filter" "notifier" "api" "checker" ; do \
docker build --build-arg MoiraVersion=${FEATURE_VERSION} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:${FEATURE_VERSION} . ; \
docker push moira/$$service:${FEATURE_VERSION} ; \
docker build --build-arg MoiraVersion=${VERSION_FEATURE} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service-${MARK_UNSTABLE}:${VERSION_FEATURE} . ; \
docker push moira/$$service-${MARK_UNSTABLE}:${VERSION_FEATURE} ; \
done

.PHONY: docker_develop_images
docker_develop_images:
for service in "filter" "notifier" "api" "checker" ; do \
docker build --build-arg MoiraVersion=${DEVELOP_VERSION} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:${DEVELOP_VERSION} . ; \
docker push moira/$$service:${DEVELOP_VERSION} ; \
done

.PHONY: docker_latest_images
docker_latest_images:
for service in "filter" "notifier" "api" "checker" ; do \
docker build --build-arg MoiraVersion=${VERSION} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:latest . ; \
docker push moira/$$service:latest ; \
docker build --build-arg MoiraVersion=${VERSION_DEVELOP} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service-${MARK_NIGHTLY}:${VERSION_DEVELOP} . ; \
docker push moira/$$service-${MARK_NIGHTLY}:${VERSION_DEVELOP} ; \
done

.PHONY: docker_release_images
docker_release_images:
for service in "filter" "notifier" "api" "checker" ; do \
docker build --build-arg MoiraVersion=${VERSION} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:${VERSION} . ; \
docker push moira/$$service:${VERSION} ; \
docker build --build-arg MoiraVersion=${VERSION_RELEASE} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:${VERSION_RELEASE} -t moira/$$service:latest . ; \
docker push moira/$$service:${VERSION_RELEASE} ; \
docker push moira/$$service:latest ; \
done
12 changes: 8 additions & 4 deletions api/controller/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/go-graphite/carbonapi/date"
"github.com/satori/go.uuid"
"github.com/gofrs/uuid"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/api"
Expand Down Expand Up @@ -35,7 +35,11 @@ func CreateContact(dataBase moira.Database, contact *dto.Contact, userLogin stri
Value: contact.Value,
}
if contactData.ID == "" {
contactData.ID = uuid.NewV4().String()
uuid4, err := uuid.NewV4()
if err != nil {
return api.ErrorInternalServer(err)
}
contactData.ID = uuid4.String()
} else {
exists, err := isContactExists(dataBase, contactData.ID)
if err != nil {
Expand Down Expand Up @@ -126,8 +130,8 @@ func SendTestContactNotification(dataBase moira.Database, contactID string) *api
ContactID: contactID,
Metric: "Test.metric.value",
Value: &value,
OldState: "TEST",
State: "TEST",
OldState: moira.StateTEST,
State: moira.StateTEST,
Timestamp: date.DateParamToEpoch("now", "", time.Now().Add(-24*time.Hour).Unix(), time.UTC),
}
if err := dataBase.PushNotificationEvent(eventData, false); err != nil {
Expand Down
Loading

0 comments on commit 4c03982

Please sign in to comment.