forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload.go
30 lines (24 loc) · 749 Bytes
/
load.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
package staticpods
import (
"io/ioutil"
"path"
"path/filepath"
"strings"
"github.com/openshift/origin/pkg/oc/clusterup/manifests"
)
func substitute(in string, replacements map[string]string) string {
curr := in
for oldVal, newVal := range replacements {
curr = strings.Replace(curr, oldVal, newVal, -1)
}
return curr
}
func UpsertStaticPod(sourceLocation string, replacements map[string]string, kubeletStaticPodDir string) error {
data, err := manifests.Asset(sourceLocation)
if err != nil {
return err
}
content := substitute(string(data), replacements)
fullLockubeletStaticPodDir := path.Join(kubeletStaticPodDir, filepath.Base(sourceLocation))
return ioutil.WriteFile(fullLockubeletStaticPodDir, []byte(content), 0644)
}