Skip to content

Commit 4bdd84f

Browse files
authored
wercker build setup (#1)
setup building via wercker
1 parent 37e7bcf commit 4bdd84f

File tree

6 files changed

+65
-2
lines changed

6 files changed

+65
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![wercker status](https://app.wercker.com/status/56107a996689202ef859cc6a49d9fb5f/s/master "wercker status")](https://app.wercker.com/project/byKey/56107a996689202ef859cc6a49d9fb5f)
2+
13
### OCI Metadata Script Handler
24

35
#### Overview

executor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
const defaultShell = "/bin/bash"
1212

13+
// RunScript runs the script that has been fetched as requested
1314
func (sm *ScriptManager) RunScript(sn string) error {
1415

1516
s := fmt.Sprintf("%s/%s", sm.WorkDir, sn)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
23
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
34
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
45
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
56
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
67
github.com/oracle/oci-go-sdk v5.4.0+incompatible h1:fM4QtmPTmmrzcyvBQP1/deOodn1/zJSszrQmHotAb3Q=
78
github.com/oracle/oci-go-sdk v5.4.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
9+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
810
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
911
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
1012
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
1113
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1214
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
15+
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
1316
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
1417
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
18+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
1519
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
1620
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
1721
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const (
1818
workShell = "/bin/bash"
1919
)
2020

21+
// ScriptManager definition of the manager to handle the script management
2122
type ScriptManager struct {
2223
Type ScriptType
2324
WorkDir string
@@ -39,7 +40,7 @@ func main() {
3940
st, err := ParseScriptType(scriptType)
4041
if err != nil {
4142
log.Error("No valid argument specified for script type")
42-
log.Error("%s : %s", err, scriptType)
43+
log.Errorf("%s : %s", err, scriptType)
4344
os.Exit(1)
4445
}
4546

@@ -53,7 +54,7 @@ func main() {
5354

5455
defer func() {
5556
if !debug {
56-
os.RemoveAll(wd)
57+
_ = os.RemoveAll(wd)
5758
} else {
5859
log.Debug("not removing work dir : ", wd)
5960
}

types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package main
22

33
import "fmt"
44

5+
// ScriptType of what type of script it is
56
type ScriptType int
67

8+
// Startup / Shutdown constant for that of a startup script
79
const (
810
Startup ScriptType = iota + 1
911
Shutdown
@@ -22,6 +24,7 @@ func (t ScriptType) String() string {
2224
return types[t-1]
2325
}
2426

27+
// ParseScriptType will take the type of script string and map to the ScriptType constant
2528
func ParseScriptType(s string) (ScriptType, error) {
2629
var ret ScriptType
2730
switch s {
@@ -42,13 +45,15 @@ func ParseScriptType(s string) (ScriptType, error) {
4245

4346
}
4447

48+
// Startup will return true if it's time for a startup script
4549
func (t ScriptType) Startup() bool {
4650
if t == Startup {
4751
return true
4852
}
4953
return false
5054
}
5155

56+
// Shutdown will return true if it's shutdown script time
5257
func (t ScriptType) Shutdown() bool {
5358
if t == Shutdown {
5459
return true

wercker.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
box: golang:1.12
2+
build:
3+
steps:
4+
- wercker/golint@1.4.1:
5+
exclude: vendor
6+
- script:
7+
name: go test
8+
code: |
9+
go test -mod vendor ./...
10+
- script:
11+
name: go build
12+
code: |
13+
go build -mod vendor -o oci-metadata-scripts .
14+
package:
15+
box: nshttpd/fpm-packager:0a62ec4
16+
steps:
17+
- script:
18+
name: make directories
19+
code: |
20+
mkdir -p pkg/usr/bin
21+
mkdir -p pkg/etc/systemd/system
22+
mkdir -p pkg/var/lib/oci/scripts
23+
mkdir -p pkg/build
24+
- script:
25+
name: copy files
26+
code: |
27+
cp oci-metadata-scripts pkg/usr/bin/
28+
cp misc/*.service pkg/etc/systemd/system/
29+
cp misc/postinst.sh pkg/var/lib/oci/scripts/
30+
chmod 744 pkg/var/lib/oci/scripts/postinst.sh
31+
- script:
32+
name: fpm rpm builder
33+
code: |
34+
export VERSION=`cat VERSION`
35+
fpm -s dir -t rpm -v ${VERSION} -n oci-metadata-scripts -p pkg/build \
36+
-C pkg --replaces oci-metadata-scripts --after-install pkg/var/lib/oci/scripts/postinst.sh var/ usr/ etc/
37+
fpm -s dir -t deb -v ${VERSION} -n oci-metadata-scripts -p pkg/build \
38+
-C pkg --replaces oci-metadata-scripts --after-install pkg/var/lib/oci/scripts/postinst.sh var/ usr/ etc/
39+
deploy:
40+
steps:
41+
- script:
42+
name: set version
43+
code: |
44+
export VERSION=`cat VERSION`
45+
- tcnksm/ghr@0.2.0:
46+
name: run ghr
47+
token: $GITHUB_TOKEN
48+
input: pkg/build
49+
version: $VERSION
50+
replace: true

0 commit comments

Comments
 (0)