mirror of
https://github.com/rancher/os.git
synced 2025-09-17 07:30:42 +00:00
generate os-config.yml
This commit is contained in:
56
cmd/control/config_test.go
Normal file
56
cmd/control/config_test.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"os"
|
||||
)
|
||||
|
||||
func TestGenTpl(t *testing.T) {
|
||||
assert := require.New(t)
|
||||
tpl := `
|
||||
services:
|
||||
{{if eq "amd64" .ARCH -}}
|
||||
acpid:
|
||||
image: rancher/os-acpid:0.x.x
|
||||
labels:
|
||||
io.rancher.os.scope: system
|
||||
net: host
|
||||
uts: host
|
||||
privileged: true
|
||||
volumes_from:
|
||||
- command-volumes
|
||||
- system-volumes
|
||||
{{end -}}
|
||||
all-volumes:`
|
||||
|
||||
for _, tc := range []struct {
|
||||
arch string
|
||||
expected string
|
||||
}{
|
||||
{"amd64", `
|
||||
services:
|
||||
acpid:
|
||||
image: rancher/os-acpid:0.x.x
|
||||
labels:
|
||||
io.rancher.os.scope: system
|
||||
net: host
|
||||
uts: host
|
||||
privileged: true
|
||||
volumes_from:
|
||||
- command-volumes
|
||||
- system-volumes
|
||||
all-volumes:`},
|
||||
{"arm", `
|
||||
services:
|
||||
all-volumes:`},
|
||||
} {
|
||||
out := &bytes.Buffer{}
|
||||
os.Setenv("ARCH", tc.arch)
|
||||
genTpl(strings.NewReader(tpl), out)
|
||||
assert.Equal(tc.expected, out.String(), tc.arch)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user