mirror of https://github.com/k3s-io/k3s
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
515 B
28 lines
515 B
6 years ago
|
package static
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
|
||
|
"github.com/pkg/errors"
|
||
|
"github.com/sirupsen/logrus"
|
||
|
)
|
||
|
|
||
|
func Stage(dataDir string) error {
|
||
|
for _, name := range AssetNames() {
|
||
|
content, err := Asset(name)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
p := filepath.Join(dataDir, name)
|
||
|
logrus.Info("Writing static file: ", p)
|
||
|
os.MkdirAll(filepath.Dir(p), 0700)
|
||
|
if err := ioutil.WriteFile(p, content, 0600); err != nil {
|
||
|
return errors.Wrapf(err, "failed to write to %s", name)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|