Skip to content

wercker build setup #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![wercker status](https://app.wercker.com/status/56107a996689202ef859cc6a49d9fb5f/s/master "wercker status")](https://app.wercker.com/project/byKey/56107a996689202ef859cc6a49d9fb5f)

### OCI Metadata Script Handler

#### Overview
Expand Down
1 change: 1 addition & 0 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

const defaultShell = "/bin/bash"

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

s := fmt.Sprintf("%s/%s", sm.WorkDir, sn)
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/oracle/oci-go-sdk v5.4.0+incompatible h1:fM4QtmPTmmrzcyvBQP1/deOodn1/zJSszrQmHotAb3Q=
github.com/oracle/oci-go-sdk v5.4.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
workShell = "/bin/bash"
)

// ScriptManager definition of the manager to handle the script management
type ScriptManager struct {
Type ScriptType
WorkDir string
Expand All @@ -39,7 +40,7 @@ func main() {
st, err := ParseScriptType(scriptType)
if err != nil {
log.Error("No valid argument specified for script type")
log.Error("%s : %s", err, scriptType)
log.Errorf("%s : %s", err, scriptType)
os.Exit(1)
}

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

defer func() {
if !debug {
os.RemoveAll(wd)
_ = os.RemoveAll(wd)
} else {
log.Debug("not removing work dir : ", wd)
}
Expand Down
5 changes: 5 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package main

import "fmt"

// ScriptType of what type of script it is
type ScriptType int

// Startup / Shutdown constant for that of a startup script
const (
Startup ScriptType = iota + 1
Shutdown
Expand All @@ -22,6 +24,7 @@ func (t ScriptType) String() string {
return types[t-1]
}

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

}

// Startup will return true if it's time for a startup script
func (t ScriptType) Startup() bool {
if t == Startup {
return true
}
return false
}

// Shutdown will return true if it's shutdown script time
func (t ScriptType) Shutdown() bool {
if t == Shutdown {
return true
Expand Down
50 changes: 50 additions & 0 deletions wercker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
box: golang:1.12
build:
steps:
- wercker/golint@1.4.1:
exclude: vendor
- script:
name: go test
code: |
go test -mod vendor ./...
- script:
name: go build
code: |
go build -mod vendor -o oci-metadata-scripts .
package:
box: nshttpd/fpm-packager:0a62ec4
steps:
- script:
name: make directories
code: |
mkdir -p pkg/usr/bin
mkdir -p pkg/etc/systemd/system
mkdir -p pkg/var/lib/oci/scripts
mkdir -p pkg/build
- script:
name: copy files
code: |
cp oci-metadata-scripts pkg/usr/bin/
cp misc/*.service pkg/etc/systemd/system/
cp misc/postinst.sh pkg/var/lib/oci/scripts/
chmod 744 pkg/var/lib/oci/scripts/postinst.sh
- script:
name: fpm rpm builder
code: |
export VERSION=`cat VERSION`
fpm -s dir -t rpm -v ${VERSION} -n oci-metadata-scripts -p pkg/build \
-C pkg --replaces oci-metadata-scripts --after-install pkg/var/lib/oci/scripts/postinst.sh var/ usr/ etc/
fpm -s dir -t deb -v ${VERSION} -n oci-metadata-scripts -p pkg/build \
-C pkg --replaces oci-metadata-scripts --after-install pkg/var/lib/oci/scripts/postinst.sh var/ usr/ etc/
deploy:
steps:
- script:
name: set version
code: |
export VERSION=`cat VERSION`
- tcnksm/ghr@0.2.0:
name: run ghr
token: $GITHUB_TOKEN
input: pkg/build
version: $VERSION
replace: true