Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed May 26, 2023
1 parent d53ca3d commit 96fc457
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 174 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ require (
github.com/spf13/pflag v1.0.5
go.bytebuilders.dev/audit v0.0.27
go.bytebuilders.dev/license-proxyserver v0.0.3
go.bytebuilders.dev/license-verifier v0.13.1
go.bytebuilders.dev/license-verifier/kubernetes v0.13.1
go.bytebuilders.dev/license-verifier v0.13.2
go.bytebuilders.dev/license-verifier/kubernetes v0.13.2
go.uber.org/automaxprocs v1.5.2
go.wandrs.dev/http v0.0.2
gocloud.dev v0.27.0
Expand All @@ -35,7 +35,7 @@ require (
k8s.io/klog/v2 v2.80.1
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85
kmodules.xyz/client-go v0.25.22
kmodules.xyz/client-go v0.25.23
kmodules.xyz/go-containerregistry v0.0.11
kubedb.dev/apimachinery v0.32.0
sigs.k8s.io/controller-runtime v0.13.1
Expand Down Expand Up @@ -179,7 +179,7 @@ require (
gomodules.xyz/clock v0.0.0-20200817085942-06523dba733f // indirect
gomodules.xyz/encoding v0.0.7 // indirect
gomodules.xyz/flags v0.1.3 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
gomodules.xyz/mergo v0.3.13 // indirect
gomodules.xyz/pointer v0.1.0 // indirect
gomodules.xyz/sync v0.1.0 // indirect
Expand Down
17 changes: 8 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ github.com/envoyproxy/go-control-plane v0.10.3/go.mod h1:fJJn/j26vwOu972OllsvAgJ
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo=
github.com/euank/go-kmsg-parser v2.0.0+incompatible/go.mod h1:MhmAMZ8V4CYH4ybgdRwPr2TU5ThnS43puaKEMpja1uw=
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
Expand Down Expand Up @@ -1582,10 +1581,10 @@ go.bytebuilders.dev/audit v0.0.27 h1:d9kYia/S17JhkauRXw/ERXAtfuujkGDGjpeQcAurmkY
go.bytebuilders.dev/audit v0.0.27/go.mod h1:88UkSOMKSKShknE5c6V1HtBHCXArIO/LHio61OSzaww=
go.bytebuilders.dev/license-proxyserver v0.0.3 h1:vAFMBWfrlmFKNspjBm2KfPXnxYnC17xLwZiHmVzUmzs=
go.bytebuilders.dev/license-proxyserver v0.0.3/go.mod h1:iMJbPzDf2R2EJOZwRi7ziEr5DBMfT9Cm75/XfPb/QnU=
go.bytebuilders.dev/license-verifier v0.13.1 h1:O0V5a91f2LO7g561NUOGu1dJQiq8ajj7m4IswnmrfnQ=
go.bytebuilders.dev/license-verifier v0.13.1/go.mod h1:PTTlWgokzoisBezn2zt+JeGkhTJZ0flvLzdhHVBy86M=
go.bytebuilders.dev/license-verifier/kubernetes v0.13.1 h1:zSylZxnaV0Nx2v8cauBUAxNIo4hSOaocl/n0jYilacw=
go.bytebuilders.dev/license-verifier/kubernetes v0.13.1/go.mod h1:A2LcHiri4JeveGGfzR3dZgrgR2l/hEh1x8+/Efha+TY=
go.bytebuilders.dev/license-verifier v0.13.2 h1:wV1ynl+GR+zKb3dh19WEzuC0uzTdiSGgVg9G78Nh4XU=
go.bytebuilders.dev/license-verifier v0.13.2/go.mod h1:PTTlWgokzoisBezn2zt+JeGkhTJZ0flvLzdhHVBy86M=
go.bytebuilders.dev/license-verifier/kubernetes v0.13.2 h1:ZIPTce9sAR9/GaPvQtkbOTXGE1Nyyv0GcMqnInUaqxM=
go.bytebuilders.dev/license-verifier/kubernetes v0.13.2/go.mod h1:xiM7bX84LNWQPJRC/m9rQASuCclJSsDdf2qFdafrz1k=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
Expand Down Expand Up @@ -2178,8 +2177,8 @@ gomodules.xyz/flags v0.1.3 h1:jQ06+EfmoMv5NvjXvJon03dOhLU+FF0TQMWN7I6qpzs=
gomodules.xyz/flags v0.1.3/go.mod h1:e+kvBLnqdEWGG670SKOYag1CXStM2Slrxq01OIK3tFs=
gomodules.xyz/go-sh v0.1.0 h1:1BJAuGREh2RhePt7HRrpmjnkbgfpXlCzc42SiyZ5dkc=
gomodules.xyz/go-sh v0.1.0/go.mod h1:N8IrjNiYppUI/rxENYrWD6FOrSxSyEZnIekPEWM7LP0=
gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY=
gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY=
gomodules.xyz/jsonpatch/v2 v2.3.0 h1:8NFhfS6gzxNqjLIYnZxg319wZ5Qjnx4m/CcX+Klzazc=
gomodules.xyz/jsonpatch/v2 v2.3.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
gomodules.xyz/logs v0.0.6 h1:8+9Wkud5yBPtIvkVszubyTeFxNII30lWODom0+GZD8U=
gomodules.xyz/logs v0.0.6/go.mod h1:Q+fFtZFLEB5q86KmDehXCGuMP72Rv+Rwz0KuVxK+Gi4=
gomodules.xyz/mergo v0.3.13 h1:q6cL/MMXZH/MrR2+yjSihFFq6UifXqjwaqI48B6cMEM=
Expand Down Expand Up @@ -2589,8 +2588,8 @@ k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85 h1:cTdVh7LYu82xeClmfzGtgyspNh6Ux
k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk=
kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80=
kmodules.xyz/client-go v0.25.22 h1:gtRyVl5Ar87zzKj4g7Nx+0QSeWq9yTKADoasZP+brZg=
kmodules.xyz/client-go v0.25.22/go.mod h1:KWVpgjAj/VNzCzj/BihpJkY39aWIqe8qMp5RuPsuSJA=
kmodules.xyz/client-go v0.25.23 h1:qz5XJYHLVZUowqfRXEJD7JQ4iaLLzQ1O1zPMmsdrkJw=
kmodules.xyz/client-go v0.25.23/go.mod h1:wbdzLEoDYiCPI6dTW0mIAGNwkwFV4lC5BN1FJxiDsbw=
kmodules.xyz/custom-resources v0.25.1 h1:0qHPTxbT/q0afl2GCOnwPFaoxKziRIPXgVu77YwrCa4=
kmodules.xyz/custom-resources v0.25.1/go.mod h1:ULwzvLmOqZJcPSXKI7iLclYL5eYRlKx8Nbex28Ht19E=
kmodules.xyz/go-containerregistry v0.0.11 h1:eZ7dz5QvszqoedOQLyqf5lkDa+S3Bds4EHHhb6jrLMc=
Expand Down
11 changes: 5 additions & 6 deletions vendor/go.bytebuilders.dev/license-verifier/info/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,14 @@ func HostedEndpoint(u string) (bool, error) {
if err != nil {
return false, err
}
host := u2.Hostname()
return host == prodDomain ||
host == qaDomain ||
strings.HasSuffix(host, "."+prodDomain) ||
strings.HasSuffix(host, "."+qaDomain), nil
return HostedDomain(u2.Hostname()), nil
}

func HostedDomain(d string) bool {
return d == prodDomain || d == qaDomain
return d == prodDomain ||
d == qaDomain ||
strings.HasSuffix(d, "."+prodDomain) ||
strings.HasSuffix(d, "."+qaDomain)
}

func LoadLicenseCA() ([]byte, error) {
Expand Down
160 changes: 34 additions & 126 deletions vendor/gomodules.xyz/jsonpatch/v2/jsonpatch.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package jsonpatch

import (
"bytes"
"encoding/json"
"fmt"
"reflect"
Expand All @@ -24,21 +23,28 @@ func (j *Operation) Json() string {
}

func (j *Operation) MarshalJSON() ([]byte, error) {
var b bytes.Buffer
b.WriteString("{")
b.WriteString(fmt.Sprintf(`"op":"%s"`, j.Operation))
b.WriteString(fmt.Sprintf(`,"path":"%s"`, j.Path))
// Consider omitting Value for non-nullable operations.
if j.Value != nil || j.Operation == "replace" || j.Operation == "add" {
v, err := json.Marshal(j.Value)
if err != nil {
return nil, err
}
b.WriteString(`,"value":`)
b.Write(v)
}
b.WriteString("}")
return b.Bytes(), nil
// Ensure for add and replace we emit `value: null`
if j.Value == nil && (j.Operation == "replace" || j.Operation == "add") {
return json.Marshal(struct {
Operation string `json:"op"`
Path string `json:"path"`
Value interface{} `json:"value"`
}{
Operation: j.Operation,
Path: j.Path,
})
}
// otherwise just marshal normally. We cannot literally do json.Marshal(j) as it would be recursively
// calling this function.
return json.Marshal(struct {
Operation string `json:"op"`
Path string `json:"path"`
Value interface{} `json:"value,omitempty"`
}{
Operation: j.Operation,
Path: j.Path,
Value: j.Value,
})
}

type ByPath []Operation
Expand Down Expand Up @@ -149,9 +155,6 @@ func makePath(path string, newPart interface{}) string {
if path == "" {
return "/" + key
}
if strings.HasSuffix(path, "/") {
return path + key
}
return path + "/" + key
}

Expand Down Expand Up @@ -211,22 +214,18 @@ func handleValues(av, bv interface{}, p string, patch []Operation) ([]Operation,
}
case []interface{}:
bt := bv.([]interface{})
if isSimpleArray(at) && isSimpleArray(bt) {
patch = append(patch, compareEditDistance(at, bt, p)...)
} else {
n := min(len(at), len(bt))
for i := len(at) - 1; i >= n; i-- {
patch = append(patch, NewOperation("remove", makePath(p, i), nil))
}
for i := n; i < len(bt); i++ {
patch = append(patch, NewOperation("add", makePath(p, i), bt[i]))
}
for i := 0; i < n; i++ {
var err error
patch, err = handleValues(at[i], bt[i], makePath(p, i), patch)
if err != nil {
return nil, err
}
n := min(len(at), len(bt))
for i := len(at) - 1; i >= n; i-- {
patch = append(patch, NewOperation("remove", makePath(p, i), nil))
}
for i := n; i < len(bt); i++ {
patch = append(patch, NewOperation("add", makePath(p, i), bt[i]))
}
for i := 0; i < n; i++ {
var err error
patch, err = handleValues(at[i], bt[i], makePath(p, i), patch)
if err != nil {
return nil, err
}
}
default:
Expand All @@ -235,100 +234,9 @@ func handleValues(av, bv interface{}, p string, patch []Operation) ([]Operation,
return patch, nil
}

func isBasicType(a interface{}) bool {
switch a.(type) {
case string, float64, bool:
default:
return false
}
return true
}

func isSimpleArray(a []interface{}) bool {
for i := range a {
switch a[i].(type) {
case string, float64, bool:
default:
val := reflect.ValueOf(a[i])
if val.Kind() == reflect.Map {
for _, k := range val.MapKeys() {
av := val.MapIndex(k)
if av.Kind() == reflect.Ptr || av.Kind() == reflect.Interface {
if av.IsNil() {
continue
}
av = av.Elem()
}
if av.Kind() != reflect.String && av.Kind() != reflect.Float64 && av.Kind() != reflect.Bool {
return false
}
}
return true
}
return false
}
}
return true
}

// https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm
// Adapted from https://github.com/texttheater/golang-levenshtein
func compareEditDistance(s, t []interface{}, p string) []Operation {
m := len(s)
n := len(t)

d := make([][]int, m+1)
for i := 0; i <= m; i++ {
d[i] = make([]int, n+1)
d[i][0] = i
}
for j := 0; j <= n; j++ {
d[0][j] = j
}

for j := 1; j <= n; j++ {
for i := 1; i <= m; i++ {
if reflect.DeepEqual(s[i-1], t[j-1]) {
d[i][j] = d[i-1][j-1] // no op required
} else {
del := d[i-1][j] + 1
add := d[i][j-1] + 1
rep := d[i-1][j-1] + 1
d[i][j] = min(rep, min(add, del))
}
}
}

return backtrace(s, t, p, m, n, d)
}

func min(x int, y int) int {
if y < x {
return y
}
return x
}

func backtrace(s, t []interface{}, p string, i int, j int, matrix [][]int) []Operation {
if i > 0 && matrix[i-1][j]+1 == matrix[i][j] {
op := NewOperation("remove", makePath(p, i-1), nil)
return append([]Operation{op}, backtrace(s, t, p, i-1, j, matrix)...)
}
if j > 0 && matrix[i][j-1]+1 == matrix[i][j] {
op := NewOperation("add", makePath(p, i), t[j-1])
return append([]Operation{op}, backtrace(s, t, p, i, j-1, matrix)...)
}
if i > 0 && j > 0 && matrix[i-1][j-1]+1 == matrix[i][j] {
if isBasicType(s[0]) {
op := NewOperation("replace", makePath(p, i-1), t[j-1])
return append([]Operation{op}, backtrace(s, t, p, i-1, j-1, matrix)...)
}

p2, _ := handleValues(s[i-1], t[j-1], makePath(p, i-1), []Operation{})
return append(p2, backtrace(s, t, p, i-1, j-1, matrix)...)
}
if i > 0 && j > 0 && matrix[i-1][j-1] == matrix[i][j] {
return backtrace(s, t, p, i-1, j-1, matrix)
}
return []Operation{}
}
20 changes: 19 additions & 1 deletion vendor/kmodules.xyz/client-go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,26 @@ gen-crd-protos:
--apimachinery-packages=-k8s.io/apimachinery/pkg/api/resource,-k8s.io/apimachinery/pkg/apis/meta/v1,-k8s.io/apimachinery/pkg/apis/meta/v1beta1,-k8s.io/apimachinery/pkg/runtime,-k8s.io/apimachinery/pkg/runtime/schema,-k8s.io/apimachinery/pkg/util/intstr \
--packages=-k8s.io/api/core/v1,kmodules.xyz/client-go/api/v1

.PHONY: gen-enum
gen-enum:
@docker run \
-i \
--rm \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/src \
-w /src \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
-v $$(pwd)/.go/cache:/.cache \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(BUILD_IMAGE) \
/bin/bash -c " \
go generate ./api/... \
"

.PHONY: gen
gen: clientset openapi gen-crd-protos
gen: clientset gen-enum openapi gen-crd-protos

fmt: $(BUILD_DIRS)
@docker run \
Expand Down
30 changes: 7 additions & 23 deletions vendor/kmodules.xyz/client-go/api/v1/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//go:generate go-enum --mustparse --names --values
package v1

import (
Expand Down Expand Up @@ -207,30 +208,13 @@ type ObjectInfo struct {
Ref ObjectReference `json:"ref" protobuf:"bytes,2,opt,name=ref"`
}

// +kubebuilder:validation:Enum=id;config;backup_via;catalog;connect_via;exposed_by;monitored_by;offshoot;restore_into;scaled_by;view;cert_issuer;policy;recommended_for;ops
// +kubebuilder:validation:Enum=backup_via;catalog;cert_issuer;config;connect_via;exposed_by;id;located_on;monitored_by;offshoot;ops;policy;recommended_for;restore_into;scaled_by;view
// ENUM(backup_via,catalog,cert_issuer,config,connect_via,exposed_by,id,located_on,monitored_by,offshoot,ops,policy,recommended_for,restore_into,scaled_by,view)
type EdgeLabel string

const (
EdgeId EdgeLabel = "id"
EdgeConfig EdgeLabel = "config"
EdgeBackupVia EdgeLabel = "backup_via"
EdgeCatalog EdgeLabel = "catalog"
EdgeConnectVia EdgeLabel = "connect_via"
EdgeExposedBy EdgeLabel = "exposed_by"
EdgeMonitoredBy EdgeLabel = "monitored_by"
EdgeOffshoot EdgeLabel = "offshoot"
EdgeRestoreInto EdgeLabel = "restore_into"
EdgeScaledBy EdgeLabel = "scaled_by"
EdgeView EdgeLabel = "view"
EdgeCertIssuer EdgeLabel = "cert_issuer"
EdgePolicy EdgeLabel = "policy"
EdgeOps EdgeLabel = "ops"
EdgeRecommendedFor EdgeLabel = "recommended_for"
)

func (e EdgeLabel) Direct() bool {
return e == EdgeOffshoot ||
e == EdgeView ||
e == EdgeOps ||
e == EdgeRecommendedFor
return e == EdgeLabelOffshoot ||
e == EdgeLabelView ||
e == EdgeLabelOps ||
e == EdgeLabelRecommendedFor
}
Loading

0 comments on commit 96fc457

Please sign in to comment.