Commit 392cfb12 authored by Vladimir Zorin's avatar Vladimir Zorin

Add basic templating support for manifests

parent 44cce9a7
......@@ -162,7 +162,7 @@ metadata:
spec:
selector:
k8s-app: kube-dns
clusterIP: 10.43.0.10
clusterIP: %{CLUSTER_DNS}%
ports:
- name: dns
port: 53
......
package deploy
import (
"bytes"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"io/ioutil"
"os"
"path/filepath"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
func Stage(dataDir string) error {
func Stage(dataDir string, templateVars map[string]string) error {
os.MkdirAll(dataDir, 0700)
for _, name := range AssetNames() {
......@@ -17,7 +17,9 @@ func Stage(dataDir string) error {
if err != nil {
return err
}
for k, v := range templateVars {
content = bytes.Replace(content, []byte(k), []byte(v), -1)
}
p := filepath.Join(dataDir, name)
logrus.Info("Writing manifest: ", p)
if err := ioutil.WriteFile(p, content, 0600); err != nil {
......
......@@ -120,7 +120,8 @@ func startNorman(ctx context.Context, config *Config) (string, error) {
},
func(ctx context.Context) error {
dataDir := filepath.Join(controlConfig.DataDir, "manifests")
if err := deploy.Stage(dataDir); err != nil {
templateVars := map[string]string{"%{CLUSTER_DNS}%": controlConfig.ClusterDNS.String()}
if err := deploy.Stage(dataDir, templateVars); err != nil {
return err
}
if err := deploy.WatchFiles(ctx, controlConfig.Skips, dataDir); err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment