-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: include Go primitive types into unstructured deepcopy
This code was written from JSON point of view, but when YAML is unmarshaled, we get more primitive Go types as values, so why not include all of them? This was showing as an error when applying a machine config e.g. for kubelet extraArgs like: ``` shutdownGracePeriod: 0 ``` Changing this to string fixes the problem, but it's not the best UX. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
pkg/machinery/config/types/v1alpha1/v1alpha1_unstructured_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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/. | ||
|
||
package v1alpha1_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1" | ||
) | ||
|
||
func TestUnstructuredDeepCopy(t *testing.T) { | ||
u := v1alpha1.Unstructured{ | ||
Object: map[string]interface{}{ | ||
"strings": map[string]interface{}{ | ||
"foo": "bar", | ||
}, | ||
"numbers": []interface{}{ | ||
map[string]interface{}{ | ||
"int": 32, | ||
"int8": int8(34), | ||
"byte": byte(35), | ||
"int16": int16(36), | ||
"int32": int32(37), | ||
"int64": int64(38), | ||
"uint": uint(39), | ||
"uint8": uint8(40), | ||
"uint16": uint16(41), | ||
"uint32": uint32(42), | ||
"uint64": uint64(43), | ||
}, | ||
float32(44.0), | ||
float64(45.0), | ||
complex64(complex(46.0, 47.0)), | ||
complex128(complex(48.0, 49.0)), | ||
}, | ||
"bytes": []byte("abc"), | ||
}, | ||
} | ||
|
||
assert.Equal(t, u.DeepCopy(), &u) | ||
} |