diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84145f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.so +headstart \ No newline at end of file diff --git a/Makefile b/Makefile index fd38042..49e2894 100644 --- a/Makefile +++ b/Makefile @@ -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 . \ No newline at end of file diff --git a/main.go b/main.go index 3339441..b6d3747 100644 --- a/main.go +++ b/main.go @@ -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") @@ -23,6 +24,10 @@ func init() { if providerPath == "" { providerPath = "/usr/lib/headstart/providers/" } + + if localConfigPath == "" { + localConfigPath = "/etc/headstart/config.yml" + } } func main() { @@ -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) } diff --git a/providers/aws.so b/providers/aws.so deleted file mode 100644 index 42c42c7..0000000 Binary files a/providers/aws.so and /dev/null differ diff --git a/providers/aws/main.go b/providers/aws/main.go index 428341d..e06ea77 100644 --- a/providers/aws/main.go +++ b/providers/aws/main.go @@ -32,6 +32,6 @@ func loadMetadata() ([]byte, error) { } // FetchConfig from this provider -func FetchConfig() ([]byte, error) { +func FetchConfig(_ string) ([]byte, error) { return loadMetadata() } diff --git a/providers/local.so b/providers/local.so deleted file mode 100644 index 317b12b..0000000 Binary files a/providers/local.so and /dev/null differ diff --git a/providers/local/main.go b/providers/local/main.go index 1adba68..1d25274 100644 --- a/providers/local/main.go +++ b/providers/local/main.go @@ -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