Skip to content

Commit

Permalink
fix: treat literal 'unknown' as a valid machine type
Browse files Browse the repository at this point in the history
We use `unknown` in the machine state file for PXE booted VMs in the
provisioning library.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Oct 20, 2021
1 parent c8e404e commit e77d81f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/machinery/config/types/v1alpha1/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func ParseType(s string) (Type, error) {
return TypeControlPlane, nil
case "worker", "join", "":
return TypeWorker, nil
case "unknown":
return TypeUnknown, nil
default:
return TypeUnknown, fmt.Errorf("invalid machine type: %q", s)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestParseType(t *testing.T) {
{"worker", machine.TypeWorker},
{"join", machine.TypeWorker},
{"", machine.TypeWorker},
{"unknown", machine.TypeUnknown},
}

for _, tt := range validTests {
Expand All @@ -56,7 +57,6 @@ func TestParseType(t *testing.T) {

for _, s := range []string{
"foo",
machine.TypeUnknown.String(),
} {
s := s
t.Run(s, func(t *testing.T) {
Expand Down

0 comments on commit e77d81f

Please sign in to comment.