Skip to content

Commit

Permalink
more location fix in tests, add release script
Browse files Browse the repository at this point in the history
  • Loading branch information
mmta committed Nov 3, 2018
1 parent ceb42b3 commit 3203fb9
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 24 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/dsiem/asset/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"testing"

"github.com/dsiem/internal/pkg/shared/test"
"github.com/defenxor/dsiem/internal/pkg/shared/test"
)

func TestInit(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/pkg/dsiem/expcounter/counter_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package expcounter

import (
"dsiem/internal/pkg/dsiem/alarm"
"github.com/defenxor/dsiem/internal/pkg/dsiem/alarm"
"time"

// "dsiem/internal/pkg/dsiem/server"
"testing"

log "github.com/defenxor/dsiem/internal/pkg/shared/logger"
Expand Down
9 changes: 5 additions & 4 deletions internal/pkg/dsiem/xcorrelator/intel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package xcorrelator

import (
"context"
"dsiem/internal/pkg/shared/apm"
"dsiem/internal/pkg/shared/ip"
"dsiem/internal/pkg/shared/test"
"dsiem/pkg/intel"
"os"
"path"
"reflect"
"testing"

"github.com/defenxor/dsiem/internal/pkg/shared/apm"
"github.com/defenxor/dsiem/internal/pkg/shared/ip"
"github.com/defenxor/dsiem/internal/pkg/shared/test"
"github.com/defenxor/dsiem/pkg/intel"
)

type intelTests struct {
Expand Down
12 changes: 6 additions & 6 deletions internal/pkg/shared/fs/fs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package fs

import (
"errors"
"os"
"path"

"github.com/kardianos/osext"
)
Expand All @@ -15,15 +17,13 @@ func FileExist(path string) bool {
// GetDir returns the program root directory
func GetDir(devEnv bool) (string, error) {
dir, err := osext.ExecutableFolder()

if devEnv == true {
// check both docker internal location or dev local pc location
dir = "/go/src/dsiem"
if !FileExist(dir + "/configs") {
dir = "/home/mmta/go/src/dsiem"
g := os.Getenv("GOPATH")
if g == "" {
return "", errors.New("cannot find $GOPATH env variable")
}
dir = path.Join(g, "src", "github.com", "defenxor", "dsiem")
}

return dir, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/vuln/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Checker interface {
Initialize(config []byte) error
}

// Result defines
// Result defines the struct that must be returned by a vulnerability lookup plugin
type Result struct {
Provider string `json:"provider"`
Term string `json:"term"`
Expand Down
6 changes: 0 additions & 6 deletions scripts/generate_code.sh

This file was deleted.

9 changes: 5 additions & 4 deletions scripts/gobuild-cmd-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ now=$(date --utc --iso-8601=seconds)
echo "target OS: $goos;" commands to build: $cmd
curdir=$(pwd)
rdir=$curdir/temp/release/$ver
rm -rf $rdir && mkdir $rdir
mkdir -p $rdir
for os in $goos; do
echo "** building for $os **"
bdir=./temp/build/$os
Expand All @@ -25,14 +25,15 @@ for os in $goos; do
echo building $c ver=${ver} buildtime=${now} for $os ..
CGO_ENABLED=0 GOOS=$os GOARCH=amd64 go build -a -ldflags "-s -w -X main.version=${ver} -X main.buildTime=${now} -extldflags '-static'" -o $bdir/$n $c
done
mkdir -p $bdir/web/dist && cp -r ./web/dist/* $bdir/web/dist/
cp -r ./configs $bdir/
cd $bdir
if [ "$os" == "linux" ]; then
zip -9 $rdir/dsiem-server-$os-amd64.zip dsiem configs/*
zip -9 -r $rdir/dsiem-server-$os-amd64.zip dsiem configs web
fi
tools=$(ls | grep -v dsiem | grep -v configs)
tools=$(ls | grep -v dsiem | grep -v configs | grep -v web)
zip -9 $rdir/dsiem-tools-$os-amd64.zip $tools
cd $curdir
# rm -rf $bdir
rm -rf $bdir
done

24 changes: 24 additions & 0 deletions scripts/gorelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

export GITHUB_REPO="dsiem"
export GITHUB_USER="defenxor"

[ "$1" == "" ] && echo need semver version as 1st argument, and optional pre-release flag as 2nd argument. Example $0 v0.1.0 pre && exit 1
ver="$1"
[ "$2" == "pre" ] && pre="-p"

read -p "This will create a git tag and release for $1. Are you sure? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi

./scripts/gobuild-cmd-release.sh || (echo failed to build release files && exit 1)

git tag -a $ver
github-release release -t $ver $pre || (echo failed to create github release && exit 1)

for f in $(ls ./temp/release/$ver); do
github-release upload -t $ver -f ./temp/release/$ver/$f -n $f
done

0 comments on commit 3203fb9

Please sign in to comment.