13
0
Fork 0
mirror of https://github.com/yannh/kubeconform.git synced 2026-07-03 01:49:30 +00:00

Update deps, make sure we use vendore dependencies

This commit is contained in:
Yann Hamon 2026-06-04 21:28:55 +02:00
parent b83bf792b2
commit d99e236d8f
66 changed files with 11656 additions and 174 deletions

View file

@ -1 +1 @@
1.22.2
1.23

View file

@ -0,0 +1,11 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
linters:
disable-all: true
enable:
- errcheck
- staticcheck
- gosimple
- govet
output_format: colored-line-number

View file

@ -1 +1,13 @@
* @hashicorp/go-retryablehttp-maintainers
# Each line is a file pattern followed by one or more owners.
# More on CODEOWNERS files: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
# Default owner
* @hashicorp/team-ip-compliance @hashicorp/go-retryablehttp-maintainers
# Add override rules below. Each line is a file/folder pattern followed by one or more owners.
# Being an owner means those groups or individuals will be added as reviewers to PRs affecting
# those areas of the code.
# Examples:
# /docs/ @docs-team
# *.js @js-team
# *.go @go-team

View file

@ -2,7 +2,7 @@ default: test
test:
go vet ./...
go test -v -race ./...
go test -v -race ./... -coverprofile=coverage.out
updatedeps:
go get -f -t -u ./...

View file

@ -638,6 +638,23 @@ func LinearJitterBackoff(min, max time.Duration, attemptNum int, resp *http.Resp
return time.Duration(jitterMin * int64(attemptNum))
}
// RateLimitLinearJitterBackoff wraps the retryablehttp.LinearJitterBackoff.
// It first checks if the response status code is http.StatusTooManyRequests
// (HTTP Code 429) or http.StatusServiceUnavailable (HTTP Code 503). If it is
// and the response contains a Retry-After response header, it will wait the
// amount of time specified by the header. Otherwise, this calls
// LinearJitterBackoff.
func RateLimitLinearJitterBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {
if resp != nil {
if resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode == http.StatusServiceUnavailable {
if sleep, ok := parseRetryAfterHeader(resp.Header["Retry-After"]); ok {
return sleep
}
}
}
return LinearJitterBackoff(min, max, attemptNum, resp)
}
// PassthroughErrorHandler is an ErrorHandler that directly passes through the
// values from the net/http library for the final request. The body is not
// closed.
@ -870,11 +887,13 @@ func (c *Client) Head(url string) (*http.Response, error) {
}
// Post is a shortcut for doing a POST request without making a new client.
// The bodyType parameter sets the "Content-Type" header of the request.
func Post(url, bodyType string, body interface{}) (*http.Response, error) {
return defaultClient.Post(url, bodyType, body)
}
// Post is a convenience method for doing simple POST requests.
// The bodyType parameter sets the "Content-Type" header of the request.
func (c *Client) Post(url, bodyType string, body interface{}) (*http.Response, error) {
req, err := NewRequest("POST", url, body)
if err != nil {

View file

@ -1,5 +1,7 @@
version: "2"
linters:
enable:
- nakedret
- errname
- godot
- misspell

BIN
vendor/github.com/santhosh-tekuri/jsonschema/v6/.swp generated vendored Normal file

Binary file not shown.

View file

@ -1,4 +1,4 @@
# jsonschema v6.0.0
# jsonschema v6.0.2
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![GoDoc](https://godoc.org/github.com/santhosh-tekuri/jsonschema?status.svg)](https://pkg.go.dev/github.com/santhosh-tekuri/jsonschema/v6)
@ -56,10 +56,12 @@ see [godoc](https://pkg.go.dev/github.com/santhosh-tekuri/jsonschema/v6) for exa
- enable via flag for draft <= 7
- [x] mixed dialect support
## CLI
## CLI v0.7.0
to install: `go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest`
Note that the cli is versioned independently. you can see it in git tags `cmd/jv/v0.7.0`
```
Usage: jv [OPTIONS] SCHEMA [INSTANCE...]
@ -75,7 +77,7 @@ Options:
-v, --version Print build information
```
- [x] exit code `1` for validation erros, `2` for usage errors
- [x] exit code `1` for validation errors, `2` for usage errors
- [x] validate both schema and multiple instances
- [x] support both json and yaml files
- [x] support standard input, use `-`

View file

@ -5,4 +5,4 @@ use (
./cmd/jv
)
replace github.com/santhosh-tekuri/jsonschema/v6 v6.0.0 => ./
// replace github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 => ./

View file

@ -0,0 +1,4 @@
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=

View file

@ -57,7 +57,7 @@ func (*Not) KeywordPath() []string {
}
func (*Not) LocalizedString(p *message.Printer) string {
return p.Sprintf("not failed")
return p.Sprintf("'not' failed")
}
// --
@ -69,7 +69,7 @@ func (*AllOf) KeywordPath() []string {
}
func (*AllOf) LocalizedString(p *message.Printer) string {
return p.Sprintf("allOf failed")
return p.Sprintf("'allOf' failed")
}
// --
@ -81,7 +81,7 @@ func (*AnyOf) KeywordPath() []string {
}
func (*AnyOf) LocalizedString(p *message.Printer) string {
return p.Sprintf("anyOf failed")
return p.Sprintf("'anyOf' failed")
}
// --
@ -98,9 +98,9 @@ func (*OneOf) KeywordPath() []string {
func (k *OneOf) LocalizedString(p *message.Printer) string {
if len(k.Subschemas) == 0 {
return p.Sprintf("oneOf failed, none matched")
return p.Sprintf("'oneOf' failed, none matched")
}
return p.Sprintf("oneOf failed, subschemas %d, %d matched", k.Subschemas[0], k.Subschemas[1])
return p.Sprintf("'oneOf' failed, subschemas %d, %d matched", k.Subschemas[0], k.Subschemas[1])
}
//--
@ -179,7 +179,7 @@ loop:
}
return p.Sprintf("value must be one of %s", strings.Join(want, ", "))
}
return p.Sprintf("enum failed")
return p.Sprintf("'enum' failed")
}
// --
@ -196,7 +196,7 @@ func (*Const) KeywordPath() []string {
func (k *Const) LocalizedString(p *message.Printer) string {
switch want := k.Want.(type) {
case []any, map[string]any:
return p.Sprintf("const failed")
return p.Sprintf("'const' failed")
default:
return p.Sprintf("value must be %s", display(want))
}
@ -523,7 +523,7 @@ func (*ContentSchema) KeywordPath() []string {
}
func (*ContentSchema) LocalizedString(p *message.Printer) string {
return p.Sprintf("contentSchema failed")
return p.Sprintf("'contentSchema' failed")
}
// --

View file

@ -137,6 +137,10 @@ type OutputError struct {
p *message.Printer
}
func (k OutputError) String() string {
return k.Kind.LocalizedString(k.p)
}
func (k OutputError) MarshalJSON() ([]byte, error) {
return json.Marshal(k.Kind.LocalizedString(k.p))
}

View file

@ -53,7 +53,7 @@ func (r *root) resolveFragment(frag fragment) (urlPtr, error) {
return r.resolveFragmentIn(frag, r.rootResource())
}
// resovles urlFrag to urlPtr from root.
// resolves urlFrag to urlPtr from root.
// returns nil if it is external.
func (r *root) resolve(uf urlFrag) (*urlPtr, error) {
var res *resource

View file

@ -79,7 +79,8 @@ func (rr *roots) collectResources(r *root, sch any, base url, schPtr jsonPointer
}
func (rr *roots) _collectResources(r *root, sch any, base url, schPtr jsonPointer, fallback dialect) error {
if _, ok := sch.(bool); ok {
obj, ok := sch.(map[string]any)
if !ok {
if schPtr.isEmpty() {
// root resource
res := newResource(schPtr, base)
@ -88,10 +89,6 @@ func (rr *roots) _collectResources(r *root, sch any, base url, schPtr jsonPointe
}
return nil
}
obj, ok := sch.(map[string]any)
if !ok {
return nil
}
hasSchema := false
if sch, ok := obj["$schema"]; ok {

View file

@ -6,7 +6,7 @@ import (
"math/big"
)
// Schema is the regpresentation of a compiled
// Schema is the representation of a compiled
// jsonschema.
type Schema struct {
up urlPtr
@ -177,11 +177,11 @@ func newTypes(v any) *Types {
var types Types
switch v := v.(type) {
case string:
types.add(typeFromString(v))
types.Add(v)
case []any:
for _, item := range v {
if s, ok := item.(string); ok {
types.add(typeFromString(s))
types.Add(s)
}
}
}
@ -195,6 +195,12 @@ func (tt Types) IsEmpty() bool {
return tt == 0
}
// Add specified json type. If typ is
// not valid json type it is ignored.
func (tt *Types) Add(typ string) {
tt.add(typeFromString(typ))
}
func (tt *Types) add(t jsonType) {
*tt = Types(int(*tt) | int(t))
}

View file

@ -49,6 +49,11 @@ type ValidatorContext struct {
vd *validator
}
// ValueLocation returns location of value as jsonpath token array.
func (ctx *ValidatorContext) ValueLocation() []string {
return ctx.vd.vloc
}
// Validate validates v with sch. vpath gives path of v from current context value.
func (ctx *ValidatorContext) Validate(sch *Schema, v any, vpath []string) error {
switch len(vpath) {