Skip to content

Commit

Permalink
Merge pull request #1 from insidieux/1.0.0
Browse files Browse the repository at this point in the history
Version 1.0.0
  • Loading branch information
arslanbekov authored May 2, 2018
2 parents 1f4061f + 2ac1f48 commit 625002c
Show file tree
Hide file tree
Showing 15 changed files with 658 additions and 172 deletions.
12 changes: 12 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM alpine:3.7

ARG APP

COPY "${APP}" /usr/local/bin/slack-duty-bot
COPY .docker/docker-entrypoint /usr/local/bin/

RUN apk --no-cache add ca-certificates

ENTRYPOINT ["docker-entrypoint"]

CMD ["slack-duty-bot"]
9 changes: 9 additions & 0 deletions .docker/docker-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

set -e

if [ "${1#-}" != "$1" ]; then
set -- slack-duty-bot "$@"
fi

exec "$@"
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.md
Gopkg*
Makefile
LICENSE
/vendor
/idea
config.yaml
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
.glide/
/.idea
!/bin/.gitkeep
/bin/*
/bin/*

/vendor
slack-duty-bot
config.yaml
.kubernetes/deploy.yaml
69 changes: 69 additions & 0 deletions .kubernetes/deploy.yaml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
apiVersion: v1
kind: Secret
metadata:
name: slack-duty-bot-${SDB_NAME}-secret
type: Opaque
data:
token: ${SDB_SLACK_TOKEN_BASE64}
---

kind: ConfigMap
apiVersion: v1
metadata:
name: slack-duty-bot-${SDB_NAME}-config-map
data:
config.yaml: |-
slack:
keyword:
- ${SDB_KEYWORD}
group:
id: ${SDB_SLACK_GROUP_ID}
name: ${SDB_SLACK_GROUP_NAME}
duties:
- [${SDB_SLACK_DEFAULT_USER}]
- [${SDB_SLACK_DEFAULT_USER}]
- [${SDB_SLACK_DEFAULT_USER}]
- [${SDB_SLACK_DEFAULT_USER}]
- [${SDB_SLACK_DEFAULT_USER}]
- [${SDB_SLACK_DEFAULT_USER}]
- [${SDB_SLACK_DEFAULT_USER}]
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: slack-duty-bot-${SDB_NAME}
labels:
app: slack-duty-bot-${SDB_NAME}
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 50%
maxSurge: 1
template:
metadata:
labels:
app: slack-duty-bot-${SDB_NAME}
spec:
containers:
- name: slack-duty-bot-${SDB_NAME}
image: insidieux/slack-duty-bot:${SDB_TAG}
imagePullPolicy: Always
args: ["--config.path=/etc/slack-duty-bot"]
env:
- name: SDB_SLACK_TOKEN
valueFrom:
secretKeyRef:
name: slack-duty-bot-${SDB_NAME}-secret
key: token
volumeMounts:
- name: slack-duty-bot-${SDB_NAME}-config-volume
mountPath: /etc/slack-duty-bot
volumes:
- name: slack-duty-bot-${SDB_NAME}-config-volume
configMap:
name: slack-duty-bot-${SDB_NAME}-config-map
restartPolicy: Always
terminationGracePeriodSeconds: 30
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CHANGELOG
=========

1.0.0
-----
* Using Slack RTM
* Configuration with config file, environment variables and flags
* Live reload config file
* Docker image
* Simple Kubernetes deploy

Init
----
* Simple slack-duty-bot working with http outgoing slack webhook
135 changes: 135 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/spf13/pflag"
version = "1.0.1"

[[constraint]]
name = "github.com/spf13/viper"
version = "1.0.2"

[prune]
go-tests = true
unused-packages = true
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
all: build

APP?=slack-duty-bot
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BUILD_OS?=linux
BUILD_ARCH?=amd64
DOCKER_IMAGE?=insidieux/${APP}
DOCKER_TAG?=1.0.0
DOCKER_USER?=user
DOCKER_PASSWORD?=password
SDB_SLACK_TOKEN?=some-token
SDB_SLACK_KEYWORD?=keyword

clean:
rm -f ${APP}

dep-install:
go get -v -u github.com/golang/dep/cmd/dep

dep-ensure: dep-install
rm -rf vendor
dep ensure

test: dep-ensure
go test -v -race ./...

build: clean dep-ensure
env GOOS=${BUILD_OS} GOARCH=${BUILD_ARCH} CGO_ENABLED=0 go build -v -o ${APP}

container: build
docker rmi ${DOCKER_IMAGE}:${DOCKER_TAG} || true
docker build \
--build-arg APP=${APP} \
-f .docker/Dockerfile \
-t ${DOCKER_IMAGE}:${DOCKER_TAG} \
.

run: container
docker stop ${APP} || true && docker rm ${APP} || true
docker run \
--name ${APP} \
--rm \
-e SDB_SLACK_TOKEN=${SDB_SLACK_TOKEN} \
${DOCKER_IMAGE}:${DOCKER_TAG} \
--slack.keyword ${SDB_SLACK_KEYWORD}

push: container
docker login docker.io -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
docker push ${DOCKER_IMAGE}:${DOCKER_TAG}
Loading

0 comments on commit 625002c

Please sign in to comment.