Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Fixed Pre-commit Formatting and added go report card
Browse files Browse the repository at this point in the history
  • Loading branch information
medyagh committed Jul 21, 2017
1 parent 0307b34 commit 8599d25
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
BINARY=k8guard-action
.DEFAULT_GOAL := help
.PHONY: help

BINARY=k8guard-action
VERSION=`git fetch;git describe --tags > /dev/null 2>&1`
BUILD=`date +%FT%T%z`

LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"

all: deps build test
all: deps build test ## install dependecies, build for linux

create-pre-commit-hooks: ## creates pre-commit hooks
chmod +x $(CURDIR)/hooks/pre-commit
ln -s $(CURDIR)/hooks/pre-commit .git/hooks/pre-commit || true

deps:
deps: ## install dependecies
glide install

glide-update:
glide cc
glide update

build-docker:
build-docker: ## builds docker local/k8guard-action
docker build -t local/k8guard-action .

build:
build: ## builds binary for linux
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY}

mac:
mac: ## builds binary for mac
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY}

dev-setup:
Expand All @@ -30,7 +36,8 @@ clean:
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi
go clean

sclean: clean
sclean: clean ## super clean, cleans binary and glide lock
rm glide.lock

.PHONY: build
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# k8guard-action
[![Go Report Card](https://goreportcard.com/badge/github.com/k8guard/k8guard-action)](https://goreportcard.com/report/github.com/k8guard/k8guard-action)

For documentation please visit [K8Guard Website](https://k8guard.github.io/).
3 changes: 2 additions & 1 deletion db/actionqueries.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package db

import (
"fmt"
"github.com/k8guard/k8guard-action/db/stmts"
"time"

"github.com/k8guard/k8guard-action/db/stmts"

"github.com/gocql/gocql"

libs "github.com/k8guard/k8guardlibs"
Expand Down
9 changes: 4 additions & 5 deletions db/stmts/stmts.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,12 @@ const (
WITH CLUSTERING ORDER BY (created_at desc)
`

INSERT_TO_VLOG = `INSERT INTO %s.vlog_namespace_type (namespace, cluster, type, source, vType, vSource, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)`
INSERT_TO_VLOG = `INSERT INTO %s.vlog_namespace_type (namespace, cluster, type, source, vType, vSource, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)`

INSERT_TO_ALOG_NAMESPACE_TYPE = `INSERT INTO %s.alog_namespace_type (namespace, cluster, type, source, vType, vSource, action, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
INSERT_TO_ALOG_TYPE = `INSERT INTO %s.alog_type (namespace, cluster, type, source, vType, vSource, action, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
INSERT_TO_ALOG_VTYPE = `INSERT INTO %s.alog_vType (namespace, cluster, type, source, vType, vSource, action, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
INSERT_TO_ALOG_ACTION = `INSERT INTO %s.alog_action (namespace, cluster, type, source, vType, vSource, action, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`

INSERT_TO_ALOG_TYPE = `INSERT INTO %s.alog_type (namespace, cluster, type, source, vType, vSource, action, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
INSERT_TO_ALOG_VTYPE = `INSERT INTO %s.alog_vType (namespace, cluster, type, source, vType, vSource, action, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
INSERT_TO_ALOG_ACTION = `INSERT INTO %s.alog_action (namespace, cluster, type, source, vType, vSource, action, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`

INSERT_TO_VACTION = `INSERT INTO %s.vaction (namespace, cluster, type, source, vType, vSource, actions, created_at ,expire_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`

Expand Down
6 changes: 3 additions & 3 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

printf "\n--- pre-commit formatting ---\n\n"
go vet 2>&1
if [ $? -ne 0 ]
then
Expand All @@ -9,7 +9,7 @@ then
exit 1
fi

gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$')
gofiles=$(git diff --name-only --diff-filter=ACM | grep '\.go$')
[ -z "$gofiles" ] && exit 0

printf "Formatting the following Go files:\n"
Expand All @@ -19,6 +19,6 @@ for file in $gofiles; do
git add $PWD/$file
done

printf "\n------------------------\n\n"
printf "\n--- Done ! ---\n\n"

exit 0
3 changes: 2 additions & 1 deletion messaging/consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
"github.com/k8guard/k8guardlibs/messaging/kafka"

"encoding/json"
"github.com/k8guard/k8guard-action/actions"
"reflect"

"github.com/k8guard/k8guard-action/actions"

"github.com/k8guard/k8guard-action/db"

"github.com/k8guard/k8guardlibs/violations"
Expand Down

0 comments on commit 8599d25

Please sign in to comment.