Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
Merging with the packaging changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Prachi Damle authored and Prachi Damle committed Oct 15, 2015
2 parents ef786bd + 78ff824 commit 848f958
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin
dist
3 changes: 3 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
image: rancher/dind:v0.6.0
script:
- ./scripts/ci
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin
/dist
9 changes: 9 additions & 0 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.5
RUN go get github.com/tools/godep
RUN go get github.com/golang/lint/golint
ENV DAPPER_SOURCE /go/src/github.com/rancher/rancher-catalog-service
ENV DAPPER_OUTPUT bin dist
RUN apt-get update && apt-get install -y xz-utils
WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
CMD ["build"]
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ Design

* The UI integrated with the service will enable the user to view the templates in a catalog format and also launch a template to a specified rancher deployment.

Building
========

This project uses [dapper](https://github.com/ibuildthecloud/dapper). Install dapper first

go get github.com/ibuildthecloud/dapper

```sh
# Compile
dapper build

# Run tests
dapper test

# Run everything
dapper all
```

Contact
========
For bugs, questions, comments, corrections, suggestions, etc., open an issue in
Expand Down
16 changes: 12 additions & 4 deletions manager/catalog_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ package manager
import (
"flag"
"fmt"
log "github.com/Sirupsen/logrus"
"github.com/rancher/rancher-catalog-service/model"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"syscall"
"time"
"strconv"

"gopkg.in/yaml.v2"

log "github.com/Sirupsen/logrus"
"github.com/rancher/rancher-catalog-service/model"
)

var (
Expand Down Expand Up @@ -54,6 +57,11 @@ func SetEnv() {
log.Fatal(err)
fmt.Errorf(err)
}

// Shutdown when parent dies
if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_PDEATHSIG, uintptr(syscall.SIGTERM), 0); err != 0 {
log.Fatal("Failed to set parent death sinal, err")
}
}

func Init() {
Expand Down
7 changes: 7 additions & 0 deletions scripts/all
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

./scripts/build
./scripts/test
#./scripts/validate
./scripts/package
8 changes: 8 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

. ./scripts/common

mkdir -p $(dirname $BIN)
echo Building $BIN
godep go build -o $BIN $MAIN
10 changes: 10 additions & 0 deletions scripts/ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

cd $(dirname $0)/..
if [ ! -x "$(which dapper)" ] ;then
go get github.com/ibuildthecloud/dapper
PATH=$GOPATH/bin:${PATH}
fi
docker version >/dev/null 2>&1 || wrapdocker || docker version
dapper all
2 changes: 2 additions & 0 deletions scripts/common
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BIN=bin/rancher-catalog-service
MAIN=main.go
20 changes: 20 additions & 0 deletions scripts/dapperw
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

setpath()
{
if [ -x "build/dapper/bin/dapper" ]; then
PATH=${PATH}:$(pwd)/build/dapper/bin/dapper
fi
}

setpath

if [ ! -x "$(which dapper)" ]; then
(
GOPATH=$(pwd)/build/dapper
mkdir -p $GOPATH
go get github.com/ibuildthecloud/dapper
)
fi

exec dapper "$@"
8 changes: 8 additions & 0 deletions scripts/entry
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

if [ -e ./scripts/$1 ]; then
exec ./scripts/"$@"
fi

exec "$@"
7 changes: 7 additions & 0 deletions scripts/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

. ./scripts/common

mkdir -p dist/artifacts
tar cvJf dist/artifacts/$(basename $BIN).tar.xz -C $(dirname $BIN) .
3 changes: 3 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

godep go test ./...
36 changes: 36 additions & 0 deletions scripts/validate
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -e

fmt()
{
local files=$(gofmt -l . | grep -v 'Godeps')

if [ -n "$files" ]; then
echo Failed gofmt
echo $files
return 1
fi
}

lint()
{
for i in $(find -type d | grep -vE '(Godep|.git)'); do
golint $i
done
}

vet()
{
for i in $(find -type d | grep -vE '(Godep|.git|bin|dist|DATA|scripts)'); do
go vet $i
done
}

fmt || FAILED=1
lint || FAILED=1
vet || FAILED=1

if [ "$FAILED" = 1 ]; then
echo Checks failed
exit 1
fi

0 comments on commit 848f958

Please sign in to comment.