mirror of
https://github.com/lingble/talos.git
synced 2025-11-03 05:57:53 +00:00
Fixes #2330 CLI tests require node discovery as `--nodes` flag is enforced for most of the `talosctl commands`. For clusters created via `talosctl cluster create`, cluster provisioner state provides all the necessary information, but clusters created via CAPI don't have the state attached. API tests rely on Talos and Kubernetes APIs to fetch kubeconfig and access Nodes K8s API. CLI tests should rely only on CLI tools, so we use `kubectl get nodes` + `talosctl kubeconfig` to fetch list of master and worker nodes. This discovery method relies on "bootstrap" node being set in `talosconfig` (to fetch `kubeconfig`). Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
32 lines
794 B
Go
32 lines
794 B
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
// +build integration
|
|
|
|
package base
|
|
|
|
import "github.com/talos-systems/talos/internal/app/machined/pkg/runtime"
|
|
|
|
type infoWrapper struct {
|
|
masterNodes []string
|
|
workerNodes []string
|
|
}
|
|
|
|
func (wrapper *infoWrapper) Nodes() []string {
|
|
return append(wrapper.masterNodes, wrapper.workerNodes...)
|
|
}
|
|
|
|
func (wrapper *infoWrapper) NodesByType(t runtime.MachineType) []string {
|
|
switch t {
|
|
case runtime.MachineTypeInit:
|
|
return nil
|
|
case runtime.MachineTypeControlPlane:
|
|
return wrapper.masterNodes
|
|
case runtime.MachineTypeJoin:
|
|
return wrapper.workerNodes
|
|
default:
|
|
panic("unreachable")
|
|
}
|
|
}
|