Commit Graph

41 Commits

Author SHA1 Message Date
Katrina Verey
f6b72077c8 Stop using deprecated ioutil functions 2022-08-10 18:22:46 -04:00
Anna Song
d1102fb726 Move demandDirectoryRoot into kyaml/filesys (#4677)
* Move demandDirectoryRoot into kyaml/filesys

* Make root directory platform-agnostic

Support windows root directory. Dogfood own error package.

* Use cleaner windows support implementation

* Address feedback

* Address feedback x2

* Re-apply go.sum changes to avoid CI errors
2022-06-30 11:12:07 -07:00
Anna Song
b0b6c962dc Replace lengthy t.Fatalf with require 2022-06-01 17:46:30 -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
0fa010c7e7 Add missing boilerplate 2022-04-04 14:24:04 -04: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
Mohd Bilal
3ec7b10bc0 Error message corrected 2022-02-27 07:48:55 +00:00
Sylvain Rabot
2f17803c0a Fix pseudo git HTTP urls broken since 59c82659 (#4453)
* Fix pseudo git HTTP urls broken since 59c82659

Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>

* Add test for Git resources using HTTP URLs

Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2022-02-09 14:23:49 -08:00
Sylvain Rabot
738573b079 Error on HTTP resources are not nescessarly protocol related
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2021-12-10 09:27:37 +01:00
Sylvain Rabot
49b464fd4d Handle HTTP error codes in file loader
GitHub release files like https://github.com/fluxcd/helm-controller/releases/download/v0.14.0/helm-controller.crds.yaml
seems to be hosted on Azure and it seems that there are egress limits that can be reached, e.g.:

```xml
<?xml version="1.0" encoding="utf-8"?><Error><Code>ServerBusy</Code><Message>Egress is over the account limit.
RequestId:f4a46b38-001e-0046-2437-ec16e2000000
Time:2021-12-08T13:28:03.8542138Z</Message></Error>
```

This patch allows to have a clear Error message instead of just `missing Resource metadata`:

```
Error: accumulating resources: accumulation err='accumulating resources from 'https://github.com/fluxcd/source-controller/releases/download/v0.19.0/source-controller.crds.yaml': URL returned error 503 (Service Unavailable)': evalsymlink failure on '/private/var/folders/hq/ttl6jyh539q55fz6282w0jyc0000gn/T/kustomize-3508224975/releases/download/v0.19.0/source-controller.crds.yaml' : lstat /private/var/folders/hq/ttl6jyh539q55fz6282w0jyc0000gn/T/kustomize-3508224975/releases: no such file or directory
```

Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2021-12-08 14:31:35 +01:00
Francesc Campoy
7fae7d1bd6 Move api/filesys to kyaml/filesys (#3997)
* Move api/filesys to kyaml/filesys

* Add deprecated version of api/filesys with aliases to new code

* Use new kyaml/filesys package and update dependencies

* Migrate to kyaml/filesys and update dependencies

* Skip tests that break on Windows
2021-06-16 11:42:00 -07:00
monopole
3af1ae4159 Enhance test harness. 2021-04-11 18:14:30 -07:00
monopole
a815774e5e Drop the go-getter dependence. 2021-02-11 16:48:39 -08:00
jregan
99c9edfc3d Drop close in timed call. 2020-12-28 08:31:42 -08:00
jregan
6bbc829593 Add a loader test. 2020-12-09 17:17:21 -08:00
Jeff Regan
05eccab823 Update loader.go 2020-12-09 15:17:52 -08:00
Yujun Zhang
485cb3831e Upgrade go-getter
* Provide a detector for repositories hosted on GitLab.com
* Update github.com/ulikunitz/xz@v0.5.8 for CVE-2020-16845
2020-12-01 09:39:03 +08:00
Donny Xia
bae9986422 remove all temp dir 2020-09-03 12:03:12 -07:00
jregan
1d91401772 Simplify use of the Merginator. 2020-08-22 08:07:57 -07:00
Donny Xia
e5e4f33ac7 Fix go-getter 2020-05-26 17:42:31 -07:00
Yujun Zhang
04bec8ed2e Rename resourceGetter to remoteTargetGetter for readability 2020-03-24 10:19:49 +08:00
Kubernetes Prow Robot
51b29d7023 Support various target and resource with go-getter 2020-03-24 09:44:05 +08:00
Yujun Zhang
711bab85ae Revert "Merge pull request #2169 from yujunz/loader/go-getter"
This reverts commit 0b1ad031a9, reversing
changes made to 300dd108d5.
2020-03-07 18:58:46 +08:00
Kubernetes Prow Robot
0b1ad031a9 Merge pull request #2169 from yujunz/loader/go-getter
Replace git cloner with go getter to support various target
2020-03-06 15:45:34 -08:00
Yujun Zhang
735cefa456 Use a lite fork of go-getter 2020-03-04 20:04:39 +08:00
Yujun Zhang
a24bf6aece Use a tailored go-getter to get rid of transitive depenencies 2020-03-04 20:04:39 +08:00
Yujun Zhang
fae66446a8 Replace git cloner with go getter to support various target 2020-03-04 20:04:39 +08:00
Yujun Zhang
382425d974 Add unit test for http fileloader 2020-02-29 16:19:21 +08:00
Yujun Zhang
ff6250cdb4 Allow loading file from http 2020-02-29 16:19:21 +08:00
Jeffrey Regan
c722d4cd17 Make filesys walk work. 2019-11-27 11:33:10 -08:00
jregan
f3e735153f More tests, better errors. 2019-11-26 19:29:06 -08:00
jregan
0924269e76 Activate lint staticcheck. 2019-11-16 07:04:53 -08:00
Jeffrey Regan
6542af600d Remove 'git' package from exposed API. 2019-11-06 13:08:47 -08:00
jregan
077c7b2d20 Improve config package names and reduce API exposure. 2019-11-03 16:39:44 -08:00
Jeffrey Regan
4716cb026f Simplify building api. 2019-10-28 13:36:14 -07:00
Jeffrey Regan
46524d3b6a Introduce API module. 2019-10-21 13:30:31 -07:00
jregan
dee1c425da Drain the top level internal. 2019-10-20 15:51:04 -07:00
jregan
951d15bf17 Make api/plugins 2019-10-20 15:12:13 -07:00
jregan
f54d4a5837 Make git package private 2019-10-20 11:36:10 -07:00
jregan
3af5a8afea Make resource, resmap public. 2019-10-20 10:51:20 -07:00