K8s: Increment generation in generic strategy (#97946)
--------- Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
co-authored by
Ryan McKinley
parent
62c1735a61
commit
8b0cd9dbb9
@@ -216,6 +216,9 @@ func (c *K8sResourceClient) sanitizeObject(v *unstructured.Unstructured, replace
|
||||
meta, ok := copy["metadata"].(map[string]any)
|
||||
require.True(c.t, ok)
|
||||
|
||||
// remove generation
|
||||
delete(meta, "generation")
|
||||
|
||||
replaceMeta = append(replaceMeta, "creationTimestamp", "resourceVersion", "uid")
|
||||
for _, key := range replaceMeta {
|
||||
old, ok := meta[key]
|
||||
@@ -403,12 +406,18 @@ func DoRequest[T any](c *K8sTestHelper, params RequestParams, result *T) K8sResp
|
||||
// Read local JSON or YAML file into a resource
|
||||
func (c *K8sTestHelper) LoadYAMLOrJSONFile(fpath string) *unstructured.Unstructured {
|
||||
c.t.Helper()
|
||||
return c.LoadYAMLOrJSON(string(c.LoadFile(fpath)))
|
||||
}
|
||||
|
||||
// Read local file into a byte slice. Does not need to be a resource.
|
||||
func (c *K8sTestHelper) LoadFile(fpath string) []byte {
|
||||
c.t.Helper()
|
||||
|
||||
//nolint:gosec
|
||||
raw, err := os.ReadFile(fpath)
|
||||
require.NoError(c.t, err)
|
||||
require.NotEmpty(c.t, raw)
|
||||
return c.LoadYAMLOrJSON(string(raw))
|
||||
return raw
|
||||
}
|
||||
|
||||
// Read local JSON or YAML file into a resource
|
||||
|
||||
Reference in New Issue
Block a user