Skip to content

Commit

Permalink
Build cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
deedubs committed Jul 23, 2018
1 parent f80e1fa commit 49a9bc6
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.so
headstart
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
export CGO_ENABLED=1

export GOOS=linux
export GOARCH=amd64

all: headstart plugins

plugins: plugins/local.so plugins/aws.so

plugins/local.so:
cd providers/local && go build -buildmode=plugin -o local.so
CGO_ENABLED=1 go build -buildmode=plugin -o local.so providers/local/main.go

plugins/aws.so:
cd providers/aws && go build -buildmode=plugin -o aws.so
CGO_ENABLED=1 go build -buildmode=plugin -o aws.so providers/aws/main.go

headstart:
go build .
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/massiveco/headstart/handlers/users"
)

var localConfigPath = os.Getenv("HS_LOCAL_PATH")
var providerEnv = os.Getenv("HS_PROVIDER")
var providerPath = os.Getenv("HS_PROVIDER_PATH")

Expand All @@ -23,6 +24,10 @@ func init() {
if providerPath == "" {
providerPath = "/usr/lib/headstart/providers/"
}

if localConfigPath == "" {
localConfigPath = "/etc/headstart/config.yml"
}
}

func main() {
Expand All @@ -36,8 +41,8 @@ func main() {
log.Fatal(err)
}

provider := providerSym.(func() ([]byte, error))
configStr, err := provider()
provider := providerSym.(func(string) ([]byte, error))
configStr, err := provider(localConfigPath)
if err != nil {
log.Fatal(err)
}
Expand Down
Binary file removed providers/aws.so
Binary file not shown.
2 changes: 1 addition & 1 deletion providers/aws/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ func loadMetadata() ([]byte, error) {
}

// FetchConfig from this provider
func FetchConfig() ([]byte, error) {
func FetchConfig(_ string) ([]byte, error) {
return loadMetadata()
}
Binary file removed providers/local.so
Binary file not shown.
5 changes: 0 additions & 5 deletions providers/local/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ func main() {}

// FetchConfig from this provider
func FetchConfig(filename string) ([]byte, error) {

if filename == "" {
filename = "/etc/headstart/config.yml"
}

userData, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
Expand Down

0 comments on commit 49a9bc6

Please sign in to comment.