File tree Expand file tree Collapse file tree 6 files changed +65
-2
lines changed Expand file tree Collapse file tree 6 files changed +65
-2
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010
1111const defaultShell = "/bin/bash"
1212
13+ // RunScript runs the script that has been fetched as requested
1314func (sm * ScriptManager ) RunScript (sn string ) error {
1415
1516 s := fmt .Sprintf ("%s/%s" , sm .WorkDir , sn )
Original file line number Diff line number Diff line change 11github.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 =
23github.com/davecgh/go-spew v1.1.1 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
34github.com/konsorten/go-windows-terminal-sequences v1.0.1 /go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ =
45github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s =
56github.com/konsorten/go-windows-terminal-sequences v1.0.2 /go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ =
67github.com/oracle/oci-go-sdk v5.4.0+incompatible h1:fM4QtmPTmmrzcyvBQP1/deOodn1/zJSszrQmHotAb3Q =
78github.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 =
810github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
911github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k =
1012github.com/sirupsen/logrus v1.4.1 /go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q =
1113github.com/stretchr/objx v0.1.0 /go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME =
1214github.com/stretchr/objx v0.1.1 /go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME =
15+ github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48 =
1316github.com/stretchr/objx v0.2.0 /go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE =
1417github.com/stretchr/testify v1.2.2 /go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs =
18+ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q =
1519github.com/stretchr/testify v1.3.0 /go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI =
1620golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8 =
1721golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 /go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY =
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ const (
1818 workShell = "/bin/bash"
1919)
2020
21+ // ScriptManager definition of the manager to handle the script management
2122type 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 }
Original file line number Diff line number Diff line change @@ -2,8 +2,10 @@ package main
22
33import "fmt"
44
5+ // ScriptType of what type of script it is
56type ScriptType int
67
8+ // Startup / Shutdown constant for that of a startup script
79const (
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
2528func 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
4549func (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
5257func (t ScriptType ) Shutdown () bool {
5358 if t == Shutdown {
5459 return true
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments