Commit Graph

75 Commits

Author SHA1 Message Date
Karl Isenberg
43868688d5 Use require for Error and NoError
Assert keeps going after failure, but require immediately fails
the tests, making it easier to find the output related to the test
failure, rather than having to comb through a bunch of subsequent
assertion failures. For equality tests, we may or may not want to
continue, but for error checks we almost always want to immediately
fail the test. Exceptions can be changed as-needed.
2024-03-20 13:19:18 -07:00
Natasha Sarkar
1957d5c746 support for more helm template args (#4926)
* support for more helm template args

* move templateArgs and unit tests to api/types

* undo package name change

* use our own simple helm chart instead of forking one

* add argument to AsHelmArgs

* code review

* lint errors
2023-02-01 10:19:05 -08:00
Katrina Verey
f6b72077c8 Stop using deprecated ioutil functions 2022-08-10 18:22:46 -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
Mohd Bilal
e25db3df2e Test case updated 2022-02-27 09:11:00 +00:00
Natasha Sarkar
67a5f6d68f support krm spec v1 and legacy path, index, and id annotations 2021-09-17 17:10:10 -07:00
Natasha Sarkar
5427ab7cc3 Merge pull request #4013 from KnVerey/go-yaml-fork
Internal go-yaml/yaml fork
2021-06-30 10:41:27 -07:00
Natasha Sarkar
3ab0665c19 fix affected kyaml tests 2021-06-30 10:14:45 -07:00
Phani Teja Marupaka
1aa7a1e709 Handle null values while formatting 2021-06-27 16:55:16 -07:00
Morten Torkildsen
2e0556b544 Allow the Handle function of the ResourceHandler interface to return an error 2021-06-13 15:06:08 -07:00
Morten Torkildsen
95e242353b Allow users to customize handling of deleted resources for merge3 2021-06-11 11:37:24 -07:00
Mengqi Yu
294070b3ab address comments 2021-06-07 15:06:57 -07:00
Mattias Öhrn
3e506eae02 PR feedback - more tests and some cleanup 2021-06-04 11:06:22 +02:00
Mattias Öhrn
942f112ef5 Fix kyaml tests 2021-06-03 08:31:03 +02:00
Zhou Hao
839cc2467c cleanup tempfiles for fmtr_test
Signed-off-by: Zhou Hao <zhouhao@fujitsu.com>
2021-05-24 15:52:28 +08:00
Phani Teja Marupaka
914a82bfa4 Support multiple implementations for IsSameResource 2021-04-27 23:53:43 -07:00
JaredTan95
c71a4534a0 update kyaml api version. 2020-12-15 12:21:27 +08:00
Phillip Wittrock
5557e1ff3c Retain element ordering when merge resources 2020-11-12 08:54:16 -08:00
Phani Teja Marupaka
e9ff26bb1b Make recurse logic public 2020-10-19 12:26:15 -07:00
Donny Xia
74d0d7960e add option to choose prepend/append in merge 2020-10-02 09:56:59 -07:00
Jijie Wei
3183fcc926 simplify the test case 2020-06-25 10:01:15 -07:00
Jijie Wei
0af9ca1266 simplify the test case 2020-06-25 09:59:17 -07:00
Jijie Wei
f17b893dd2 fmt 2020-06-23 13:16:18 -07:00
Jijie Wei
e9bd11caaa add test for fmt on yaml file of a list 2020-06-22 22:32:08 -07:00
Phani Teja Marupaka
28307bc435 Simplify parsing 2020-06-19 17:21:13 -07:00
Phillip Wittrock
28c919912a Fix cmd/config windows issues 2020-05-21 16:53:24 -07:00
Morten Torkildsen
99b850555d Add annotation for opting out of formatting 2020-05-15 13:43:02 -07:00
Phillip Wittrock
594c48d19a Refactor container function runtime into its own package 2020-05-06 08:16:14 -07:00
Justin SB
028811eb97 Fix godocs on MergeFilter
It was copy-pasted from GrepFilter
2020-04-29 14:13:15 -04:00
Phillip Wittrock
6d9702561a Enable functions to defer failures
so multiple validators can be run sequentially without shortcircuiting the pipeline
2020-04-17 20:27:58 -07:00
Phillip Wittrock
8d22cbdcca Support writing results from container filter 2020-04-15 08:01:49 -07:00
Phillip Wittrock
4f926df7cf Fix path in runfn
- Calculate path relative to the functionConfig file
- Do not allow absolute paths or traversal to parent directories
2020-04-06 16:53:20 -07:00
Phani Teja Marupaka
a5a51ba76a Remove format filter for update 2020-04-03 15:24:10 -07:00
Prachi Pendse
109ffdaec5 Update parsing of StringToStorageMount to use SplitN 2020-04-02 12:12:27 -07:00
Prachi Pendse
b17ea88bf7 Update mount flag to match docker docs
- Also modify TODO in validator-kubeval example
2020-04-02 11:20:32 -07:00
Prachi Pendse
38973a80c3 Use mount flag to pass storage mounts to functions 2020-04-01 15:03:57 -07:00
Prachi Pendse
39fe903498 Support mounting volumes to containers 2020-03-31 01:08:54 -07:00
Phani Teja Marupaka
17503ae9d8 Rearrange comments for yaml/V3 bug fix 2020-03-30 10:51:47 -07:00
Phillip Wittrock
7164e55831 Allow functions to enable the starlark filter (off by default) 2020-03-25 13:29:20 -07:00
Phillip Wittrock
85e9779bd6 Refactor container functions 2020-03-24 20:50:08 -07:00
Phillip Wittrock
efdd812cc1 refactor function filters 2020-03-24 11:18:46 -07:00
Eddie Zaneski
6cdcb1f436 Support network in functions
Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>
2020-02-07 17:31:33 -07:00
Kubernetes Prow Robot
bf6982afa3 Merge pull request #2176 from phanimarupaka/OptInToFormatSchema
Opt in to use schema
2020-02-04 11:27:27 -08:00
Phani Teja Marupaka
79d591e2b0 Opt in to use schema 2020-02-04 10:50:17 -08:00
Phillip Wittrock
2d54981bcd optionally use filepath as part of merge key for merge3 2020-02-03 19:28:40 -08:00
Frank Farzan
7372a371b4 kyaml: Handle functions in top-level directory.
scope() method uses HasPrefix to detect whether a resource
is in a subdirectory of function directory. It doesn't handle
the case when the function is in top-level dir ('.').
2020-01-31 14:41:56 -08:00
Kubernetes Prow Robot
02dbc0da98 Merge pull request #2100 from pwittrock/master
runfns: sort ContainerFilters depth first
2020-01-14 14:06:36 -08:00
Phillip Wittrock
778f92ca0d runfns: sort ContainerFilters depth first
- run ContainerFilters most deeply nested in the hierarchy before others
- test refactoring
2020-01-14 13:43:31 -08:00
bzub
34f21f44a1 Handle functions dir for resource destination. 2020-01-14 13:03:56 -06:00
Phillip Wittrock
7bbcba5d23 Re-introduce global scope for cmd/config run as flag 2020-01-13 08:42:20 -08:00