Skip to content

Commit 8a02d1f

Browse files
authoredDec 7, 2024
chore(kubeconform): upgrade v0.6.7 (#39)
1 parent 55b5377 commit 8a02d1f

File tree

4 files changed

+192
-146
lines changed

4 files changed

+192
-146
lines changed
 

‎kubeconform/dagger.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"name": "kubeconform",
3+
"engineVersion": "v0.14.0",
34
"sdk": "go",
45
"dependencies": [
56
{
67
"name": "apko",
7-
"source": "github.com/vito/daggerverse/apko@dd441abffabb98405c6ba74f9fde6a62ecaea81a"
8+
"source": "github.com/vito/daggerverse/apko@dd441abffabb98405c6ba74f9fde6a62ecaea81a",
9+
"pin": "dd441abffabb98405c6ba74f9fde6a62ecaea81a"
810
},
911
{
1012
"name": "arc",
11-
"source": "github.com/sagikazarmark/daggerverse/arc@b45dbd7448bb967aca4a538af9ce7f042abf0316"
13+
"source": "github.com/sagikazarmark/daggerverse/arc@arc/v0.5.0",
14+
"pin": "126b5fbbdad70dbf2a8689600baec2eb78c05ef4"
1215
}
1316
],
14-
"source": "dagger",
15-
"engineVersion": "v0.12.1"
17+
"source": "dagger"
1618
}

‎kubeconform/dagger/go.mod

+53-42
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,68 @@
11
module dagger/kubeconform
22

3-
go 1.22.2
3+
go 1.23.2
44

55
require (
6-
github.com/99designs/gqlgen v0.17.49
6+
github.com/99designs/gqlgen v0.17.57
77
github.com/Khan/genqlient v0.7.0
8-
github.com/mholt/archiver/v4 v4.0.0-alpha.8
9-
github.com/vektah/gqlparser/v2 v2.5.16
10-
go.opentelemetry.io/otel v1.27.0
11-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0
12-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0
13-
go.opentelemetry.io/otel/sdk v1.27.0
14-
go.opentelemetry.io/otel/trace v1.27.0
15-
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
16-
golang.org/x/sync v0.7.0
17-
google.golang.org/grpc v1.64.0
8+
github.com/mholt/archives v0.0.0-20241203232558-998c9622f6b8
9+
github.com/vektah/gqlparser/v2 v2.5.20
10+
go.opentelemetry.io/otel v1.32.0
11+
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0
12+
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0
13+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0
14+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0
15+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0
16+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0
17+
go.opentelemetry.io/otel/log v0.8.0
18+
go.opentelemetry.io/otel/metric v1.32.0
19+
go.opentelemetry.io/otel/sdk v1.32.0
20+
go.opentelemetry.io/otel/sdk/log v0.8.0
21+
go.opentelemetry.io/otel/sdk/metric v1.32.0
22+
go.opentelemetry.io/otel/trace v1.32.0
23+
go.opentelemetry.io/proto/otlp v1.4.0
24+
golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d
25+
golang.org/x/sync v0.10.0
26+
google.golang.org/grpc v1.68.1
1827
)
1928

2029
require (
21-
github.com/andybalholm/brotli v1.0.4 // indirect
22-
github.com/bodgit/plumbing v1.2.0 // indirect
23-
github.com/bodgit/sevenzip v1.3.0 // indirect
24-
github.com/bodgit/windows v1.0.0 // indirect
30+
github.com/STARRY-S/zip v0.2.1 // indirect
31+
github.com/andybalholm/brotli v1.1.1 // indirect
32+
github.com/bodgit/plumbing v1.3.0 // indirect
33+
github.com/bodgit/sevenzip v1.6.0 // indirect
34+
github.com/bodgit/windows v1.0.1 // indirect
2535
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
26-
github.com/connesc/cipherio v0.2.1 // indirect
27-
github.com/dsnet/compress v0.0.1 // indirect
28-
github.com/go-logr/logr v1.4.1 // indirect
36+
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707 // indirect
37+
github.com/go-logr/logr v1.4.2 // indirect
2938
github.com/go-logr/stdr v1.2.2 // indirect
30-
github.com/golang/snappy v0.0.4 // indirect
3139
github.com/google/uuid v1.6.0 // indirect
32-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
33-
github.com/hashicorp/errwrap v1.0.0 // indirect
40+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect
41+
github.com/hashicorp/errwrap v1.1.0 // indirect
3442
github.com/hashicorp/go-multierror v1.1.1 // indirect
35-
github.com/klauspost/compress v1.15.9 // indirect
36-
github.com/klauspost/pgzip v1.2.5 // indirect
37-
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 // indirect
38-
github.com/pierrec/lz4/v4 v4.1.15 // indirect
39-
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
43+
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
44+
github.com/klauspost/compress v1.17.11 // indirect
45+
github.com/klauspost/pgzip v1.2.6 // indirect
46+
github.com/nwaples/rardecode/v2 v2.0.1 // indirect
47+
github.com/pierrec/lz4/v4 v4.1.21 // indirect
48+
github.com/sorairolake/lzip-go v0.3.5 // indirect
4049
github.com/sosodev/duration v1.3.1 // indirect
4150
github.com/therootcompany/xz v1.0.1 // indirect
42-
github.com/ulikunitz/xz v0.5.10 // indirect
43-
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
44-
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
45-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
46-
go.opentelemetry.io/otel/log v0.3.0
47-
go.opentelemetry.io/otel/metric v1.27.0 // indirect
48-
go.opentelemetry.io/otel/sdk/log v0.3.0
49-
go.opentelemetry.io/proto/otlp v1.3.1
50-
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
51-
golang.org/x/net v0.26.0 // indirect
52-
golang.org/x/sys v0.21.0 // indirect
53-
golang.org/x/text v0.16.0 // indirect
54-
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect
55-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
56-
google.golang.org/protobuf v1.34.1 // indirect
51+
github.com/ulikunitz/xz v0.5.12 // indirect
52+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect
53+
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
54+
golang.org/x/net v0.32.0 // indirect
55+
golang.org/x/sys v0.28.0 // indirect
56+
golang.org/x/text v0.21.0 // indirect
57+
google.golang.org/genproto/googleapis/api v0.0.0-20241206012308-a4fef0638583 // indirect
58+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583 // indirect
59+
google.golang.org/protobuf v1.35.2 // indirect
5760
)
61+
62+
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
63+
64+
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
65+
66+
replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.3.0
67+
68+
replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.3.0

‎kubeconform/dagger/go.sum

+113-82
Large diffs are not rendered by default.

‎kubeconform/dagger/main.go

+20-18
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@ import (
2020
"context"
2121
"dagger/kubeconform/internal/dagger"
2222
"fmt"
23-
"io"
2423
"net/http"
2524
"net/url"
2625
"path"
2726
"strconv"
2827
"strings"
2928

30-
"github.com/mholt/archiver/v4"
29+
"github.com/mholt/archives"
3130
)
3231

3332
type Kubeconform struct {
3433
// Kubeconform version to use for validation.
3534
// +optional
36-
// +default="v0.6.6"
35+
// +default="v0.6.7"
3736
Version string
3837
}
3938

@@ -117,32 +116,33 @@ func parseGitURL(gitURL string) (string, string, string, error) {
117116
return repoURL, branch, subdir, nil
118117
}
119118

120-
func isAnArchive(url string) (bool, error) {
119+
func isAnArchive(ctx context.Context, url string) (bool, error) {
121120
resp, err := http.Get(url)
122121
if err != nil {
123-
return false, err
122+
return false, fmt.Errorf("failed to fetch URL: %w", err)
124123
}
125124
defer resp.Body.Close()
126125

127-
_, input, err := archiver.Identify("", resp.Body)
128-
if err != nil {
129-
if err == archiver.ErrNoMatch {
130-
return false, nil
131-
}
132-
return false, err
126+
if resp.StatusCode != http.StatusOK {
127+
return false, fmt.Errorf("received non-200 status: %s", resp.Status)
133128
}
134129

135-
// Consume the remaining bytes from the input stream
136-
_, err = io.Copy(io.Discard, input)
130+
// Identify the archive format
131+
format, _, err := archives.Identify(ctx, url, resp.Body)
137132
if err != nil {
138-
return false, err
133+
return false, fmt.Errorf("failed to identify archive format: %w", err)
134+
}
135+
136+
// Check if the identified format is an extractor
137+
if _, ok := format.(archives.Extractor); ok {
138+
return true, nil
139139
}
140140

141-
return true, nil
141+
return false, nil
142142
}
143143

144144
// crdDirs creates a list of directories containing the CRDs schemas to validate against.
145-
func crdDirs(crdURLs []string) ([]*dagger.Directory, error) {
145+
func crdDirs(ctx context.Context, crdURLs []string) ([]*dagger.Directory, error) {
146146
var dirs []*dagger.Directory
147147
for _, crdURL := range crdURLs {
148148
isRepo, err := isGitRepo(crdURL)
@@ -162,7 +162,7 @@ func crdDirs(crdURLs []string) ([]*dagger.Directory, error) {
162162
dir := dag.Git(repoURL).Branch(branch).Tree()
163163
dirs = append(dirs, dir.Directory(subdir))
164164
} else {
165-
isArchive, err := isAnArchive(crdURL)
165+
isArchive, err := isAnArchive(ctx, crdURL)
166166
if err != nil {
167167
return nil, fmt.Errorf("failed to check if the URL is an archive: %v", err)
168168
}
@@ -188,6 +188,8 @@ func (m *Kubeconform) Validate(
188188
version string,
189189

190190
// Base directory to walk through in order to validate Kubernetes manifests.
191+
// +defaultPath="."
192+
// +optional
191193
manifests *dagger.Directory,
192194

193195
// kustomize if set to true it will look for kustomization.yaml files and validate them otherwise it will validate all the YAML files in the directory.
@@ -230,7 +232,7 @@ func (m *Kubeconform) Validate(
230232
return "", err
231233
}
232234

233-
crdDirs, err := crdDirs(crds)
235+
crdDirs, err := crdDirs(ctx, crds)
234236
if err != nil {
235237
return "", fmt.Errorf("failed to create the schemas directories: %v", err)
236238
}

0 commit comments

Comments
 (0)
Please sign in to comment.