Skip to content

Commit

Permalink
More inspection
Browse files Browse the repository at this point in the history
Signed-off-by: Kimmo Lehto <[email protected]>
  • Loading branch information
kke committed Jan 18, 2022
1 parent 05bb9ea commit 6ee5732
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions inttest/k0sctl/k0sctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (s *K0sctlSuite) k0sctlInitConfig() (*dig.Mapping, error) {
args := []string{"init", "--controller-count", fmt.Sprintf("%d", s.ControllerCount)}
args = append(args, addresses...)
out, err := exec.Command("./k0sctl", args...).Output()
s.T().Logf("k0sctl init output:\n%s", string(out))

cfg := &dig.Mapping{}
err = yaml.Unmarshal(out, cfg)
Expand All @@ -146,15 +147,21 @@ func (s *K0sctlSuite) TestK0sGetsUp() {
s.NoError(s.DownloadK0sctl())
cfg, err := s.k0sctlInitConfig()

hosts, ok := cfg.Dig("spec", "hosts").([]*dig.Mapping)
spec := cfg.DigMapping("spec")
hosts, ok := spec["hosts"].([]interface{})
if !ok {
s.T().Logf("k0sctl config inspection:\n%+v", cfg)
s.Fail("could not find spec.hosts in generated k0sctl.yaml")
}

for _, h := range hosts {
(*h)["uploadBinary"] = true
(*h)["k0sBinaryPath"] = os.Getenv("K0S_PATH")
host, ok := h.(map[string]interface{})
if !ok {
s.Failf("k0sctl config", "is not what was expected: %+v", host)
}

host["uploadBinary"] = true
host["k0sBinaryPath"] = os.Getenv("K0S_PATH")
}

s.NoError(err)
Expand Down

0 comments on commit 6ee5732

Please sign in to comment.