From eaa208fb6d20340472dac6a2739679cb86a985e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Tue, 3 Dec 2019 10:56:57 +0100 Subject: [PATCH] write files in system --- .gitignore | 1 + Dockerfile | 4 ++-- config.go | 7 ++++++- main.go | 9 +++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3aa6369 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.*.sw[po] diff --git a/Dockerfile b/Dockerfile index f4e1285..ad7ae76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # ------------------------------------------------------------------------ -from mcluseau/golang-builder:1.13.1 as build +from mcluseau/golang-builder:1.13.4 as build # ------------------------------------------------------------------------ -from alpine:3.10 +from alpine:3.10.3 env busybox_v=1.28.1-defconfig-multiarch \ arch=x86_64 diff --git a/config.go b/config.go index eca352f..b7e2c0c 100644 --- a/config.go +++ b/config.go @@ -1,5 +1,10 @@ package main +import ( + nconfig "novit.nc/direktil/pkg/config" +) + type config struct { - Layers []string `yaml:"layers"` + Layers []string `yaml:"layers"` + Files []nconfig.FileDef `yaml:"files"` } diff --git a/main.go b/main.go index 2d538c4..a9d67f5 100644 --- a/main.go +++ b/main.go @@ -127,6 +127,15 @@ func main() { fatal("failed: ", err) } + // - write files + for _, fileDef := range cfg.Files { + log.Print("writing ", fileDef.Path) + + filePath := filepath.Join("/system", fileDef.Path) + + ioutil.WriteFile(filePath, []byte(fileDef.Content), fileDef.Mode) + } + // clean zombies cleanZombies()