diff --git a/.release b/.release new file mode 100644 index 000000000..e2ed7558e --- /dev/null +++ b/.release @@ -0,0 +1 @@ +release=1.0.0 diff --git a/.travis.yml b/.travis.yml index 6bf432437..7a40f26ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ install: - go get -u golang.org/x/lint/golint - curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh - chmod +x get_helm.sh - - sudo ./get_helm.sh + - ./get_helm.sh before_script: - hack/verify-gofmt.sh @@ -21,4 +21,4 @@ before_script: - helm lint helm/botkube script: - - build/docker.sh infracloudio/botkube latest + - make diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..61f9e5139 --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +IMAGE_REPO=infracloud/botkube +TAG=$(shell cut -d'=' -f2- .release) + +.DEFAULT_GOAL := build +.PHONY: release git-tag check-git-status build pre-build tag-image publish + +#Docker Tasks +#Make a release +release: check-git-status build tag-image publish git-tag + @echo "Successfully released version $(TAG)" + +#Create a git tag +git-tag: + @echo "Creating a git tag" + @git add . + @git commit -m "Bumped to version $(TAG)" ; + @git tag $(TAG) ; + @git push --tags origin master; + @echo 'Git tag pushed successfully' ; + +#Check git status +check-git-status: + @echo "Checking git status" + @if [ -n "$(shell git tag | grep $(TAG))" ] ; then echo 'Tag already exists' && exit 1 ; fi + @if [ -z "$(shell git remote -v)" ] ; then echo 'No remote to push tags to' && exit 1 ; fi + @if [ -z "$(shell git config user.email)" ] ; then echo 'Unable to detect git credentials' && exit 1 ; fi + +#Build the image +build: pre-build + @echo "Building docker image" + @docker build --build-arg GOOS_VAL=$(shell go env GOOS) --build-arg GOARCH_VAL=$(shell go env GOARCH) -t $(IMAGE_REPO) -f build/Dockerfile --no-cache . + @echo "Docker image build successfully" + +#Pre-build checks +pre-build: + @echo "Checking system information" + @if [ -z "$(shell go env GOOS)" ] || [ -z "$(shell go env GOARCH)" ] ; then echo 'Could not determine the system architecture.' && exit 1 ; fi + + +#Tag images +tag-image: + @echo 'Tagging image' + @docker tag $(IMAGE_REPO) $(IMAGE_REPO):$(TAG) + @docker tag $(IMAGE_REPO) $(IMAGE_REPO):latest + +#Docker push image +publish: + @echo "Pushing docker image to repository" + @docker login + @docker push $(IMAGE_REPO):$(TAG) + @docker push $(IMAGE_REPO):latest diff --git a/build/docker.sh b/build/docker.sh deleted file mode 100755 index ad162bfc9..000000000 --- a/build/docker.sh +++ /dev/null @@ -1,13 +0,0 @@ -set +x - -BUILD_ROOT=$(dirname $0) -IMAGE_REPO=${1:-infracloud/botkube} -IMAGE_TAG=${2:-latest} - -[ ! -z $(go env GOOS) ] && [ ! -z $(go env GOARCH) ] && \ - GOOS=$(go env GOOS) && GOARCH=$(go env GOARCH) || \ - echo "Couldn't determine the system architecture." - -pushd ${BUILD_ROOT}/.. -docker build --build-arg GOOS_VAL=${GOOS} --build-arg GOARCH_VAL=${GOARCH} -t $IMAGE_REPO:$IMAGE_TAG -f ${BUILD_ROOT}/Dockerfile --no-cache . -popd diff --git a/helm/botkube/values.yaml b/helm/botkube/values.yaml index b92b74e2a..f44ea9541 100644 --- a/helm/botkube/values.yaml +++ b/helm/botkube/values.yaml @@ -6,7 +6,7 @@ replicaCount: 1 image: repository: infracloud/botkube - tag: "0.4" + tag: "latest" pullPolicy: Always nameOverride: "" diff --git a/pkg/execute/executor.go b/pkg/execute/executor.go index 91e3f20d1..d9996f3df 100644 --- a/pkg/execute/executor.go +++ b/pkg/execute/executor.go @@ -32,16 +32,13 @@ var validNotifierCommand = map[string]bool{ var validPingCommand = map[string]bool{ "ping": true, } -var validHelpCommand = map[string]bool{ - "help": true, -} var kubectlBinary = "/usr/local/bin/kubectl" const ( notifierStartMsg = "Brace yourselves, notifications are coming from cluster '%s'." notifierStopMsg = "Sure! I won't send you notifications from cluster '%s' anymore." - unsupportedCmdMsg = "Command not supported. Please run '@BotKube help' to see supported commands." + unsupportedCmdMsg = "Command not supported. Please run /botkubehelp to see supported commands." kubectlDisabledMsg = "Sorry, the admin hasn't given me the permission to execute kubectl command on cluster '%s'." ) @@ -116,60 +113,10 @@ func (e *DefaultExecutor) Execute() string { if validPingCommand[args[0]] { return runPingCommand(args, e.ClusterName) } - if validHelpCommand[args[0]] { - return printHelp(e.ChannelName) - } - return unsupportedCmdMsg -} - -func printHelp(channelName string) string { - kubecltCmdKeys := make([]string, 0, len(validKubectlCommands)) - for cmd := range validKubectlCommands { - kubecltCmdKeys = append(kubecltCmdKeys, cmd) + if e.IsAuthChannel { + return unsupportedCmdMsg } - allowedKubectl := strings.Join(kubecltCmdKeys, ", ") - helpMsg := ` -BotKube Help - -Usage: - @BotKube [--cluster-name ] - @BotKube notifier [stop|start|status|showconfig] - @BotKube ping [--cluster-name ] - -Description: - -Kubectl commands: - - Executes kubectl commands on k8s cluster and returns output. - - Example: - @BotKube get pods - @BotKube logs podname -n namespace - @BotKube get deployment --cluster-name cluster_name - - Allowed kubectl commands: - %s - -Cluster Status: - - List all available Kubernetes Clusters and check connection health. - - If flag specified, gives response from the specified cluster. - - Example: - @BotKube ping - @BotKube ping --cluster-name mycluster - -Notifier commands: - - Commands to manage notifier (Runs only on configured channel %s). - - Example: - @BotKube notifier stop Stop sending k8s event notifications to Slack - @BotKube notifier start Start sending k8s event notifications to Slack - @BotKube notifier status Show running status of event notifier - @BotKube notifier showconfig Show BotKube configuration for event notifier - -Options: - --cluster-name Get cluster specific response -` - return fmt.Sprintf(helpMsg, allowedKubectl, channelName) + return "" } func printDefaultMsg() string {