Skip to content

Commit ccf14e6

Browse files
committed
fix
Signed-off-by: Tomasz Janiszewski <[email protected]>
1 parent 89f4991 commit ccf14e6

File tree

5 files changed

+14
-32
lines changed

5 files changed

+14
-32
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ require (
6767
github.com/hashicorp/errwrap v1.1.0 // indirect
6868
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
6969
github.com/hashicorp/go-multierror v1.1.1 // indirect
70-
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
70+
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
7171
github.com/huandu/xstrings v1.5.0 // indirect
7272
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7373
github.com/josharian/intern v1.0.0 // indirect

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
156156
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
157157
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
158158
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
159+
github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3iS0jrZ7LvzFGFmuKbw=
159160
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 h1:l2zaLDubNhW4XO3LnliVj0GXO3+/CGNJAg1dcN2Fpfw=
160161
github.com/hashicorp/golang-lru/arc/v2 v2.0.5/go.mod h1:ny6zBSQZi2JxIeYcv7kt2sH2PXJtirBN7RDhRpxPkxU=
161162
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4=
Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
apiVersion: v1
2-
kind: Pod
2+
kind: InvalidKind
33
metadata:
4-
creationTimestamp: null
54
name: foo-pod
65
namespace: foo
76
spec:
8-
containers:
9-
- image: busybox
10-
name: invalid
11-
command:
12-
- "sleep"
13-
args:
14-
- "infinity"
15-
resources:
16-
limits:
17-
cpu: 25m
18-
memory: 1GB
19-
requests:
20-
cpu: 25m
21-
memory: 1GB
22-
dnsPolicy: ClusterFirst
23-
restartPolicy: Always
24-
status: {}
7+
invalidField: [this is invalid YAML that should fail to parse
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
apiVersion: v1
2-
kind: PersistentVolumeClaim
3-
metadata:
4-
name: foo-pvc
5-
namespace: foo
6-
spec:
7-
accessModes:
8-
- ReadWriteOnce
9-
resources:
10-
requests:
11-
storage: 250GB
12-
storageClassName: thin-disk
1+
this is malformed YAML that should fail to parse: {
2+
invalid: unclosed bracket

pkg/templates/kubeconform/template.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package kubeconform
22

33
import (
44
"fmt"
5+
"os"
56

67
"github.com/yannh/kubeconform/pkg/resource"
78
"github.com/yannh/kubeconform/pkg/validator"
@@ -33,6 +34,13 @@ func init() {
3334
}
3435

3536
func validate(p params.Params) (check.Func, error) {
37+
// Create cache directory if it doesn't exist
38+
if p.Cache != "" {
39+
if err := os.MkdirAll(p.Cache, 0750); err != nil {
40+
return nil, fmt.Errorf("creating cache directory %s: %w", p.Cache, err)
41+
}
42+
}
43+
3644
v, err := validator.New(p.SchemaLocations, validator.Opts{
3745
Cache: p.Cache,
3846
SkipKinds: sliceToMap(p.SkipKinds),

0 commit comments

Comments
 (0)