Files
k3s/pkg/deploy/stage.go
Morten Lied Johansen 9033891f88 Skip writing manifest when using --no-deploy
Instead of skipping the manifest when listing the directory, we now skip
creating it in the first place. This allows users to deploy manifests
that replaces the ones bundled, without having to come up with a new
name.

Fixes #230.
2019-03-23 22:22:58 +01:00

40 lines
785 B
Go

package deploy
import (
"bytes"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"io/ioutil"
"os"
"path/filepath"
)
func Stage(dataDir string, templateVars map[string]string, skipList []string) error {
os.MkdirAll(dataDir, 0700)
skips := map[string]bool{}
for _, skip := range skipList {
skips[skip] = true
}
for _, name := range AssetNames() {
if skips[name] {
continue
}
content, err := Asset(name)
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 {
return errors.Wrapf(err, "failed to write to %s", name)
}
}
return nil
}