Commit Graph

57 Commits

Author SHA1 Message Date
Katrina Verey
79a9154cf8 Improve error message when namespace transformer is given invalid fieldspecs
Also remove invalid+ignored fieldspecs from the defaults
2022-08-16 18:18:44 -04:00
Katrina Verey
55a37de686 Fix other linters on modified lines 2022-08-10 19:34:25 -04:00
Katrina Verey
f6b72077c8 Stop using deprecated ioutil functions 2022-08-10 18:22:46 -04:00
yugo kobayashi
6fb96b7d53 update go 1.18 2022-07-07 20:11:29 +00:00
Katrina Verey
7a773a3a48 Configure wrapcheck linter to recognize wrapping done by kyaml's errors package 2022-05-09 17:02:02 -04:00
Katrina Verey
2e230b4d4b Regression test and fix for APIs that satisfy ValidationSchemaProvider but not Validator 2022-04-22 17:19:49 -04:00
Katrina Verey
bcae65770a Configurable extensions for template parser 2022-04-21 18:28:13 -04:00
Eng Zer Jun
9452a031ba test: use T.TempDir to create temporary test directory (#4587)
* test: use `T.TempDir` to create temporary test directory

This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix `TestInit_noargs` on Windows

--- FAIL: TestInit_noargs (0.01s)
    testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestInit_noargs3136084632\001: The process cannot access the file because it is being used by another process.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix `TestTreeCommandDefaultCurDir_files` on Windows

--- FAIL: TestTreeCommandDefaultCurDir_files (0.01s)
    testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestTreeCommandDefaultCurDir_files716679291\001: The process cannot access the file because it is being used by another process.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix `TestCreateSetterCommand` on Windows

--- FAIL: TestCreateSetterCommand (13.27s)
    --- FAIL: TestCreateSetterCommand/add_replicas (1.45s)
        testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestCreateSetterCommandadd_replicas176222064\001\k8s-cli-487197005.yaml: The process cannot access the file because it is being used by another process.
    ...
    and all subtests
    ...

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix `TestCreateSubstitutionCommand` on Windows

--- FAIL: TestCreateSubstitutionCommand (4.16s)
    --- FAIL: TestCreateSubstitutionCommand/substitution_replicas (1.30s)
        testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestCreateSubstitutionCommandsubstitution_replicas1352417113\001\k8s-cli-3183612276.yaml: The process cannot access the file because it is being used by another process.
    ...
    and all subtests
    ...

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix `TestDeleteSetterCommand` on Windows

--- FAIL: TestDeleteSetterCommand (4.36s)
    --- FAIL: TestDeleteSetterCommand/delete_replicas (1.31s)
        testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestDeleteSetterCommanddelete_replicas3949811929\001\k8s-cli-957077271.yaml: The process cannot access the file because it is being used by another process.
    ...
    and all subtests
    ...

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix `TestDeleteSubstitutionCommand` on Windows

--- FAIL: TestDeleteSubstitutionCommand (2.35s)
    --- FAIL: TestDeleteSubstitutionCommand/delete_only_subst_if_setter_has_same_name_-_long_ref (1.15s)
        testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestDeleteSubstitutionCommanddelete_only_subst_if_setter_has_same_name_-_long_ref2039728641\001\k8s-cli-1602861478.yaml: The process cannot access the file because it is being used by another process.
    ...
    and all subtests
    ...

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix `TestSetCommand` on Windows

--- FAIL: TestSetCommand (13.76s)
    --- FAIL: TestSetCommand/set_replicas (1.13s)
        testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestSetCommandset_replicas3781384539\001\k8s-cli-1030344459.yaml: The process cannot access the file because it is being used by another process.
    ...
    and all subtests
    ...

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-04-18 09:32:41 -07:00
Katrina Verey
71bf0d5d14 Update full linter list and enable some easily resolved new ones 2022-03-31 11:37:26 -04:00
Katrina Verey
14947e449b Address new linter complaints 2022-03-31 11:37:26 -04:00
Shoshana Malfatto
7b0ec99d90 retain quotes in namespace transformer filter (#4421)
* check tag values for double quoting

* reuse setentry

* don't override single quotes in merge and fix cm generator immutable val

* get rid of comment

* starlark annotation tests

* don't commit test image changes

* set network to bool

* isSet bool

* updating e2e config tool

* leave createtag

* fn command failing unmarshal test

* fn command test

* don't set style in run-fs

* use setentry to set tag

* remove e2e test changes and make IsStringValue an RNode method
2022-03-23 14:25:19 -07:00
Katrina Verey
c90504a19d Enable validation using function config schema from KRMFunctionDefinition 2022-02-24 13:20:29 -05:00
Sam Dowell
9d29f57789 feat: Add Sort method to kyaml fn Results
Issues: GoogleContainerTools/kpt#2195
2021-12-01 20:57:48 +00:00
Natasha Sarkar
01420768c8 Merge pull request #4241 from Goodwine/kyaml-result-provider
Handle "Result" errors as non-fatal errors in kyaml FilterFuncs
2021-11-22 11:07:18 -08:00
Mengqi Yu
2ee2d3e389 use custom id as key of the mapping and make kio.Pipeline behave the same as framework.Execute 2021-11-19 07:30:31 -08:00
Mengqi Yu
81edfb7ee8 default result.severity to info when formatting string 2021-11-19 07:30:31 -08:00
Mengqi Yu
4e7aebc20c address comments 2021-11-18 14:58:04 -08:00
Mengqi Yu
5caed5b90a kyaml/fn/framework ensures the annotation output format matches the input
If the input only contains legacy format anntations (path, index, id), the
output will be the same.
2021-11-17 14:09:19 -08:00
Goodwine
4cde50ab14 fix typo
Co-authored-by: Katrina Verey <kn.verey@gmail.com>
2021-11-11 16:33:17 -08:00
Carlos Ortiz García
894ffec36a Handle kyaml Filter errors type Result as non-breaking errors and store in ResourceList
- Result can only count as error when passed as pointer, this makes easy use of "errors.As"
- Existing Filter() implementations that return Result from the `framework` package won't return an error anymore but modify the ResourceList
2021-11-11 15:26:07 -08:00
Mengqi Yu
374d790a21 Make ResourceList follow k8s api conventions
Make optional fields as pointers.
Add omitempty for optional fields.
2021-11-08 21:35:49 -08:00
natasha41575
3ea8b79925 update results field of ResourceList to implement function spec v1 2021-10-29 14:28:50 -07:00
natasha41575
c3c02887ec bump ResourceList from v1alpha1 to v1 2021-10-19 16:15:27 -07:00
Mengqi Yu
6cf06fac12 update the dockerfile gen command 2021-09-29 13:34:11 -07:00
Natasha Sarkar
67a5f6d68f support krm spec v1 and legacy path, index, and id annotations 2021-09-17 17:10:10 -07:00
Katrina Verey
f0b4cc4581 ContainerPatch supports all common workload paths 2021-08-17 11:13:52 -07:00
Katrina Verey
c5adafd9ce Make UpdateExpectedFromActual work with hierarchical testdata directories 2021-07-20 18:13:04 -07:00
Natasha Sarkar
0205090e0d remove metadata field from resourceRef schema 2021-06-03 12:46:51 -07:00
Jeff Regan
da1bd901b4 Merge pull request #3939 from KnVerey/framework_test_helpers
[kyaml] Improvements to frameworktestutil
2021-06-03 11:14:54 -07:00
Mengqi Yu
f061bb887b Check for empty GKNN when formatting results 2021-06-02 16:32:18 -07:00
Katrina Verey
382f09a126 Make frameworktestutil assertions configurable
Also refactor to share common code between results checkers
2021-06-01 12:20:23 -07:00
Katrina Verey
f9afdc5c95 Improve frameworktestutil usability with complex error messages 2021-06-01 12:20:17 -07:00
Katrina Verey
76f8988865 Mark updated tests as skipped instead of passed 2021-05-31 10:56:32 -07:00
Katrina Verey
3f3d3b17a4 Replace pkger with embed.FS compatibility 2021-05-18 12:07:42 -07:00
Katrina Verey
53c87a32e9 Reset openapi in Filter and show use of pkger with filepath 2021-05-18 11:20:42 -07:00
Katrina Verey
0fdf0f825f TemplateProcessor can add custom resource schemas to openapi 2021-05-18 11:20:42 -07:00
Jeremy
9989b5fc84 Add check of UpdateExpectedFromActual before skipping test
Signed-off-by: Jeremy <jeremyrrickard@gmail.com>
2021-04-12 13:12:53 -06:00
Katrina Verey
5c4b5b1bf0 Improvements to kyaml fn framework
This commit creates a new version of the alpha configuration functions framework. Goals include:
- Make it easy to build multi-version APIs with the framework (not previously facilitated at all).
- Simplify the framework's APIs where redundant configuration options exist (leaving the most powerful, replacing others with helpers to maintain usability they provided).
- Make the Framework's APIs more consistent (e.g. between the various template types, usage of kio.Filter, field names)
- Decouple responsibilities (e.g. command creation, resource list processing, generation of templating functions).
- Make the framework even more powerfully pluggable (e.g. any kio.Filter can be a selector, and the selector the framework provides is itself a filter built from reusable abstractions).
- Improve documentation.
- Make container patches merge fields (notably list fields like `env`) correctly.
2021-03-03 08:27:19 -08:00
monopole
2e6ef91a7c Update generated files under kyaml.
sed -i 's|version: v0.17.0|version: v0.19.8|' kyaml/yaml/internal/k8sgen/k8scopy.yaml
rm kyaml/yaml/internal/k8sgen/pkg/labels/zz_generated.deepcopy.go
(cd kyaml; make generate)
2021-02-28 10:10:52 -08:00
Phillip Wittrock
f7d13ade35 fn framework support for legacy kustomize plugin io 2021-02-17 09:19:02 -08:00
Phillip Wittrock
2db4121c6a Support fnframework to write expected testdata based on observed results 2021-02-11 09:48:50 -08:00
monopole
bbccee0219 Fix message in generated code. 2021-02-09 07:34:32 -08:00
Katrina Verey
4f184e8ce3 Add validation hook to template command execution 2021-01-20 15:53:46 -08:00
Katrina Verey
2e0d6d42bf Improve framework usability without cobra 2021-01-20 15:53:10 -08:00
Phillip Wittrock
736f110f04 Fn framework template and process options
- Refactor framework code to be simpler
- Add TemplatesFn feature
- Add PreProcessFilters feature
- Add PostProcessFilters features
- Add TemplatesFromDir
- Add PatchTemplatesFromDir
- Add PatchContainerTemplatesFromDir
2020-11-30 08:23:34 -08:00
Phillip Wittrock
f2706dce68 Improved fn framework support for patching
- Generate patches with a func
- Generate patches for containers
2020-11-24 12:02:55 -08:00
Phillip Wittrock
82b2d83ede fn/framework support for reading from stdin in standalone
- speficy '-' to read from stdin when running standalone
2020-11-21 09:17:26 -08:00
Phillip Wittrock
be5db09db1 Function framework support for patching containers 2020-11-19 10:01:12 -08:00
Phillip Wittrock
8c4841c28f Support for framework.Selector substitutions 2020-11-17 08:52:34 -08:00
Phillip Wittrock
02e7589323 Function framework testutil support for functions which refer to local files
Some functions may read local files using relative paths.  Update the test
framework to `cd` into the directory containing the config.yaml before
running the function.
2020-11-16 16:35:07 -08:00