-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
36 lines (31 loc) · 767 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"os"
"strings"
"io/ioutil"
"fmt"
"sort"
)
func main() {
// This MUST remain in alphabetical order for contains to work
ignores := []string{ "GOLANG_VERSION", "GOPATH", "HOME", "HOSTNAME", "PATH",
"TERM", "no_proxy" }
for _, e := range os.Environ() {
pair := strings.SplitN(e, "=", 2)
if !contains(ignores, pair[0]) {
contents := []byte(pair[1]);
err := ioutil.WriteFile("/run/secrets/" + pair[0], contents, 0644)
check(err)
}
}
}
func contains(list []string, value string) bool {
i := sort.SearchStrings(list, value)
return i < len(list) && list[i] == value
}
func check(err error) {
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}