diff --git a/go.mod b/go.mod index 68b74d9c..d6328cf3 100644 --- a/go.mod +++ b/go.mod @@ -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.23 + kmodules.xyz/client-go v0.25.30-0.20230816023640-cf58432a4653 kmodules.xyz/go-containerregistry v0.0.11 kubedb.dev/apimachinery v0.32.0 sigs.k8s.io/controller-runtime v0.13.1 @@ -179,7 +179,8 @@ 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.3.0 // indirect + gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect + gomodules.xyz/jsonpath v0.0.2 // indirect gomodules.xyz/mergo v0.3.13 // indirect gomodules.xyz/pointer v0.1.0 // indirect gomodules.xyz/sync v0.1.0 // indirect @@ -208,9 +209,13 @@ require ( sigs.k8s.io/yaml v1.3.0 // indirect ) +replace github.com/Masterminds/sprig/v3 => github.com/gomodules/sprig/v3 v3.2.3-0.20220405051441-0a8a99bac1b8 + +replace sigs.k8s.io/controller-runtime => github.com/kmodules/controller-runtime v0.13.1-0.20230725210630-f8273f9c4412 + replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.6 -replace k8s.io/apiserver => github.com/kmodules/apiserver v0.25.2-0.20220917044909-4ac5fceca518 +replace k8s.io/apiserver => github.com/kmodules/apiserver v0.25.2-0.20230712090038-ce87ebac4a3d replace k8s.io/kubernetes => github.com/kmodules/kubernetes v1.26.0-alpha.0.0.20220917022409-54ac9f3f1315 diff --git a/go.sum b/go.sum index 45d1509c..744f610e 100644 --- a/go.sum +++ b/go.sum @@ -152,8 +152,6 @@ github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJ github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= -github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= @@ -789,6 +787,8 @@ github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAO github.com/golangplus/bytes v1.0.0/go.mod h1:AdRaCFwmc/00ZzELMWb01soso6W1R/++O1XL80yAn+A= github.com/golangplus/fmt v1.0.0/go.mod h1:zpM0OfbMCjPtd2qkTD/jX2MgiFCqklhSUFyDW44gVQE= github.com/golangplus/testing v1.0.0/go.mod h1:ZDreixUV3YzhoVraIDyOzHrr76p6NUh6k/pPg/Q3gYA= +github.com/gomodules/sprig/v3 v3.2.3-0.20220405051441-0a8a99bac1b8 h1:rWzwdmHqkXrISyacSZcK9oLZIu5nIxesPwp9f8LpTvc= +github.com/gomodules/sprig/v3 v3.2.3-0.20220405051441-0a8a99bac1b8/go.mod h1:70huEoC6heWUvVNiFAnIRaEmvzAECK551RuYBCkT13w= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= @@ -967,7 +967,6 @@ github.com/heketi/tests v0.0.0-20151005000721-f3775cbcefd6/go.mod h1:xGMAM8JLi7U github.com/hetznercloud/hcloud-go v1.33.1/go.mod h1:XX/TQub3ge0yWR2yHWmnDVIrB+MQbda1pHxkUmDlUME= github.com/hetznercloud/hcloud-go v1.35.0/go.mod h1:mepQwR6va27S3UQthaEPGS86jtzSY9xWL1e9dyxXpgA= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= @@ -1070,8 +1069,10 @@ github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47e github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/kmodules/apiserver v0.25.2-0.20220917044909-4ac5fceca518 h1:uYw2fRagdWLdOOP7VGjHO2z/iTfM3mz+LEgDLgMJkeQ= -github.com/kmodules/apiserver v0.25.2-0.20220917044909-4ac5fceca518/go.mod h1:IB1EhM28U3cCrV+VNC06p1/YSZMCNYiH+P5sI5yLaZY= +github.com/kmodules/apiserver v0.25.2-0.20230712090038-ce87ebac4a3d h1:uTjbIzCRR94MPtzbhoRXG+1xUSI1DzoLKm+SRPMfOdA= +github.com/kmodules/apiserver v0.25.2-0.20230712090038-ce87ebac4a3d/go.mod h1:IB1EhM28U3cCrV+VNC06p1/YSZMCNYiH+P5sI5yLaZY= +github.com/kmodules/controller-runtime v0.13.1-0.20230725210630-f8273f9c4412 h1:sy5gE/M+SfQdIK9wh1VIT0RhXxiVlPRQxpGy2TVvnzE= +github.com/kmodules/controller-runtime v0.13.1-0.20230725210630-f8273f9c4412/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI= github.com/kmodules/kubernetes v1.26.0-alpha.0.0.20220917022409-54ac9f3f1315/go.mod h1:0mG7e9c0E0rgZHPqtiezb+3/tZW+ixtNWpNo0n9XOaw= github.com/kolo/xmlrpc v0.0.0-20201022064351-38db28db192b/go.mod h1:pcaDhQK0/NJZEvtCO0qQPPropqV0sJOJ6YW7X+9kRwM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -1161,7 +1162,6 @@ github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -1180,7 +1180,6 @@ github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/ipvs v1.0.1/go.mod h1:2pngiyseZbIKXNv7hsKj3O9UEz30c53MT9005gt2hxQ= @@ -1700,7 +1699,6 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -2177,8 +2175,10 @@ 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.3.0 h1:8NFhfS6gzxNqjLIYnZxg319wZ5Qjnx4m/CcX+Klzazc= -gomodules.xyz/jsonpatch/v2 v2.3.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= +gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= +gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= +gomodules.xyz/jsonpath v0.0.2 h1:taUvqxKQ9KqVl3vq/+hLg7rCZUIQjq+izhbvo6nTIkE= +gomodules.xyz/jsonpath v0.0.2/go.mod h1:du28vmLHrgEV48JqK/7rn92YHsVDoQuqrowb2w6YZmE= 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= @@ -2588,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.23 h1:qz5XJYHLVZUowqfRXEJD7JQ4iaLLzQ1O1zPMmsdrkJw= -kmodules.xyz/client-go v0.25.23/go.mod h1:wbdzLEoDYiCPI6dTW0mIAGNwkwFV4lC5BN1FJxiDsbw= +kmodules.xyz/client-go v0.25.30-0.20230816023640-cf58432a4653 h1:EV+jQ/PhMJ5TF/B7KyKGx++F3bnULSuxk95MMYu149o= +kmodules.xyz/client-go v0.25.30-0.20230816023640-cf58432a4653/go.mod h1:r/Va2Y6t1G8X1sPRjrQC6FWB3oh/i6rjssmlfJnbCmg= 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= @@ -2617,8 +2617,6 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.33 h1:LYqFq+6Cj2D0g sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.33/go.mod h1:soWkSNf2tZC7aMibXEqVhCd73GOY5fJikn8qbdzemB0= sigs.k8s.io/cli-utils v0.33.0 h1:/ioqfYu0hVeR2T2SDH3WVPgpqiJkrzqjJFrQ3u+baHk= sigs.k8s.io/cli-utils v0.33.0/go.mod h1:g/zB9hJ5eUN7zIEBIxrO0CwhXU4YISJ+BkLJzvWwlEs= -sigs.k8s.io/controller-runtime v0.13.1 h1:tUsRCSJVM1QQOOeViGeX3GMT3dQF1eePPw6sEE3xSlg= -sigs.k8s.io/controller-runtime v0.13.1/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI= sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6/go.mod h1:p4QtZmO4uMYipTQNzagwnNoseA6OxSUutVw05NhYDRs= sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= diff --git a/pkg/controllers/scanreport/controller.go b/pkg/controllers/scanreport/controller.go index d84e7511..34136f04 100644 --- a/pkg/controllers/scanreport/controller.go +++ b/pkg/controllers/scanreport/controller.go @@ -69,7 +69,7 @@ func (r *ImageScanReportReconciler) Reconcile(ctx context.Context, req ctrl.Requ status.Phase = api.ImageScanReportPhaseCurrent } - _, _, err = cu.PatchStatus(ctx, r.Client, &isrp, func(obj client.Object) client.Object { + _, err = cu.PatchStatus(ctx, r.Client, &isrp, func(obj client.Object) client.Object { in := obj.(*api.ImageScanReport) in.Status = *status return in diff --git a/pkg/controllers/scanrequest/copy.go b/pkg/controllers/scanrequest/copy.go index 0dc11fb0..365505b0 100644 --- a/pkg/controllers/scanrequest/copy.go +++ b/pkg/controllers/scanrequest/copy.go @@ -70,7 +70,7 @@ func (r *RequestReconciler) copySecrets(secrets []corev1.LocalObjectReference) ( return nil, err } - newSec, _, err := cu.CreateOrPatch(r.ctx, r.Client, &corev1.Secret{ + newSec := &corev1.Secret{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.String(), Kind: "Secret", @@ -79,7 +79,8 @@ func (r *RequestReconciler) copySecrets(secrets []corev1.LocalObjectReference) ( GenerateName: "pull-secret-", Namespace: r.workspace, }, - }, func(obj client.Object, createOp bool) client.Object { + } + _, err = cu.CreateOrPatch(r.ctx, r.Client, newSec, func(obj client.Object, createOp bool) client.Object { s := obj.(*corev1.Secret) if createOp { s.Immutable = sec.Immutable @@ -98,7 +99,7 @@ func (r *RequestReconciler) copySecrets(secrets []corev1.LocalObjectReference) ( } func (r *RequestReconciler) copyServiceAccount(saPullSecrets []corev1.LocalObjectReference, sa corev1.ServiceAccount) (string, error) { - newSA, _, err := cu.CreateOrPatch(r.ctx, r.Client, &corev1.ServiceAccount{ + newSA := &corev1.ServiceAccount{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.String(), Kind: "ServiceAccount", @@ -107,7 +108,8 @@ func (r *RequestReconciler) copyServiceAccount(saPullSecrets []corev1.LocalObjec GenerateName: "sa-", Namespace: r.workspace, }, - }, func(obj client.Object, createOp bool) client.Object { + } + _, err := cu.CreateOrPatch(r.ctx, r.Client, newSA, func(obj client.Object, createOp bool) client.Object { s := obj.(*corev1.ServiceAccount) if createOp { s.Secrets = sa.Secrets @@ -124,7 +126,7 @@ func (r *RequestReconciler) copyServiceAccount(saPullSecrets []corev1.LocalObjec func (r *RequestReconciler) setOwnerRefToCopiedObjects(job *batch.Job, sa string, pullSecrets []corev1.LocalObjectReference) error { for i := range pullSecrets { - _, _, err := cu.CreateOrPatch(r.ctx, r.Client, &corev1.Secret{ + _, err := cu.CreateOrPatch(r.ctx, r.Client, &corev1.Secret{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.String(), Kind: "Secret", @@ -145,7 +147,7 @@ func (r *RequestReconciler) setOwnerRefToCopiedObjects(job *batch.Job, sa string if sa == "" { return nil } - _, _, err := cu.CreateOrPatch(r.ctx, r.Client, &corev1.ServiceAccount{ + _, err := cu.CreateOrPatch(r.ctx, r.Client, &corev1.ServiceAccount{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.String(), Kind: "ServiceAccount", diff --git a/pkg/controllers/scanrequest/helpers.go b/pkg/controllers/scanrequest/helpers.go index 45409dd6..2d3d067b 100644 --- a/pkg/controllers/scanrequest/helpers.go +++ b/pkg/controllers/scanrequest/helpers.go @@ -36,11 +36,12 @@ func EnsureScanReport(kc client.Client, imageRef string, resp trivy.BackendRespo return nil, err } - obj, vt, err := cu.CreateOrPatch(context.TODO(), kc, &api.ImageScanReport{ + obj := &api.ImageScanReport{ ObjectMeta: metav1.ObjectMeta{ Name: api.GetReportName(img.Name), }, - }, func(obj client.Object, createOp bool) client.Object { + } + vt, err := cu.CreateOrPatch(context.TODO(), kc, obj, func(obj client.Object, createOp bool) client.Object { rep := obj.(*api.ImageScanReport) rep.Spec.Image = api.ImageReference{ Name: resp.ImageDetails.Name, @@ -56,7 +57,7 @@ func EnsureScanReport(kc client.Client, imageRef string, resp trivy.BackendRespo klog.Infof("%v ImageScanReport has been created\n", obj.GetName()) } - _, _, err = cu.PatchStatus(context.TODO(), kc, &api.ImageScanReport{ + _, err = cu.PatchStatus(context.TODO(), kc, &api.ImageScanReport{ ObjectMeta: metav1.ObjectMeta{ Name: api.GetReportName(img.Name), }, @@ -75,7 +76,7 @@ func EnsureScanReport(kc client.Client, imageRef string, resp trivy.BackendRespo return nil, err } - return obj.(*api.ImageScanReport), nil + return obj, nil } func upsertCVEs(kc client.Client, r trivy.SingleReport) error { @@ -88,7 +89,7 @@ func upsertCVEs(kc client.Client, r trivy.SingleReport) error { } for _, vul := range vuls { - _, vt, err := cu.CreateOrPatch(context.TODO(), kc, &api.Vulnerability{ + vt, err := cu.CreateOrPatch(context.TODO(), kc, &api.Vulnerability{ ObjectMeta: metav1.ObjectMeta{ Name: vul.VulnerabilityID, }, diff --git a/pkg/controllers/scanrequest/private.go b/pkg/controllers/scanrequest/private.go index cb80a228..e07beec2 100644 --- a/pkg/controllers/scanrequest/private.go +++ b/pkg/controllers/scanrequest/private.go @@ -76,7 +76,7 @@ func (r *RequestReconciler) ensureJob(sa string, pullSecrets []corev1.LocalObjec } } - obj, _, err := cu.CreateOrPatch(r.ctx, r.Client, &batch.Job{ + obj := &batch.Job{ TypeMeta: metav1.TypeMeta{ Kind: "Job", APIVersion: batch.SchemeGroupVersion.String(), @@ -85,7 +85,8 @@ func (r *RequestReconciler) ensureJob(sa string, pullSecrets []corev1.LocalObjec GenerateName: ScannerJobName, Namespace: r.workspace, }, - }, func(obj client.Object, createOp bool) client.Object { + } + _, err := cu.CreateOrPatch(r.ctx, r.Client, obj, func(obj client.Object, createOp bool) client.Object { job := obj.(*batch.Job) if createOp { job.Spec.Template.Spec.Volumes = core_util.UpsertVolume(job.Spec.Template.Spec.Volumes, core.Volume{ @@ -167,7 +168,7 @@ func (r *RequestReconciler) ensureJob(sa string, pullSecrets []corev1.LocalObjec } klog.Infof("Scanner job %v/%v created", obj.GetNamespace(), obj.GetName()) - return obj.(*batch.Job), r.updateStatusWithJobName(obj.GetName()) + return obj, r.updateStatusWithJobName(obj.GetName()) } func (r *RequestReconciler) ScanForPrivateImage() error { @@ -262,11 +263,12 @@ func (r *RequestReconciler) ensureDigestInRequestAndReport(digest string) error return err } - req, _, err := cu.PatchStatus(r.ctx, r.Client, &api.ImageScanRequest{ + r.req = &api.ImageScanRequest{ ObjectMeta: metav1.ObjectMeta{ Name: r.req.Name, }, - }, func(obj client.Object) client.Object { + } + _, err = cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { req := obj.(*api.ImageScanRequest) if req.Status.Image == nil { req.Status.Image = &trivy.ImageDetails{ @@ -282,9 +284,8 @@ func (r *RequestReconciler) ensureDigestInRequestAndReport(digest string) error if err != nil { return err } - r.req = req.(*api.ImageScanRequest) - _, _, err = cu.CreateOrPatch(r.ctx, r.Client, &api.ImageScanReport{ + _, err = cu.CreateOrPatch(r.ctx, r.Client, &api.ImageScanReport{ ObjectMeta: metav1.ObjectMeta{ Name: api.GetReportName(img.Name), }, diff --git a/pkg/controllers/scanrequest/status.go b/pkg/controllers/scanrequest/status.go index f1057614..3bdc27f4 100644 --- a/pkg/controllers/scanrequest/status.go +++ b/pkg/controllers/scanrequest/status.go @@ -27,7 +27,7 @@ import ( ) func (r *RequestReconciler) setDefaultStatus() error { - req, _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { + _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { in := obj.(*api.ImageScanRequest) in.Status.Image = &trivy.ImageDetails{ Name: r.req.Spec.Image, @@ -35,11 +35,7 @@ func (r *RequestReconciler) setDefaultStatus() error { in.Status.Phase = api.ImageScanRequestPhasePending return in }) - if err != nil { - return err - } - r.req = req.(*api.ImageScanRequest) - return nil + return err } func (r *RequestReconciler) updateStatusWithImageDetails(vis trivy.ImageVisibility) error { @@ -48,7 +44,7 @@ func (r *RequestReconciler) updateStatusWithImageDetails(vis trivy.ImageVisibili return err } - req, _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { + _, err = cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { in := obj.(*api.ImageScanRequest) in.Status.Image.Visibility = vis in.Status.Image.Name = img.Name @@ -57,28 +53,20 @@ func (r *RequestReconciler) updateStatusWithImageDetails(vis trivy.ImageVisibili in.Status.Phase = api.ImageScanRequestPhaseInProgress return in }) - if err != nil { - return err - } - r.req = req.(*api.ImageScanRequest) - return nil + return err } func (r *RequestReconciler) updateStatusWithJobName(jobName string) error { - req, _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { + _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { in := obj.(*api.ImageScanRequest) in.Status.JobName = jobName return in }) - if err != nil { - return err - } - r.req = req.(*api.ImageScanRequest) - return nil + return err } func (r *RequestReconciler) updateStatusAsReportEnsured(rep *api.ImageScanReport) error { - req, _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { + _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { in := obj.(*api.ImageScanRequest) if in.Status.Image.Digest == "" { in.Status.Image.Digest = rep.Spec.Image.Digest @@ -89,15 +77,11 @@ func (r *RequestReconciler) updateStatusAsReportEnsured(rep *api.ImageScanReport in.Status.Phase = api.ImageScanRequestPhaseCurrent return in }) - if err != nil { - return err - } - r.req = req.(*api.ImageScanRequest) - return nil + return err } func (r *RequestReconciler) updateStatusAsReportAlreadyExists(isrp *api.ImageScanReport) error { - req, _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { + _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { in := obj.(*api.ImageScanRequest) in.Status.ReportRef = &api.ScanReportRef{ Name: isrp.Name, @@ -111,25 +95,17 @@ func (r *RequestReconciler) updateStatusAsReportAlreadyExists(isrp *api.ImageSca in.Status.Phase = api.ImageScanRequestPhaseCurrent return in }) - if err != nil { - return err - } - r.req = req.(*api.ImageScanRequest) - return nil + return err } func (r *RequestReconciler) updateStatusAsFailed(msg string) error { - req, _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { + _, err := cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { in := obj.(*api.ImageScanRequest) in.Status.Phase = api.ImageScanRequestPhaseFailed in.Status.Reason = msg return in }) - if err != nil { - return err - } - r.req = req.(*api.ImageScanRequest) - return nil + return err } func (r *RequestReconciler) updateStatusWithReportDetails() error { @@ -146,7 +122,7 @@ func (r *RequestReconciler) updateStatusWithReportDetails() error { return err } - _, _, err = cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { + _, err = cu.PatchStatus(r.ctx, r.Client, r.req, func(obj client.Object) client.Object { in := obj.(*api.ImageScanRequest) in.Status.ReportRef = &api.ScanReportRef{ Name: rep.Name, diff --git a/vendor/github.com/Masterminds/sprig/v3/README.md b/vendor/github.com/Masterminds/sprig/v3/README.md index c37ba01c..db0f8cf7 100644 --- a/vendor/github.com/Masterminds/sprig/v3/README.md +++ b/vendor/github.com/Masterminds/sprig/v3/README.md @@ -17,10 +17,9 @@ JavaScript libraries, such as [underscore.js](http://underscorejs.org/). ## IMPORTANT NOTES Sprig leverages [mergo](https://github.com/imdario/mergo) to handle merges. In -its v0.3.9 release there was a behavior change that impacts merging template -functions in sprig. It is currently recommended to use v0.3.8 of that package. -Using v0.3.9 will cause sprig tests to fail. The issue in mergo is tracked at -https://github.com/imdario/mergo/issues/139. +its v0.3.9 release, there was a behavior change that impacts merging template +functions in sprig. It is currently recommended to use v0.3.10 or later of that package. +Using v0.3.9 will cause sprig tests to fail. ## Package Versions diff --git a/vendor/github.com/Masterminds/sprig/v3/crypto.go b/vendor/github.com/Masterminds/sprig/v3/crypto.go index 13a5cd55..98f7660c 100644 --- a/vendor/github.com/Masterminds/sprig/v3/crypto.go +++ b/vendor/github.com/Masterminds/sprig/v3/crypto.go @@ -27,9 +27,8 @@ import ( "io" "math/big" "net" - "time" - "strings" + "time" "github.com/google/uuid" bcrypt_lib "golang.org/x/crypto/bcrypt" @@ -84,11 +83,13 @@ var masterPasswordSeed = "com.lyndir.masterpassword" var passwordTypeTemplates = map[string][][]byte{ "maximum": {[]byte("anoxxxxxxxxxxxxxxxxx"), []byte("axxxxxxxxxxxxxxxxxno")}, - "long": {[]byte("CvcvnoCvcvCvcv"), []byte("CvcvCvcvnoCvcv"), []byte("CvcvCvcvCvcvno"), []byte("CvccnoCvcvCvcv"), []byte("CvccCvcvnoCvcv"), + "long": { + []byte("CvcvnoCvcvCvcv"), []byte("CvcvCvcvnoCvcv"), []byte("CvcvCvcvCvcvno"), []byte("CvccnoCvcvCvcv"), []byte("CvccCvcvnoCvcv"), []byte("CvccCvcvCvcvno"), []byte("CvcvnoCvccCvcv"), []byte("CvcvCvccnoCvcv"), []byte("CvcvCvccCvcvno"), []byte("CvcvnoCvcvCvcc"), []byte("CvcvCvcvnoCvcc"), []byte("CvcvCvcvCvccno"), []byte("CvccnoCvccCvcv"), []byte("CvccCvccnoCvcv"), []byte("CvccCvccCvcvno"), []byte("CvcvnoCvccCvcc"), []byte("CvcvCvccnoCvcc"), []byte("CvcvCvccCvccno"), []byte("CvccnoCvcvCvcc"), []byte("CvccCvcvnoCvcc"), - []byte("CvccCvcvCvccno")}, + []byte("CvccCvcvCvccno"), + }, "medium": {[]byte("CvcnoCvc"), []byte("CvcCvcno")}, "short": {[]byte("Cvcn")}, "basic": {[]byte("aaanaaan"), []byte("aannaaan"), []byte("aaannaaa")}, @@ -108,7 +109,7 @@ var templateCharacters = map[byte]string{ } func derivePassword(counter uint32, passwordType, password, user, site string) string { - var templates = passwordTypeTemplates[passwordType] + templates := passwordTypeTemplates[passwordType] if templates == nil { return fmt.Sprintf("cannot find password template %s", passwordType) } @@ -129,10 +130,10 @@ func derivePassword(counter uint32, passwordType, password, user, site string) s buffer.WriteString(site) binary.Write(&buffer, binary.BigEndian, counter) - var hmacv = hmac.New(sha256.New, key) + hmacv := hmac.New(sha256.New, key) hmacv.Write(buffer.Bytes()) - var seed = hmacv.Sum(nil) - var temp = templates[int(seed[0])%len(templates)] + seed := hmacv.Sum(nil) + temp := templates[int(seed[0])%len(templates)] buffer.Truncate(0) for i, element := range temp { diff --git a/vendor/github.com/Masterminds/sprig/v3/date.go b/vendor/github.com/Masterminds/sprig/v3/date.go index ed022dda..7386b7e2 100644 --- a/vendor/github.com/Masterminds/sprig/v3/date.go +++ b/vendor/github.com/Masterminds/sprig/v3/date.go @@ -138,13 +138,20 @@ func durationRound(duration interface{}) string { return "0s" } -func toDate(fmt, str string) time.Time { - t, _ := time.ParseInLocation(fmt, str, time.Local) - return t +func toDate(fmt string, str interface{}) time.Time { + output, _ := mustToDate(fmt, str) + return output } -func mustToDate(fmt, str string) (time.Time, error) { - return time.ParseInLocation(fmt, str, time.Local) +func mustToDate(fmt string, str interface{}) (time.Time, error) { + if str == nil { + return time.Time{}, nil + } + s, ok := str.(string) + if !ok || s == "" { + return time.Time{}, nil + } + return time.ParseInLocation(fmt, s, time.Local) } func unixEpoch(date time.Time) string { diff --git a/vendor/github.com/Masterminds/sprig/v3/defaults.go b/vendor/github.com/Masterminds/sprig/v3/defaults.go index b9f97966..35aa509a 100644 --- a/vendor/github.com/Masterminds/sprig/v3/defaults.go +++ b/vendor/github.com/Masterminds/sprig/v3/defaults.go @@ -24,7 +24,6 @@ func init() { // // For everything else, including pointers, a nil value is unset. func dfault(d interface{}, given ...interface{}) interface{} { - if empty(given) || empty(given[0]) { return d } @@ -134,11 +133,8 @@ func mustToPrettyJson(v interface{}) (string, error) { // toRawJson encodes an item into a JSON string with no escaping of HTML characters. func toRawJson(v interface{}) string { - output, err := mustToRawJson(v) - if err != nil { - panic(err) - } - return string(output) + output, _ := mustToRawJson(v) + return output } // mustToRawJson encodes an item into a JSON string with no escaping of HTML characters. diff --git a/vendor/github.com/Masterminds/sprig/v3/dict.go b/vendor/github.com/Masterminds/sprig/v3/dict.go index ade88969..93a93fc6 100644 --- a/vendor/github.com/Masterminds/sprig/v3/dict.go +++ b/vendor/github.com/Masterminds/sprig/v3/dict.go @@ -1,8 +1,8 @@ package sprig import ( - "github.com/imdario/mergo" "github.com/mitchellh/copystructure" + "gomodules.xyz/mergo" ) func get(d map[string]interface{}, key string) interface{} { @@ -162,9 +162,9 @@ func dig(ps ...interface{}) (interface{}, error) { } func digFromDict(dict map[string]interface{}, d interface{}, ks []string) (interface{}, error) { - k, ns := ks[0], ks[1:len(ks)] + k, ns := ks[0], ks[1:] step, has := dict[k] - if !has { + if !has || step == nil { return d, nil } if len(ns) == 0 { diff --git a/vendor/github.com/Masterminds/sprig/v3/functions.go b/vendor/github.com/Masterminds/sprig/v3/functions.go index 57fcec1d..9f4d534b 100644 --- a/vendor/github.com/Masterminds/sprig/v3/functions.go +++ b/vendor/github.com/Masterminds/sprig/v3/functions.go @@ -14,6 +14,7 @@ import ( "time" util "github.com/Masterminds/goutils" + "github.com/dustin/go-humanize" "github.com/huandu/xstrings" "github.com/shopspring/decimal" ) @@ -336,20 +337,20 @@ var genericMap = map[string]interface{}{ "mustChunk": mustChunk, // Crypto: - "bcrypt": bcrypt, - "htpasswd": htpasswd, - "genPrivateKey": generatePrivateKey, - "derivePassword": derivePassword, - "buildCustomCert": buildCustomCertificate, - "genCA": generateCertificateAuthority, - "genCAWithKey": generateCertificateAuthorityWithPEMKey, - "genSelfSignedCert": generateSelfSignedCertificate, + "bcrypt": bcrypt, + "htpasswd": htpasswd, + "genPrivateKey": generatePrivateKey, + "derivePassword": derivePassword, + "buildCustomCert": buildCustomCertificate, + "genCA": generateCertificateAuthority, + "genCAWithKey": generateCertificateAuthorityWithPEMKey, + "genSelfSignedCert": generateSelfSignedCertificate, "genSelfSignedCertWithKey": generateSelfSignedCertificateWithPEMKey, - "genSignedCert": generateSignedCertificate, - "genSignedCertWithKey": generateSignedCertificateWithPEMKey, - "encryptAES": encryptAES, - "decryptAES": decryptAES, - "randBytes": randBytes, + "genSignedCert": generateSignedCertificate, + "genSignedCertWithKey": generateSignedCertificateWithPEMKey, + "encryptAES": encryptAES, + "decryptAES": decryptAES, + "randBytes": randBytes, // UUIDs: "uuidv4": uuidv4, @@ -379,4 +380,20 @@ var genericMap = map[string]interface{}{ // URLs: "urlParse": urlParse, "urlJoin": urlJoin, + + // json path: + "jp": jsonpathFn, + + // humanize: + "toBytes": toBytes, + "mustToBytes": mustToBytes, + "toIBytes": toIBytes, + "mustToIBytes": mustToIBytes, + "ordinal": humanize.Ordinal, + "fromBytes": humanize.ParseBytes, + "toComma": toComma, + "mustToComma": mustToComma, + "ftoa": humanize.Ftoa, + "formatNumber": formatNumber, + "mustFormatNumber": mustFormatNumber, } diff --git a/vendor/github.com/Masterminds/sprig/v3/humanize.go b/vendor/github.com/Masterminds/sprig/v3/humanize.go new file mode 100644 index 00000000..f57573fd --- /dev/null +++ b/vendor/github.com/Masterminds/sprig/v3/humanize.go @@ -0,0 +1,198 @@ +package sprig + +import ( + "encoding/json" + "fmt" + "math" + "strconv" + + "github.com/dustin/go-humanize" +) + +func toBytes(v interface{}) string { + s, _ := mustToBytes(v) + return s +} + +func mustToBytes(v interface{}) (string, error) { + switch n := v.(type) { + case json.Number: + if i, err := n.Int64(); err == nil { + return humanize.Bytes(uint64(i)), nil + } + // Return a float64 (default json.Decode() behavior) + // An overflow will return an error + if f, err := n.Float64(); err != nil { + return "", err + } else { + return humanize.Bytes(uint64(math.Round(f))), nil + } + case string: + if n == "" { + return "", nil + } else if i, err := strconv.ParseInt(n, 10, 64); err == nil { + return humanize.Bytes(uint64(i)), nil + } + // Return a float64 (default json.Decode() behavior) + // An overflow will return an error + if f, err := strconv.ParseFloat(n, 64); err != nil { + return "", err + } else { + return humanize.Bytes(uint64(math.Round(f))), nil + } + case int32: + return humanize.Bytes(uint64(n)), nil + case int64: + return humanize.Bytes(uint64(n)), nil + case int: + return humanize.Bytes(uint64(n)), nil + case float32: + return humanize.Bytes(uint64(math.Round(float64(n)))), nil + case float64: + return humanize.Bytes(uint64(math.Round(n))), nil + case nil: + return "", nil + } + return "", fmt.Errorf("unknown %T with value %v", v, v) +} + +func toIBytes(v interface{}) string { + s, _ := mustToIBytes(v) + return s +} + +func mustToIBytes(v interface{}) (string, error) { + switch n := v.(type) { + case json.Number: + if i, err := n.Int64(); err == nil { + return humanize.IBytes(uint64(i)), nil + } + // Return a float64 (default json.Decode() behavior) + // An overflow will return an error + if f, err := n.Float64(); err != nil { + return "", err + } else { + return humanize.IBytes(uint64(math.Round(f))), nil + } + case string: + if n == "" { + return "", nil + } else if i, err := strconv.ParseInt(n, 10, 64); err == nil { + return humanize.IBytes(uint64(i)), nil + } + // Return a float64 (default json.Decode() behavior) + // An overflow will return an error + if f, err := strconv.ParseFloat(n, 64); err != nil { + return "", err + } else { + return humanize.IBytes(uint64(math.Round(f))), nil + } + case int32: + return humanize.IBytes(uint64(n)), nil + case int64: + return humanize.IBytes(uint64(n)), nil + case int: + return humanize.IBytes(uint64(n)), nil + case float32: + return humanize.IBytes(uint64(math.Round(float64(n)))), nil + case float64: + return humanize.IBytes(uint64(math.Round(n))), nil + case nil: + return "", nil + } + return "", fmt.Errorf("unknown %T with value %v", v, v) +} + +func toComma(v interface{}) string { + s, _ := mustToComma(v) + return s +} + +func mustToComma(v interface{}) (string, error) { + switch n := v.(type) { + case json.Number: + if i, err := n.Int64(); err == nil { + return humanize.Comma(i), nil + } + // Return a float64 (default json.Decode() behavior) + // An overflow will return an error + if f, err := n.Float64(); err != nil { + return "", err + } else { + return humanize.Commaf(f), nil + } + case string: + if n == "" { + return "", nil + } else if i, err := strconv.ParseInt(n, 10, 64); err == nil { + return humanize.Comma(i), nil + } + // Return a float64 (default json.Decode() behavior) + // An overflow will return an error + if f, err := strconv.ParseFloat(n, 64); err != nil { + return "", err + } else { + return humanize.Commaf(f), nil + } + case int32: + return humanize.Comma(int64(n)), nil + case int64: + return humanize.Comma(n), nil + case int: + return humanize.Comma(int64(n)), nil + case float32: + return humanize.Commaf(float64(n)), nil + case float64: + return humanize.Commaf(n), nil + case nil: + return "", nil + } + return "", fmt.Errorf("unknown %T with value %v", v, v) +} + +func formatNumber(format string, v interface{}) string { + s, _ := mustFormatNumber(format, v) + return s +} + +func mustFormatNumber(format string, v interface{}) (string, error) { + switch n := v.(type) { + case json.Number: + if i, err := n.Int64(); err == nil { + return humanize.FormatInteger(format, int(i)), nil + } + // Return a float64 (default json.Decode() behavior) + // An overflow will return an error + if f, err := n.Float64(); err != nil { + return "", err + } else { + return humanize.FormatFloat(format, f), nil + } + case string: + if n == "" { + return "", nil + } else if i, err := strconv.ParseInt(n, 10, 64); err == nil { + return humanize.FormatInteger(format, int(i)), nil + } + // Return a float64 (default json.Decode() behavior) + // An overflow will return an error + if f, err := strconv.ParseFloat(n, 64); err != nil { + return "", err + } else { + return humanize.FormatFloat(format, f), nil + } + case int32: + return humanize.FormatInteger(format, int(n)), nil + case int64: + return humanize.FormatInteger(format, int(n)), nil + case int: + return humanize.FormatInteger(format, n), nil + case float32: + return humanize.FormatFloat(format, float64(n)), nil + case float64: + return humanize.FormatFloat(format, n), nil + case nil: + return "", nil + } + return "", fmt.Errorf("unknown %T with value %v", v, v) +} diff --git a/vendor/github.com/Masterminds/sprig/v3/jsonpath.go b/vendor/github.com/Masterminds/sprig/v3/jsonpath.go new file mode 100644 index 00000000..6363decc --- /dev/null +++ b/vendor/github.com/Masterminds/sprig/v3/jsonpath.go @@ -0,0 +1,33 @@ +package sprig + +import ( + "bytes" + "fmt" + + "gomodules.xyz/encoding/json" + "gomodules.xyz/jsonpath" +) + +func jsonpathFn(expr string, data interface{}, jsonoutput ...bool) (interface{}, error) { + enableJSONoutput := len(jsonoutput) > 0 && jsonoutput[0] + + jp := jsonpath.New("jp") + if err := jp.Parse(expr); err != nil { + return nil, fmt.Errorf("unrecognized column definition %q", expr) + } + jp.AllowMissingKeys(true) + jp.EnableJSONOutput(enableJSONoutput) + + var buf bytes.Buffer + err := jp.Execute(&buf, data) + if err != nil { + return nil, err + } + + if enableJSONoutput { + var v []interface{} + err = json.Unmarshal(buf.Bytes(), &v) + return v, err + } + return buf.String(), err +} diff --git a/vendor/github.com/Masterminds/sprig/v3/list.go b/vendor/github.com/Masterminds/sprig/v3/list.go index ca0fbb78..90aeeb26 100644 --- a/vendor/github.com/Masterminds/sprig/v3/list.go +++ b/vendor/github.com/Masterminds/sprig/v3/list.go @@ -53,7 +53,7 @@ func prepend(list interface{}, v interface{}) []interface{} { } func mustPrepend(list interface{}, v interface{}) ([]interface{}, error) { - //return append([]interface{}{v}, list...) + // return append([]interface{}{v}, list...) tp := reflect.TypeOf(list).Kind() switch tp { diff --git a/vendor/github.com/Masterminds/sprig/v3/network.go b/vendor/github.com/Masterminds/sprig/v3/network.go index 108d78a9..d68ac6b4 100644 --- a/vendor/github.com/Masterminds/sprig/v3/network.go +++ b/vendor/github.com/Masterminds/sprig/v3/network.go @@ -7,6 +7,6 @@ import ( func getHostByName(name string) string { addrs, _ := net.LookupHost(name) - //TODO: add error handing when release v3 comes out + // TODO: add error handing when release v3 comes out return addrs[rand.Intn(len(addrs))] } diff --git a/vendor/github.com/Masterminds/sprig/v3/numeric.go b/vendor/github.com/Masterminds/sprig/v3/numeric.go index f68e4182..84fe18de 100644 --- a/vendor/github.com/Masterminds/sprig/v3/numeric.go +++ b/vendor/github.com/Masterminds/sprig/v3/numeric.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - "github.com/spf13/cast" "github.com/shopspring/decimal" + "github.com/spf13/cast" ) // toFloat64 converts 64-bit floats diff --git a/vendor/github.com/Masterminds/sprig/v3/strings.go b/vendor/github.com/Masterminds/sprig/v3/strings.go index e0ae628c..4b3f7186 100644 --- a/vendor/github.com/Masterminds/sprig/v3/strings.go +++ b/vendor/github.com/Masterminds/sprig/v3/strings.go @@ -50,6 +50,7 @@ func abbrevboth(left, right int, s string) string { r, _ := util.AbbreviateFull(s, left, right) return r } + func initials(s string) string { // Wrap this just to eliminate the var args, which templates don't do well. return util.Initials(s) diff --git a/vendor/gomodules.xyz/jsonpatch/v2/jsonpatch.go b/vendor/gomodules.xyz/jsonpatch/v2/jsonpatch.go index a411d542..0d7823b3 100644 --- a/vendor/gomodules.xyz/jsonpatch/v2/jsonpatch.go +++ b/vendor/gomodules.xyz/jsonpatch/v2/jsonpatch.go @@ -1,6 +1,7 @@ package jsonpatch import ( + "bytes" "encoding/json" "fmt" "reflect" @@ -64,6 +65,9 @@ func NewOperation(op, path string, value interface{}) Operation { // // An error will be returned if any of the two documents are invalid. func CreatePatch(a, b []byte) ([]Operation, error) { + if bytes.Equal(a, b) { + return []Operation{}, nil + } var aI interface{} var bI interface{} err := json.Unmarshal(a, &aI) diff --git a/vendor/gomodules.xyz/jsonpath/LICENSE b/vendor/gomodules.xyz/jsonpath/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/gomodules.xyz/jsonpath/README.md b/vendor/gomodules.xyz/jsonpath/README.md new file mode 100644 index 00000000..1d3a9c91 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/README.md @@ -0,0 +1,3 @@ +# jsonpath + +This repository has been forked from https://github.com/kubernetes/client-go/tree/v0.21.0/util/jsonpath diff --git a/vendor/gomodules.xyz/jsonpath/doc.go b/vendor/gomodules.xyz/jsonpath/doc.go new file mode 100644 index 00000000..2a6e1706 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2015 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// package jsonpath is a template engine using jsonpath syntax, +// which can be seen at http://goessner.net/articles/JsonPath/. +// In addition, it has {range} {end} function to iterate list and slice. +package jsonpath diff --git a/vendor/gomodules.xyz/jsonpath/jsonpath.go b/vendor/gomodules.xyz/jsonpath/jsonpath.go new file mode 100644 index 00000000..eae92142 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/jsonpath.go @@ -0,0 +1,579 @@ +/* +Copyright 2015 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package jsonpath + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "reflect" + "strings" + + "gomodules.xyz/jsonpath/third_party/forked/golang/template" +) + +type JSONPath struct { + name string + parser *Parser + beginRange int + inRange int + endRange int + + lastEndNode *Node + + allowMissingKeys bool + outputJSON bool +} + +// New creates a new JSONPath with the given name. +func New(name string) *JSONPath { + return &JSONPath{ + name: name, + beginRange: 0, + inRange: 0, + endRange: 0, + } +} + +// AllowMissingKeys allows a caller to specify whether they want an error if a field or map key +// cannot be located, or simply an empty result. The receiver is returned for chaining. +func (j *JSONPath) AllowMissingKeys(allow bool) *JSONPath { + j.allowMissingKeys = allow + return j +} + +// Parse parses the given template and returns an error. +func (j *JSONPath) Parse(text string) error { + var err error + j.parser, err = Parse(j.name, text) + return err +} + +// Execute bounds data into template and writes the result. +func (j *JSONPath) Execute(wr io.Writer, data interface{}) error { + fullResults, err := j.FindResults(data) + if err != nil { + return err + } + for ix := range fullResults { + if err := j.PrintResults(wr, fullResults[ix]); err != nil { + return err + } + } + return nil +} + +func (j *JSONPath) FindResults(data interface{}) ([][]reflect.Value, error) { + if j.parser == nil { + return nil, fmt.Errorf("%s is an incomplete jsonpath template", j.name) + } + + cur := []reflect.Value{reflect.ValueOf(data)} + nodes := j.parser.Root.Nodes + fullResult := [][]reflect.Value{} + for i := 0; i < len(nodes); i++ { + node := nodes[i] + results, err := j.walk(cur, node) + if err != nil { + return nil, err + } + + // encounter an end node, break the current block + if j.endRange > 0 && j.endRange <= j.inRange { + j.endRange-- + j.lastEndNode = &nodes[i] + break + } + // encounter a range node, start a range loop + if j.beginRange > 0 { + j.beginRange-- + j.inRange++ + if len(results) > 0 { + for _, value := range results { + j.parser.Root.Nodes = nodes[i+1:] + nextResults, err := j.FindResults(value.Interface()) + if err != nil { + return nil, err + } + fullResult = append(fullResult, nextResults...) + } + } else { + // If the range has no results, we still need to process the nodes within the range + // so the position will advance to the end node + j.parser.Root.Nodes = nodes[i+1:] + _, err := j.FindResults(nil) + if err != nil { + return nil, err + } + } + j.inRange-- + + // Fast forward to resume processing after the most recent end node that was encountered + for k := i + 1; k < len(nodes); k++ { + if &nodes[k] == j.lastEndNode { + i = k + break + } + } + continue + } + fullResult = append(fullResult, results) + } + return fullResult, nil +} + +// EnableJSONOutput changes the PrintResults behavior to return a JSON array of results +func (j *JSONPath) EnableJSONOutput(v bool) { + j.outputJSON = v +} + +// PrintResults writes the results into writer +func (j *JSONPath) PrintResults(wr io.Writer, results []reflect.Value) error { + if j.outputJSON { + // convert the []reflect.Value to something that json + // will be able to marshal + r := make([]interface{}, 0, len(results)) + for i := range results { + r = append(r, results[i].Interface()) + } + results = []reflect.Value{reflect.ValueOf(r)} + } + for i, r := range results { + var text []byte + var err error + outputJSON := true + kind := r.Kind() + if kind == reflect.Interface { + kind = r.Elem().Kind() + } + switch kind { + case reflect.Map: + case reflect.Array: + case reflect.Slice: + case reflect.Struct: + default: + outputJSON = false + } + switch { + case outputJSON || j.outputJSON: + if j.outputJSON { + text, err = json.MarshalIndent(r.Interface(), "", " ") + text = append(text, '\n') + } else { + text, err = json.Marshal(r.Interface()) + } + default: + text, err = j.evalToText(r) + } + if err != nil { + return err + } + if i != len(results)-1 { + text = append(text, ' ') + } + if _, err = wr.Write(text); err != nil { + return err + } + } + + return nil + +} + +// walk visits tree rooted at the given node in DFS order +func (j *JSONPath) walk(value []reflect.Value, node Node) ([]reflect.Value, error) { + switch node := node.(type) { + case *ListNode: + return j.evalList(value, node) + case *TextNode: + return []reflect.Value{reflect.ValueOf(node.Text)}, nil + case *FieldNode: + return j.evalField(value, node) + case *ArrayNode: + return j.evalArray(value, node) + case *FilterNode: + return j.evalFilter(value, node) + case *IntNode: + return j.evalInt(value, node) + case *BoolNode: + return j.evalBool(value, node) + case *FloatNode: + return j.evalFloat(value, node) + case *WildcardNode: + return j.evalWildcard(value, node) + case *RecursiveNode: + return j.evalRecursive(value, node) + case *UnionNode: + return j.evalUnion(value, node) + case *IdentifierNode: + return j.evalIdentifier(value, node) + default: + return value, fmt.Errorf("unexpected Node %v", node) + } +} + +// evalInt evaluates IntNode +func (j *JSONPath) evalInt(input []reflect.Value, node *IntNode) ([]reflect.Value, error) { + result := make([]reflect.Value, len(input)) + for i := range input { + result[i] = reflect.ValueOf(node.Value) + } + return result, nil +} + +// evalFloat evaluates FloatNode +func (j *JSONPath) evalFloat(input []reflect.Value, node *FloatNode) ([]reflect.Value, error) { + result := make([]reflect.Value, len(input)) + for i := range input { + result[i] = reflect.ValueOf(node.Value) + } + return result, nil +} + +// evalBool evaluates BoolNode +func (j *JSONPath) evalBool(input []reflect.Value, node *BoolNode) ([]reflect.Value, error) { + result := make([]reflect.Value, len(input)) + for i := range input { + result[i] = reflect.ValueOf(node.Value) + } + return result, nil +} + +// evalList evaluates ListNode +func (j *JSONPath) evalList(value []reflect.Value, node *ListNode) ([]reflect.Value, error) { + var err error + curValue := value + for _, node := range node.Nodes { + curValue, err = j.walk(curValue, node) + if err != nil { + return curValue, err + } + } + return curValue, nil +} + +// evalIdentifier evaluates IdentifierNode +func (j *JSONPath) evalIdentifier(input []reflect.Value, node *IdentifierNode) ([]reflect.Value, error) { + results := []reflect.Value{} + switch node.Name { + case "range": + j.beginRange++ + results = input + case "end": + if j.inRange > 0 { + j.endRange++ + } else { + return results, fmt.Errorf("not in range, nothing to end") + } + default: + return input, fmt.Errorf("unrecognized identifier %v", node.Name) + } + return results, nil +} + +// evalArray evaluates ArrayNode +func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect.Value, error) { + result := []reflect.Value{} + for _, value := range input { + + value, isNil := template.Indirect(value) + if isNil { + continue + } + if value.Kind() != reflect.Array && value.Kind() != reflect.Slice { + return input, fmt.Errorf("%v is not array or slice", value.Type()) + } + params := node.Params + if !params[0].Known { + params[0].Value = 0 + } + if params[0].Value < 0 { + params[0].Value += value.Len() + } + if !params[1].Known { + params[1].Value = value.Len() + } + + if params[1].Value < 0 || (params[1].Value == 0 && params[1].Derived) { + params[1].Value += value.Len() + } + sliceLength := value.Len() + if params[1].Value != params[0].Value { // if you're requesting zero elements, allow it through. + if params[0].Value >= sliceLength || params[0].Value < 0 { + return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[0].Value, sliceLength) + } + if params[1].Value > sliceLength || params[1].Value < 0 { + return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[1].Value-1, sliceLength) + } + if params[0].Value > params[1].Value { + return input, fmt.Errorf("starting index %d is greater than ending index %d", params[0].Value, params[1].Value) + } + } else { + return result, nil + } + + value = value.Slice(params[0].Value, params[1].Value) + + step := 1 + if params[2].Known { + if params[2].Value <= 0 { + return input, fmt.Errorf("step must be > 0") + } + step = params[2].Value + } + for i := 0; i < value.Len(); i += step { + result = append(result, value.Index(i)) + } + } + return result, nil +} + +// evalUnion evaluates UnionNode +func (j *JSONPath) evalUnion(input []reflect.Value, node *UnionNode) ([]reflect.Value, error) { + result := []reflect.Value{} + for _, listNode := range node.Nodes { + temp, err := j.evalList(input, listNode) + if err != nil { + return input, err + } + result = append(result, temp...) + } + return result, nil +} + +func (j *JSONPath) findFieldInValue(value *reflect.Value, node *FieldNode) (reflect.Value, error) { + t := value.Type() + var inlineValue *reflect.Value + for ix := 0; ix < t.NumField(); ix++ { + f := t.Field(ix) + jsonTag := f.Tag.Get("json") + parts := strings.Split(jsonTag, ",") + if len(parts) == 0 { + continue + } + if parts[0] == node.Value { + return value.Field(ix), nil + } + if len(parts[0]) == 0 { + val := value.Field(ix) + inlineValue = &val + } + } + if inlineValue != nil { + if inlineValue.Kind() == reflect.Struct { + // handle 'inline' + match, err := j.findFieldInValue(inlineValue, node) + if err != nil { + return reflect.Value{}, err + } + if match.IsValid() { + return match, nil + } + } + } + return value.FieldByName(node.Value), nil +} + +// evalField evaluates field of struct or key of map. +func (j *JSONPath) evalField(input []reflect.Value, node *FieldNode) ([]reflect.Value, error) { + results := []reflect.Value{} + // If there's no input, there's no output + if len(input) == 0 { + return results, nil + } + for _, value := range input { + var result reflect.Value + value, isNil := template.Indirect(value) + if isNil { + continue + } + + if value.Kind() == reflect.Struct { + var err error + if result, err = j.findFieldInValue(&value, node); err != nil { + return nil, err + } + } else if value.Kind() == reflect.Map { + mapKeyType := value.Type().Key() + nodeValue := reflect.ValueOf(node.Value) + // node value type must be convertible to map key type + if !nodeValue.Type().ConvertibleTo(mapKeyType) { + return results, fmt.Errorf("%s is not convertible to %s", nodeValue, mapKeyType) + } + result = value.MapIndex(nodeValue.Convert(mapKeyType)) + } + if result.IsValid() { + results = append(results, result) + } + } + if len(results) == 0 { + if j.allowMissingKeys { + return results, nil + } + return results, fmt.Errorf("%s is not found", node.Value) + } + return results, nil +} + +// evalWildcard extracts all contents of the given value +func (j *JSONPath) evalWildcard(input []reflect.Value, node *WildcardNode) ([]reflect.Value, error) { + results := []reflect.Value{} + for _, value := range input { + value, isNil := template.Indirect(value) + if isNil { + continue + } + + kind := value.Kind() + if kind == reflect.Struct { + for i := 0; i < value.NumField(); i++ { + results = append(results, value.Field(i)) + } + } else if kind == reflect.Map { + for _, key := range value.MapKeys() { + results = append(results, value.MapIndex(key)) + } + } else if kind == reflect.Array || kind == reflect.Slice || kind == reflect.String { + for i := 0; i < value.Len(); i++ { + results = append(results, value.Index(i)) + } + } + } + return results, nil +} + +// evalRecursive visits the given value recursively and pushes all of them to result +func (j *JSONPath) evalRecursive(input []reflect.Value, node *RecursiveNode) ([]reflect.Value, error) { + result := []reflect.Value{} + for _, value := range input { + results := []reflect.Value{} + value, isNil := template.Indirect(value) + if isNil { + continue + } + + kind := value.Kind() + if kind == reflect.Struct { + for i := 0; i < value.NumField(); i++ { + results = append(results, value.Field(i)) + } + } else if kind == reflect.Map { + for _, key := range value.MapKeys() { + results = append(results, value.MapIndex(key)) + } + } else if kind == reflect.Array || kind == reflect.Slice || kind == reflect.String { + for i := 0; i < value.Len(); i++ { + results = append(results, value.Index(i)) + } + } + if len(results) != 0 { + result = append(result, value) + output, err := j.evalRecursive(results, node) + if err != nil { + return result, err + } + result = append(result, output...) + } + } + return result, nil +} + +// evalFilter filters array according to FilterNode +func (j *JSONPath) evalFilter(input []reflect.Value, node *FilterNode) ([]reflect.Value, error) { + results := []reflect.Value{} + for _, value := range input { + value, _ = template.Indirect(value) + + if value.Kind() != reflect.Array && value.Kind() != reflect.Slice { + return input, fmt.Errorf("%v is not array or slice and cannot be filtered", value) + } + for i := 0; i < value.Len(); i++ { + temp := []reflect.Value{value.Index(i)} + lefts, err := j.evalList(temp, node.Left) + + //case exists + if node.Operator == "exists" { + if len(lefts) > 0 { + results = append(results, value.Index(i)) + } + continue + } + + if err != nil { + return input, err + } + + var left, right interface{} + switch { + case len(lefts) == 0: + continue + case len(lefts) > 1: + return input, fmt.Errorf("can only compare one element at a time") + } + left = lefts[0].Interface() + + rights, err := j.evalList(temp, node.Right) + if err != nil { + return input, err + } + switch { + case len(rights) == 0: + continue + case len(rights) > 1: + return input, fmt.Errorf("can only compare one element at a time") + } + right = rights[0].Interface() + + pass := false + switch node.Operator { + case "<": + pass, err = template.Less(left, right) + case ">": + pass, err = template.Greater(left, right) + case "==": + pass, err = template.Equal(left, right) + case "!=": + pass, err = template.NotEqual(left, right) + case "<=": + pass, err = template.LessEqual(left, right) + case ">=": + pass, err = template.GreaterEqual(left, right) + default: + return results, fmt.Errorf("unrecognized filter operator %s", node.Operator) + } + if err != nil { + return results, err + } + if pass { + results = append(results, value.Index(i)) + } + } + } + return results, nil +} + +// evalToText translates reflect value to corresponding text +func (j *JSONPath) evalToText(v reflect.Value) ([]byte, error) { + iface, ok := template.PrintableValue(v) + if !ok { + return nil, fmt.Errorf("can't print type %s", v.Type()) + } + var buffer bytes.Buffer + fmt.Fprint(&buffer, iface) + return buffer.Bytes(), nil +} diff --git a/vendor/gomodules.xyz/jsonpath/node.go b/vendor/gomodules.xyz/jsonpath/node.go new file mode 100644 index 00000000..83abe8b0 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/node.go @@ -0,0 +1,256 @@ +/* +Copyright 2015 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package jsonpath + +import "fmt" + +// NodeType identifies the type of a parse tree node. +type NodeType int + +// Type returns itself and provides an easy default implementation +func (t NodeType) Type() NodeType { + return t +} + +func (t NodeType) String() string { + return NodeTypeName[t] +} + +const ( + NodeText NodeType = iota + NodeArray + NodeList + NodeField + NodeIdentifier + NodeFilter + NodeInt + NodeFloat + NodeWildcard + NodeRecursive + NodeUnion + NodeBool +) + +var NodeTypeName = map[NodeType]string{ + NodeText: "NodeText", + NodeArray: "NodeArray", + NodeList: "NodeList", + NodeField: "NodeField", + NodeIdentifier: "NodeIdentifier", + NodeFilter: "NodeFilter", + NodeInt: "NodeInt", + NodeFloat: "NodeFloat", + NodeWildcard: "NodeWildcard", + NodeRecursive: "NodeRecursive", + NodeUnion: "NodeUnion", + NodeBool: "NodeBool", +} + +type Node interface { + Type() NodeType + String() string +} + +// ListNode holds a sequence of nodes. +type ListNode struct { + NodeType + Nodes []Node // The element nodes in lexical order. +} + +func newList() *ListNode { + return &ListNode{NodeType: NodeList} +} + +func (l *ListNode) append(n Node) { + l.Nodes = append(l.Nodes, n) +} + +func (l *ListNode) String() string { + return l.Type().String() +} + +// TextNode holds plain text. +type TextNode struct { + NodeType + Text string // The text; may span newlines. +} + +func newText(text string) *TextNode { + return &TextNode{NodeType: NodeText, Text: text} +} + +func (t *TextNode) String() string { + return fmt.Sprintf("%s: %s", t.Type(), t.Text) +} + +// FieldNode holds field of struct +type FieldNode struct { + NodeType + Value string +} + +func newField(value string) *FieldNode { + return &FieldNode{NodeType: NodeField, Value: value} +} + +func (f *FieldNode) String() string { + return fmt.Sprintf("%s: %s", f.Type(), f.Value) +} + +// IdentifierNode holds an identifier +type IdentifierNode struct { + NodeType + Name string +} + +func newIdentifier(value string) *IdentifierNode { + return &IdentifierNode{ + NodeType: NodeIdentifier, + Name: value, + } +} + +func (f *IdentifierNode) String() string { + return fmt.Sprintf("%s: %s", f.Type(), f.Name) +} + +// ParamsEntry holds param information for ArrayNode +type ParamsEntry struct { + Value int + Known bool // whether the value is known when parse it + Derived bool +} + +// ArrayNode holds start, end, step information for array index selection +type ArrayNode struct { + NodeType + Params [3]ParamsEntry // start, end, step +} + +func newArray(params [3]ParamsEntry) *ArrayNode { + return &ArrayNode{ + NodeType: NodeArray, + Params: params, + } +} + +func (a *ArrayNode) String() string { + return fmt.Sprintf("%s: %v", a.Type(), a.Params) +} + +// FilterNode holds operand and operator information for filter +type FilterNode struct { + NodeType + Left *ListNode + Right *ListNode + Operator string +} + +func newFilter(left, right *ListNode, operator string) *FilterNode { + return &FilterNode{ + NodeType: NodeFilter, + Left: left, + Right: right, + Operator: operator, + } +} + +func (f *FilterNode) String() string { + return fmt.Sprintf("%s: %s %s %s", f.Type(), f.Left, f.Operator, f.Right) +} + +// IntNode holds integer value +type IntNode struct { + NodeType + Value int +} + +func newInt(num int) *IntNode { + return &IntNode{NodeType: NodeInt, Value: num} +} + +func (i *IntNode) String() string { + return fmt.Sprintf("%s: %d", i.Type(), i.Value) +} + +// FloatNode holds float value +type FloatNode struct { + NodeType + Value float64 +} + +func newFloat(num float64) *FloatNode { + return &FloatNode{NodeType: NodeFloat, Value: num} +} + +func (i *FloatNode) String() string { + return fmt.Sprintf("%s: %f", i.Type(), i.Value) +} + +// WildcardNode means a wildcard +type WildcardNode struct { + NodeType +} + +func newWildcard() *WildcardNode { + return &WildcardNode{NodeType: NodeWildcard} +} + +func (i *WildcardNode) String() string { + return i.Type().String() +} + +// RecursiveNode means a recursive descent operator +type RecursiveNode struct { + NodeType +} + +func newRecursive() *RecursiveNode { + return &RecursiveNode{NodeType: NodeRecursive} +} + +func (r *RecursiveNode) String() string { + return r.Type().String() +} + +// UnionNode is union of ListNode +type UnionNode struct { + NodeType + Nodes []*ListNode +} + +func newUnion(nodes []*ListNode) *UnionNode { + return &UnionNode{NodeType: NodeUnion, Nodes: nodes} +} + +func (u *UnionNode) String() string { + return u.Type().String() +} + +// BoolNode holds bool value +type BoolNode struct { + NodeType + Value bool +} + +func newBool(value bool) *BoolNode { + return &BoolNode{NodeType: NodeBool, Value: value} +} + +func (b *BoolNode) String() string { + return fmt.Sprintf("%s: %t", b.Type(), b.Value) +} diff --git a/vendor/gomodules.xyz/jsonpath/parser.go b/vendor/gomodules.xyz/jsonpath/parser.go new file mode 100644 index 00000000..b84016a9 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/parser.go @@ -0,0 +1,527 @@ +/* +Copyright 2015 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package jsonpath + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "strings" + "unicode" + "unicode/utf8" +) + +const eof = -1 + +const ( + leftDelim = "{" + rightDelim = "}" +) + +type Parser struct { + Name string + Root *ListNode + input string + pos int + start int + width int +} + +var ( + ErrSyntax = errors.New("invalid syntax") + dictKeyRex = regexp.MustCompile(`^'([^']*)'$`) + sliceOperatorRex = regexp.MustCompile(`^(-?[\d]*)(:-?[\d]*)?(:-?[\d]*)?$`) +) + +// Parse parsed the given text and return a node Parser. +// If an error is encountered, parsing stops and an empty +// Parser is returned with the error +func Parse(name, text string) (*Parser, error) { + p := NewParser(name) + err := p.Parse(text) + if err != nil { + p = nil + } + return p, err +} + +func NewParser(name string) *Parser { + return &Parser{ + Name: name, + } +} + +// parseAction parsed the expression inside delimiter +func parseAction(name, text string) (*Parser, error) { + p, err := Parse(name, fmt.Sprintf("%s%s%s", leftDelim, text, rightDelim)) + // when error happens, p will be nil, so we need to return here + if err != nil { + return p, err + } + p.Root = p.Root.Nodes[0].(*ListNode) + return p, nil +} + +func (p *Parser) Parse(text string) error { + p.input = text + p.Root = newList() + p.pos = 0 + return p.parseText(p.Root) +} + +// consumeText return the parsed text since last cosumeText +func (p *Parser) consumeText() string { + value := p.input[p.start:p.pos] + p.start = p.pos + return value +} + +// next returns the next rune in the input. +func (p *Parser) next() rune { + if p.pos >= len(p.input) { + p.width = 0 + return eof + } + r, w := utf8.DecodeRuneInString(p.input[p.pos:]) + p.width = w + p.pos += p.width + return r +} + +// peek returns but does not consume the next rune in the input. +func (p *Parser) peek() rune { + r := p.next() + p.backup() + return r +} + +// backup steps back one rune. Can only be called once per call of next. +func (p *Parser) backup() { + p.pos -= p.width +} + +func (p *Parser) parseText(cur *ListNode) error { + for { + if strings.HasPrefix(p.input[p.pos:], leftDelim) { + if p.pos > p.start { + cur.append(newText(p.consumeText())) + } + return p.parseLeftDelim(cur) + } + if p.next() == eof { + break + } + } + // Correctly reached EOF. + if p.pos > p.start { + cur.append(newText(p.consumeText())) + } + return nil +} + +// parseLeftDelim scans the left delimiter, which is known to be present. +func (p *Parser) parseLeftDelim(cur *ListNode) error { + p.pos += len(leftDelim) + p.consumeText() + newNode := newList() + cur.append(newNode) + cur = newNode + return p.parseInsideAction(cur) +} + +func (p *Parser) parseInsideAction(cur *ListNode) error { + prefixMap := map[string]func(*ListNode) error{ + rightDelim: p.parseRightDelim, + "[?(": p.parseFilter, + "..": p.parseRecursive, + } + for prefix, parseFunc := range prefixMap { + if strings.HasPrefix(p.input[p.pos:], prefix) { + return parseFunc(cur) + } + } + + switch r := p.next(); { + case r == eof || isEndOfLine(r): + return fmt.Errorf("unclosed action") + case r == ' ': + p.consumeText() + case r == '@' || r == '$': //the current object, just pass it + p.consumeText() + case r == '[': + return p.parseArray(cur) + case r == '"' || r == '\'': + return p.parseQuote(cur, r) + case r == '.': + return p.parseField(cur) + case r == '+' || r == '-' || unicode.IsDigit(r): + p.backup() + return p.parseNumber(cur) + case isAlphaNumeric(r): + p.backup() + return p.parseIdentifier(cur) + default: + return fmt.Errorf("unrecognized character in action: %#U", r) + } + return p.parseInsideAction(cur) +} + +// parseRightDelim scans the right delimiter, which is known to be present. +func (p *Parser) parseRightDelim(cur *ListNode) error { + p.pos += len(rightDelim) + p.consumeText() + return p.parseText(p.Root) +} + +// parseIdentifier scans build-in keywords, like "range" "end" +func (p *Parser) parseIdentifier(cur *ListNode) error { + var r rune + for { + r = p.next() + if isTerminator(r) { + p.backup() + break + } + } + value := p.consumeText() + + if isBool(value) { + v, err := strconv.ParseBool(value) + if err != nil { + return fmt.Errorf("can not parse bool '%s': %s", value, err.Error()) + } + + cur.append(newBool(v)) + } else { + cur.append(newIdentifier(value)) + } + + return p.parseInsideAction(cur) +} + +// parseRecursive scans the recursive descent operator .. +func (p *Parser) parseRecursive(cur *ListNode) error { + if lastIndex := len(cur.Nodes) - 1; lastIndex >= 0 && cur.Nodes[lastIndex].Type() == NodeRecursive { + return fmt.Errorf("invalid multiple recursive descent") + } + p.pos += len("..") + p.consumeText() + cur.append(newRecursive()) + if r := p.peek(); isAlphaNumeric(r) { + return p.parseField(cur) + } + return p.parseInsideAction(cur) +} + +// parseNumber scans number +func (p *Parser) parseNumber(cur *ListNode) error { + r := p.peek() + if r == '+' || r == '-' { + p.next() + } + for { + r = p.next() + if r != '.' && !unicode.IsDigit(r) { + p.backup() + break + } + } + value := p.consumeText() + i, err := strconv.Atoi(value) + if err == nil { + cur.append(newInt(i)) + return p.parseInsideAction(cur) + } + d, err := strconv.ParseFloat(value, 64) + if err == nil { + cur.append(newFloat(d)) + return p.parseInsideAction(cur) + } + return fmt.Errorf("cannot parse number %s", value) +} + +// parseArray scans array index selection +func (p *Parser) parseArray(cur *ListNode) error { +Loop: + for { + switch p.next() { + case eof, '\n': + return fmt.Errorf("unterminated array") + case ']': + break Loop + } + } + text := p.consumeText() + text = text[1 : len(text)-1] + if text == "*" { + text = ":" + } + + //union operator + strs := strings.Split(text, ",") + if len(strs) > 1 { + union := []*ListNode{} + for _, str := range strs { + parser, err := parseAction("union", fmt.Sprintf("[%s]", strings.Trim(str, " "))) + if err != nil { + return err + } + union = append(union, parser.Root) + } + cur.append(newUnion(union)) + return p.parseInsideAction(cur) + } + + // dict key + value := dictKeyRex.FindStringSubmatch(text) + if value != nil { + parser, err := parseAction("arraydict", fmt.Sprintf(".%s", value[1])) + if err != nil { + return err + } + for _, node := range parser.Root.Nodes { + cur.append(node) + } + return p.parseInsideAction(cur) + } + + //slice operator + value = sliceOperatorRex.FindStringSubmatch(text) + if value == nil { + return fmt.Errorf("invalid array index %s", text) + } + value = value[1:] + params := [3]ParamsEntry{} + for i := 0; i < 3; i++ { + if value[i] != "" { + if i > 0 { + value[i] = value[i][1:] + } + if i > 0 && value[i] == "" { + params[i].Known = false + } else { + var err error + params[i].Known = true + params[i].Value, err = strconv.Atoi(value[i]) + if err != nil { + return fmt.Errorf("array index %s is not a number", value[i]) + } + } + } else { + if i == 1 { + params[i].Known = true + params[i].Value = params[0].Value + 1 + params[i].Derived = true + } else { + params[i].Known = false + params[i].Value = 0 + } + } + } + cur.append(newArray(params)) + return p.parseInsideAction(cur) +} + +// parseFilter scans filter inside array selection +func (p *Parser) parseFilter(cur *ListNode) error { + p.pos += len("[?(") + p.consumeText() + begin := false + end := false + var pair rune + +Loop: + for { + r := p.next() + switch r { + case eof, '\n': + return fmt.Errorf("unterminated filter") + case '"', '\'': + if begin == false { + //save the paired rune + begin = true + pair = r + continue + } + //only add when met paired rune + if p.input[p.pos-2] != '\\' && r == pair { + end = true + } + case ')': + //in rightParser below quotes only appear zero or once + //and must be paired at the beginning and end + if begin == end { + break Loop + } + } + } + if p.next() != ']' { + return fmt.Errorf("unclosed array expect ]") + } + reg := regexp.MustCompile(`^([^!<>=]+)([!<>=]+)(.+?)$`) + text := p.consumeText() + text = text[:len(text)-2] + value := reg.FindStringSubmatch(text) + if value == nil { + parser, err := parseAction("text", text) + if err != nil { + return err + } + cur.append(newFilter(parser.Root, newList(), "exists")) + } else { + leftParser, err := parseAction("left", value[1]) + if err != nil { + return err + } + rightParser, err := parseAction("right", value[3]) + if err != nil { + return err + } + cur.append(newFilter(leftParser.Root, rightParser.Root, value[2])) + } + return p.parseInsideAction(cur) +} + +// parseQuote unquotes string inside double or single quote +func (p *Parser) parseQuote(cur *ListNode, end rune) error { +Loop: + for { + switch p.next() { + case eof, '\n': + return fmt.Errorf("unterminated quoted string") + case end: + //if it's not escape break the Loop + if p.input[p.pos-2] != '\\' { + break Loop + } + } + } + value := p.consumeText() + s, err := UnquoteExtend(value) + if err != nil { + return fmt.Errorf("unquote string %s error %v", value, err) + } + cur.append(newText(s)) + return p.parseInsideAction(cur) +} + +// parseField scans a field until a terminator +func (p *Parser) parseField(cur *ListNode) error { + p.consumeText() + for p.advance() { + } + value := p.consumeText() + if value == "*" { + cur.append(newWildcard()) + } else { + cur.append(newField(strings.Replace(value, "\\", "", -1))) + } + return p.parseInsideAction(cur) +} + +// advance scans until next non-escaped terminator +func (p *Parser) advance() bool { + r := p.next() + if r == '\\' { + p.next() + } else if isTerminator(r) { + p.backup() + return false + } + return true +} + +// isTerminator reports whether the input is at valid termination character to appear after an identifier. +func isTerminator(r rune) bool { + if isSpace(r) || isEndOfLine(r) { + return true + } + switch r { + case eof, '.', ',', '[', ']', '$', '@', '{', '}': + return true + } + return false +} + +// isSpace reports whether r is a space character. +func isSpace(r rune) bool { + return r == ' ' || r == '\t' +} + +// isEndOfLine reports whether r is an end-of-line character. +func isEndOfLine(r rune) bool { + return r == '\r' || r == '\n' +} + +// isAlphaNumeric reports whether r is an alphabetic, digit, or underscore. +func isAlphaNumeric(r rune) bool { + return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r) +} + +// isBool reports whether s is a boolean value. +func isBool(s string) bool { + return s == "true" || s == "false" +} + +//UnquoteExtend is almost same as strconv.Unquote(), but it support parse single quotes as a string +func UnquoteExtend(s string) (string, error) { + n := len(s) + if n < 2 { + return "", ErrSyntax + } + quote := s[0] + if quote != s[n-1] { + return "", ErrSyntax + } + s = s[1 : n-1] + + if quote != '"' && quote != '\'' { + return "", ErrSyntax + } + + // Is it trivial? Avoid allocation. + if !contains(s, '\\') && !contains(s, quote) { + return s, nil + } + + var runeTmp [utf8.UTFMax]byte + buf := make([]byte, 0, 3*len(s)/2) // Try to avoid more allocations. + for len(s) > 0 { + c, multibyte, ss, err := strconv.UnquoteChar(s, quote) + if err != nil { + return "", err + } + s = ss + if c < utf8.RuneSelf || !multibyte { + buf = append(buf, byte(c)) + } else { + n := utf8.EncodeRune(runeTmp[:], c) + buf = append(buf, runeTmp[:n]...) + } + } + return string(buf), nil +} + +func contains(s string, c byte) bool { + for i := 0; i < len(s); i++ { + if s[i] == c { + return true + } + } + return false +} diff --git a/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/LICENSE b/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/LICENSE new file mode 100644 index 00000000..6a66aea5 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/PATENTS b/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/PATENTS new file mode 100644 index 00000000..73309904 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/template/exec.go b/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/template/exec.go new file mode 100644 index 00000000..739fd350 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/template/exec.go @@ -0,0 +1,94 @@ +//This package is copied from Go library text/template. +//The original private functions indirect and printableValue +//are exported as public functions. +package template + +import ( + "fmt" + "reflect" +) + +var Indirect = indirect +var PrintableValue = printableValue + +var ( + errorType = reflect.TypeOf((*error)(nil)).Elem() + fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem() +) + +// indirect returns the item at the end of indirection, and a bool to indicate if it's nil. +// We indirect through pointers and empty interfaces (only) because +// non-empty interfaces have methods we might need. +func indirect(v reflect.Value) (rv reflect.Value, isNil bool) { + for ; v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface; v = v.Elem() { + if v.IsNil() { + return v, true + } + if v.Kind() == reflect.Interface && v.NumMethod() > 0 { + break + } + } + return v, false +} + +// printableValue returns the, possibly indirected, interface value inside v that +// is best for a call to formatted printer. +func printableValue(v reflect.Value) (interface{}, bool) { + if v.Kind() == reflect.Ptr { + v, _ = indirect(v) // fmt.Fprint handles nil. + } + if !v.IsValid() { + return "", true + } + + if !v.Type().Implements(errorType) && !v.Type().Implements(fmtStringerType) { + if v.CanAddr() && (reflect.PtrTo(v.Type()).Implements(errorType) || reflect.PtrTo(v.Type()).Implements(fmtStringerType)) { + v = v.Addr() + } else { + switch v.Kind() { + case reflect.Chan, reflect.Func: + return nil, false + } + } + } + return v.Interface(), true +} + +// canBeNil reports whether an untyped nil can be assigned to the type. See reflect.Zero. +func canBeNil(typ reflect.Type) bool { + switch typ.Kind() { + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + return true + } + return false +} + +// isTrue reports whether the value is 'true', in the sense of not the zero of its type, +// and whether the value has a meaningful truth value. +func isTrue(val reflect.Value) (truth, ok bool) { + if !val.IsValid() { + // Something like var x interface{}, never set. It's a form of nil. + return false, true + } + switch val.Kind() { + case reflect.Array, reflect.Map, reflect.Slice, reflect.String: + truth = val.Len() > 0 + case reflect.Bool: + truth = val.Bool() + case reflect.Complex64, reflect.Complex128: + truth = val.Complex() != 0 + case reflect.Chan, reflect.Func, reflect.Ptr, reflect.Interface: + truth = !val.IsNil() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + truth = val.Int() != 0 + case reflect.Float32, reflect.Float64: + truth = val.Float() != 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + truth = val.Uint() != 0 + case reflect.Struct: + truth = true // Struct values are always true. + default: + return + } + return truth, true +} diff --git a/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/template/funcs.go b/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/template/funcs.go new file mode 100644 index 00000000..27a008b0 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpath/third_party/forked/golang/template/funcs.go @@ -0,0 +1,599 @@ +//This package is copied from Go library text/template. +//The original private functions eq, ge, gt, le, lt, and ne +//are exported as public functions. +package template + +import ( + "bytes" + "errors" + "fmt" + "io" + "net/url" + "reflect" + "strings" + "unicode" + "unicode/utf8" +) + +var Equal = eq +var GreaterEqual = ge +var Greater = gt +var LessEqual = le +var Less = lt +var NotEqual = ne + +// FuncMap is the type of the map defining the mapping from names to functions. +// Each function must have either a single return value, or two return values of +// which the second has type error. In that case, if the second (error) +// return value evaluates to non-nil during execution, execution terminates and +// Execute returns that error. +type FuncMap map[string]interface{} + +var builtins = FuncMap{ + "and": and, + "call": call, + "html": HTMLEscaper, + "index": index, + "js": JSEscaper, + "len": length, + "not": not, + "or": or, + "print": fmt.Sprint, + "printf": fmt.Sprintf, + "println": fmt.Sprintln, + "urlquery": URLQueryEscaper, + + // Comparisons + "eq": eq, // == + "ge": ge, // >= + "gt": gt, // > + "le": le, // <= + "lt": lt, // < + "ne": ne, // != +} + +var builtinFuncs = createValueFuncs(builtins) + +// createValueFuncs turns a FuncMap into a map[string]reflect.Value +func createValueFuncs(funcMap FuncMap) map[string]reflect.Value { + m := make(map[string]reflect.Value) + addValueFuncs(m, funcMap) + return m +} + +// addValueFuncs adds to values the functions in funcs, converting them to reflect.Values. +func addValueFuncs(out map[string]reflect.Value, in FuncMap) { + for name, fn := range in { + v := reflect.ValueOf(fn) + if v.Kind() != reflect.Func { + panic("value for " + name + " not a function") + } + if !goodFunc(v.Type()) { + panic(fmt.Errorf("can't install method/function %q with %d results", name, v.Type().NumOut())) + } + out[name] = v + } +} + +// AddFuncs adds to values the functions in funcs. It does no checking of the input - +// call addValueFuncs first. +func addFuncs(out, in FuncMap) { + for name, fn := range in { + out[name] = fn + } +} + +// goodFunc checks that the function or method has the right result signature. +func goodFunc(typ reflect.Type) bool { + // We allow functions with 1 result or 2 results where the second is an error. + switch { + case typ.NumOut() == 1: + return true + case typ.NumOut() == 2 && typ.Out(1) == errorType: + return true + } + return false +} + +// findFunction looks for a function in the template, and global map. +func findFunction(name string) (reflect.Value, bool) { + if fn := builtinFuncs[name]; fn.IsValid() { + return fn, true + } + return reflect.Value{}, false +} + +// Indexing. + +// index returns the result of indexing its first argument by the following +// arguments. Thus "index x 1 2 3" is, in Go syntax, x[1][2][3]. Each +// indexed item must be a map, slice, or array. +func index(item interface{}, indices ...interface{}) (interface{}, error) { + v := reflect.ValueOf(item) + for _, i := range indices { + index := reflect.ValueOf(i) + var isNil bool + if v, isNil = indirect(v); isNil { + return nil, fmt.Errorf("index of nil pointer") + } + switch v.Kind() { + case reflect.Array, reflect.Slice, reflect.String: + var x int64 + switch index.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + x = index.Int() + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + x = int64(index.Uint()) + default: + return nil, fmt.Errorf("cannot index slice/array with type %s", index.Type()) + } + if x < 0 || x >= int64(v.Len()) { + return nil, fmt.Errorf("index out of range: %d", x) + } + v = v.Index(int(x)) + case reflect.Map: + if !index.IsValid() { + index = reflect.Zero(v.Type().Key()) + } + if !index.Type().AssignableTo(v.Type().Key()) { + return nil, fmt.Errorf("%s is not index type for %s", index.Type(), v.Type()) + } + if x := v.MapIndex(index); x.IsValid() { + v = x + } else { + v = reflect.Zero(v.Type().Elem()) + } + default: + return nil, fmt.Errorf("can't index item of type %s", v.Type()) + } + } + return v.Interface(), nil +} + +// Length + +// length returns the length of the item, with an error if it has no defined length. +func length(item interface{}) (int, error) { + v, isNil := indirect(reflect.ValueOf(item)) + if isNil { + return 0, fmt.Errorf("len of nil pointer") + } + switch v.Kind() { + case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String: + return v.Len(), nil + } + return 0, fmt.Errorf("len of type %s", v.Type()) +} + +// Function invocation + +// call returns the result of evaluating the first argument as a function. +// The function must return 1 result, or 2 results, the second of which is an error. +func call(fn interface{}, args ...interface{}) (interface{}, error) { + v := reflect.ValueOf(fn) + typ := v.Type() + if typ.Kind() != reflect.Func { + return nil, fmt.Errorf("non-function of type %s", typ) + } + if !goodFunc(typ) { + return nil, fmt.Errorf("function called with %d args; should be 1 or 2", typ.NumOut()) + } + numIn := typ.NumIn() + var dddType reflect.Type + if typ.IsVariadic() { + if len(args) < numIn-1 { + return nil, fmt.Errorf("wrong number of args: got %d want at least %d", len(args), numIn-1) + } + dddType = typ.In(numIn - 1).Elem() + } else { + if len(args) != numIn { + return nil, fmt.Errorf("wrong number of args: got %d want %d", len(args), numIn) + } + } + argv := make([]reflect.Value, len(args)) + for i, arg := range args { + value := reflect.ValueOf(arg) + // Compute the expected type. Clumsy because of variadics. + var argType reflect.Type + if !typ.IsVariadic() || i < numIn-1 { + argType = typ.In(i) + } else { + argType = dddType + } + if !value.IsValid() && canBeNil(argType) { + value = reflect.Zero(argType) + } + if !value.Type().AssignableTo(argType) { + return nil, fmt.Errorf("arg %d has type %s; should be %s", i, value.Type(), argType) + } + argv[i] = value + } + result := v.Call(argv) + if len(result) == 2 && !result[1].IsNil() { + return result[0].Interface(), result[1].Interface().(error) + } + return result[0].Interface(), nil +} + +// Boolean logic. + +func truth(a interface{}) bool { + t, _ := isTrue(reflect.ValueOf(a)) + return t +} + +// and computes the Boolean AND of its arguments, returning +// the first false argument it encounters, or the last argument. +func and(arg0 interface{}, args ...interface{}) interface{} { + if !truth(arg0) { + return arg0 + } + for i := range args { + arg0 = args[i] + if !truth(arg0) { + break + } + } + return arg0 +} + +// or computes the Boolean OR of its arguments, returning +// the first true argument it encounters, or the last argument. +func or(arg0 interface{}, args ...interface{}) interface{} { + if truth(arg0) { + return arg0 + } + for i := range args { + arg0 = args[i] + if truth(arg0) { + break + } + } + return arg0 +} + +// not returns the Boolean negation of its argument. +func not(arg interface{}) (truth bool) { + truth, _ = isTrue(reflect.ValueOf(arg)) + return !truth +} + +// Comparison. + +// TODO: Perhaps allow comparison between signed and unsigned integers. + +var ( + errBadComparisonType = errors.New("invalid type for comparison") + errBadComparison = errors.New("incompatible types for comparison") + errNoComparison = errors.New("missing argument for comparison") +) + +type kind int + +const ( + invalidKind kind = iota + boolKind + complexKind + intKind + floatKind + integerKind + stringKind + uintKind +) + +func basicKind(v reflect.Value) (kind, error) { + switch v.Kind() { + case reflect.Bool: + return boolKind, nil + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return intKind, nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return uintKind, nil + case reflect.Float32, reflect.Float64: + return floatKind, nil + case reflect.Complex64, reflect.Complex128: + return complexKind, nil + case reflect.String: + return stringKind, nil + } + return invalidKind, errBadComparisonType +} + +// eq evaluates the comparison a == b || a == c || ... +func eq(arg1 interface{}, arg2 ...interface{}) (bool, error) { + v1 := reflect.ValueOf(arg1) + k1, err := basicKind(v1) + if err != nil { + return false, err + } + if len(arg2) == 0 { + return false, errNoComparison + } + for _, arg := range arg2 { + v2 := reflect.ValueOf(arg) + k2, err := basicKind(v2) + if err != nil { + return false, err + } + truth := false + if k1 != k2 { + // Special case: Can compare integer values regardless of type's sign. + switch { + case k1 == intKind && k2 == uintKind: + truth = v1.Int() >= 0 && uint64(v1.Int()) == v2.Uint() + case k1 == uintKind && k2 == intKind: + truth = v2.Int() >= 0 && v1.Uint() == uint64(v2.Int()) + default: + return false, errBadComparison + } + } else { + switch k1 { + case boolKind: + truth = v1.Bool() == v2.Bool() + case complexKind: + truth = v1.Complex() == v2.Complex() + case floatKind: + truth = v1.Float() == v2.Float() + case intKind: + truth = v1.Int() == v2.Int() + case stringKind: + truth = v1.String() == v2.String() + case uintKind: + truth = v1.Uint() == v2.Uint() + default: + panic("invalid kind") + } + } + if truth { + return true, nil + } + } + return false, nil +} + +// ne evaluates the comparison a != b. +func ne(arg1, arg2 interface{}) (bool, error) { + // != is the inverse of ==. + equal, err := eq(arg1, arg2) + return !equal, err +} + +// lt evaluates the comparison a < b. +func lt(arg1, arg2 interface{}) (bool, error) { + v1 := reflect.ValueOf(arg1) + k1, err := basicKind(v1) + if err != nil { + return false, err + } + v2 := reflect.ValueOf(arg2) + k2, err := basicKind(v2) + if err != nil { + return false, err + } + truth := false + if k1 != k2 { + // Special case: Can compare integer values regardless of type's sign. + switch { + case k1 == intKind && k2 == uintKind: + truth = v1.Int() < 0 || uint64(v1.Int()) < v2.Uint() + case k1 == uintKind && k2 == intKind: + truth = v2.Int() >= 0 && v1.Uint() < uint64(v2.Int()) + default: + return false, errBadComparison + } + } else { + switch k1 { + case boolKind, complexKind: + return false, errBadComparisonType + case floatKind: + truth = v1.Float() < v2.Float() + case intKind: + truth = v1.Int() < v2.Int() + case stringKind: + truth = v1.String() < v2.String() + case uintKind: + truth = v1.Uint() < v2.Uint() + default: + panic("invalid kind") + } + } + return truth, nil +} + +// le evaluates the comparison <= b. +func le(arg1, arg2 interface{}) (bool, error) { + // <= is < or ==. + lessThan, err := lt(arg1, arg2) + if lessThan || err != nil { + return lessThan, err + } + return eq(arg1, arg2) +} + +// gt evaluates the comparison a > b. +func gt(arg1, arg2 interface{}) (bool, error) { + // > is the inverse of <=. + lessOrEqual, err := le(arg1, arg2) + if err != nil { + return false, err + } + return !lessOrEqual, nil +} + +// ge evaluates the comparison a >= b. +func ge(arg1, arg2 interface{}) (bool, error) { + // >= is the inverse of <. + lessThan, err := lt(arg1, arg2) + if err != nil { + return false, err + } + return !lessThan, nil +} + +// HTML escaping. + +var ( + htmlQuot = []byte(""") // shorter than """ + htmlApos = []byte("'") // shorter than "'" and apos was not in HTML until HTML5 + htmlAmp = []byte("&") + htmlLt = []byte("<") + htmlGt = []byte(">") +) + +// HTMLEscape writes to w the escaped HTML equivalent of the plain text data b. +func HTMLEscape(w io.Writer, b []byte) { + last := 0 + for i, c := range b { + var html []byte + switch c { + case '"': + html = htmlQuot + case '\'': + html = htmlApos + case '&': + html = htmlAmp + case '<': + html = htmlLt + case '>': + html = htmlGt + default: + continue + } + w.Write(b[last:i]) + w.Write(html) + last = i + 1 + } + w.Write(b[last:]) +} + +// HTMLEscapeString returns the escaped HTML equivalent of the plain text data s. +func HTMLEscapeString(s string) string { + // Avoid allocation if we can. + if strings.IndexAny(s, `'"&<>`) < 0 { + return s + } + var b bytes.Buffer + HTMLEscape(&b, []byte(s)) + return b.String() +} + +// HTMLEscaper returns the escaped HTML equivalent of the textual +// representation of its arguments. +func HTMLEscaper(args ...interface{}) string { + return HTMLEscapeString(evalArgs(args)) +} + +// JavaScript escaping. + +var ( + jsLowUni = []byte(`\u00`) + hex = []byte("0123456789ABCDEF") + + jsBackslash = []byte(`\\`) + jsApos = []byte(`\'`) + jsQuot = []byte(`\"`) + jsLt = []byte(`\x3C`) + jsGt = []byte(`\x3E`) +) + +// JSEscape writes to w the escaped JavaScript equivalent of the plain text data b. +func JSEscape(w io.Writer, b []byte) { + last := 0 + for i := 0; i < len(b); i++ { + c := b[i] + + if !jsIsSpecial(rune(c)) { + // fast path: nothing to do + continue + } + w.Write(b[last:i]) + + if c < utf8.RuneSelf { + // Quotes, slashes and angle brackets get quoted. + // Control characters get written as \u00XX. + switch c { + case '\\': + w.Write(jsBackslash) + case '\'': + w.Write(jsApos) + case '"': + w.Write(jsQuot) + case '<': + w.Write(jsLt) + case '>': + w.Write(jsGt) + default: + w.Write(jsLowUni) + t, b := c>>4, c&0x0f + w.Write(hex[t : t+1]) + w.Write(hex[b : b+1]) + } + } else { + // Unicode rune. + r, size := utf8.DecodeRune(b[i:]) + if unicode.IsPrint(r) { + w.Write(b[i : i+size]) + } else { + fmt.Fprintf(w, "\\u%04X", r) + } + i += size - 1 + } + last = i + 1 + } + w.Write(b[last:]) +} + +// JSEscapeString returns the escaped JavaScript equivalent of the plain text data s. +func JSEscapeString(s string) string { + // Avoid allocation if we can. + if strings.IndexFunc(s, jsIsSpecial) < 0 { + return s + } + var b bytes.Buffer + JSEscape(&b, []byte(s)) + return b.String() +} + +func jsIsSpecial(r rune) bool { + switch r { + case '\\', '\'', '"', '<', '>': + return true + } + return r < ' ' || utf8.RuneSelf <= r +} + +// JSEscaper returns the escaped JavaScript equivalent of the textual +// representation of its arguments. +func JSEscaper(args ...interface{}) string { + return JSEscapeString(evalArgs(args)) +} + +// URLQueryEscaper returns the escaped value of the textual representation of +// its arguments in a form suitable for embedding in a URL query. +func URLQueryEscaper(args ...interface{}) string { + return url.QueryEscape(evalArgs(args)) +} + +// evalArgs formats the list of arguments into a string. It is therefore equivalent to +// fmt.Sprint(args...) +// except that each argument is indirected (if a pointer), as required, +// using the same rules as the default string evaluation during template +// execution. +func evalArgs(args []interface{}) string { + ok := false + var s string + // Fast path for simple common case. + if len(args) == 1 { + s, ok = args[0].(string) + } + if !ok { + for i, arg := range args { + a, ok := printableValue(reflect.ValueOf(arg)) + if ok { + args[i] = a + } // else left fmt do its thing + } + s = fmt.Sprint(args...) + } + return s +} diff --git a/vendor/k8s.io/apiserver/pkg/server/options/authentication.go b/vendor/k8s.io/apiserver/pkg/server/options/authentication.go index 8ff771af..f226909c 100644 --- a/vendor/k8s.io/apiserver/pkg/server/options/authentication.go +++ b/vendor/k8s.io/apiserver/pkg/server/options/authentication.go @@ -19,12 +19,12 @@ package options import ( "context" "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "strings" "time" "github.com/spf13/pflag" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apiserver/pkg/authentication/authenticatorfactory" "k8s.io/apiserver/pkg/authentication/request/headerrequest" @@ -202,6 +202,8 @@ type DelegatingAuthenticationOptions struct { // CustomRoundTripperFn allows for specifying a middleware function for custom HTTP behaviour for the authentication webhook client. CustomRoundTripperFn transport.WrapperFunc + + AuthenticationConfigMapNamespace string } func NewDelegatingAuthenticationOptions() *DelegatingAuthenticationOptions { @@ -214,8 +216,9 @@ func NewDelegatingAuthenticationOptions() *DelegatingAuthenticationOptions { GroupHeaders: []string{"x-remote-group"}, ExtraHeaderPrefixes: []string{"x-remote-extra-"}, }, - WebhookRetryBackoff: DefaultAuthWebhookRetryBackoff(), - TokenRequestTimeout: 10 * time.Second, + WebhookRetryBackoff: DefaultAuthWebhookRetryBackoff(), + TokenRequestTimeout: 10 * time.Second, + AuthenticationConfigMapNamespace: metav1.NamespaceSystem, } } @@ -274,6 +277,9 @@ func (s *DelegatingAuthenticationOptions) AddFlags(fs *pflag.FlagSet) { fs.BoolVar(&s.TolerateInClusterLookupFailure, "authentication-tolerate-lookup-failure", s.TolerateInClusterLookupFailure, ""+ "If true, failures to look up missing authentication configuration from the cluster are not considered fatal. "+ "Note that this can result in authentication that treats all requests as anonymous.") + + fs.StringVar(&s.AuthenticationConfigMapNamespace, "authentication-configmap-namespace", s.AuthenticationConfigMapNamespace, ""+ + "Namespace of extension-apiserver-authentication configmap") } func (s *DelegatingAuthenticationOptions) ApplyTo(authenticationInfo *server.AuthenticationInfo, servingInfo *server.SecureServingInfo, openAPIConfig *openapicommon.Config) error { @@ -314,9 +320,9 @@ func (s *DelegatingAuthenticationOptions) ApplyTo(authenticationInfo *server.Aut } else if !s.SkipInClusterLookup { if client == nil { - klog.Warningf("No authentication-kubeconfig provided in order to lookup client-ca-file in configmap/%s in %s, so client certificate authentication won't work.", authenticationConfigMapName, authenticationConfigMapNamespace) + klog.Warningf("No authentication-kubeconfig provided in order to lookup client-ca-file in configmap/%s in %s, so client certificate authentication won't work.", authenticationConfigMapName, s.AuthenticationConfigMapNamespace) } else { - clientCAProvider, err = dynamiccertificates.NewDynamicCAFromConfigMapController("client-ca", authenticationConfigMapNamespace, authenticationConfigMapName, "client-ca-file", client) + clientCAProvider, err = dynamiccertificates.NewDynamicCAFromConfigMapController("client-ca", s.AuthenticationConfigMapNamespace, authenticationConfigMapName, "client-ca-file", client) if err != nil { return fmt.Errorf("unable to load configmap based client CA file: %v", err) } @@ -338,7 +344,7 @@ func (s *DelegatingAuthenticationOptions) ApplyTo(authenticationInfo *server.Aut } else if !s.SkipInClusterLookup { if client == nil { - klog.Warningf("No authentication-kubeconfig provided in order to lookup requestheader-client-ca-file in configmap/%s in %s, so request-header client certificate authentication won't work.", authenticationConfigMapName, authenticationConfigMapNamespace) + klog.Warningf("No authentication-kubeconfig provided in order to lookup requestheader-client-ca-file in configmap/%s in %s, so request-header client certificate authentication won't work.", authenticationConfigMapName, s.AuthenticationConfigMapNamespace) } else { requestHeaderConfig, err = s.createRequestHeaderConfig(client) if err != nil { @@ -373,7 +379,7 @@ func (s *DelegatingAuthenticationOptions) ApplyTo(authenticationInfo *server.Aut } const ( - authenticationConfigMapNamespace = metav1.NamespaceSystem + // authenticationConfigMapNamespace = metav1.NamespaceSystem // authenticationConfigMapName is the name of ConfigMap in the kube-system namespace holding the root certificate // bundle to use to verify client certificates on incoming requests before trusting usernames in headers specified // by --requestheader-username-headers. This is created in the cluster by the kube-apiserver. @@ -382,7 +388,7 @@ const ( ) func (s *DelegatingAuthenticationOptions) createRequestHeaderConfig(client kubernetes.Interface) (*authenticatorfactory.RequestHeaderConfig, error) { - dynamicRequestHeaderProvider, err := newDynamicRequestHeaderController(client) + dynamicRequestHeaderProvider, err := newDynamicRequestHeaderController(client, s.AuthenticationConfigMapNamespace) if err != nil { return nil, fmt.Errorf("unable to create request header authentication config: %v", err) } diff --git a/vendor/k8s.io/apiserver/pkg/server/options/authentication_dynamic_request_header.go b/vendor/k8s.io/apiserver/pkg/server/options/authentication_dynamic_request_header.go index 0dac3402..1707594c 100644 --- a/vendor/k8s.io/apiserver/pkg/server/options/authentication_dynamic_request_header.go +++ b/vendor/k8s.io/apiserver/pkg/server/options/authentication_dynamic_request_header.go @@ -39,7 +39,7 @@ type DynamicRequestHeaderController struct { } // newDynamicRequestHeaderController creates a new controller that implements DynamicRequestHeaderController -func newDynamicRequestHeaderController(client kubernetes.Interface) (*DynamicRequestHeaderController, error) { +func newDynamicRequestHeaderController(client kubernetes.Interface, authenticationConfigMapNamespace string) (*DynamicRequestHeaderController, error) { requestHeaderCAController, err := dynamiccertificates.NewDynamicCAFromConfigMapController( "client-ca", authenticationConfigMapNamespace, diff --git a/vendor/kmodules.xyz/client-go/Makefile b/vendor/kmodules.xyz/client-go/Makefile index 441dd38e..a54fa85d 100644 --- a/vendor/kmodules.xyz/client-go/Makefile +++ b/vendor/kmodules.xyz/client-go/Makefile @@ -45,7 +45,7 @@ endif ### These variables should not need tweaking. ### -SRC_PKGS := admissionregistration api apiextensions apiregistration apps batch certificates client core discovery dynamic extensions meta networking openapi policy rbac storage tools +SRC_PKGS := admissionregistration api apiextensions apiregistration apps batch certificates client conditions core discovery dynamic extensions meta networking openapi policy rbac storage tools SRC_DIRS := $(SRC_PKGS) *.go DOCKER_PLATFORMS := linux/amd64 linux/arm linux/arm64 @@ -154,7 +154,7 @@ gen-crd-protos: --packages=-k8s.io/api/core/v1,kmodules.xyz/client-go/api/v1 .PHONY: gen-enum -gen-enum: +gen-enum: $(BUILD_DIRS) @docker run \ -i \ --rm \ diff --git a/vendor/kmodules.xyz/client-go/api/v1/conditions.go b/vendor/kmodules.xyz/client-go/api/v1/conditions.go index 332a460c..148531c8 100644 --- a/vendor/kmodules.xyz/client-go/api/v1/conditions.go +++ b/vendor/kmodules.xyz/client-go/api/v1/conditions.go @@ -1,5 +1,5 @@ /* -Copyright AppsCode Inc. and Contributors +Copyright 2020 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,190 +17,72 @@ limitations under the License. package v1 import ( - "fmt" - - core "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// KEP: https://github.com/kubernetes/enhancements/blob/ced773ab59f0ff080888a912ab99474245623dad/keps/sig-api-machinery/1623-standardize-conditions/README.md +// ConditionSeverity expresses the severity of a Condition Type failing. +type ConditionSeverity string -// List of common condition types const ( - ConditionProgressing = "Progressing" - ConditionInitialized = "Initialized" - ConditionReady = "Ready" - ConditionAvailable = "Available" - ConditionFailed = "Failed" - - ConditionRequestApproved = "Approved" - ConditionRequestDenied = "Denied" + // ConditionSeverityError specifies that a condition with `Status=False` is an error. + ConditionSeverityError ConditionSeverity = "Error" + + // ConditionSeverityWarning specifies that a condition with `Status=False` is a warning. + ConditionSeverityWarning ConditionSeverity = "Warning" + + // ConditionSeverityInfo specifies that a condition with `Status=False` is informative. + ConditionSeverityInfo ConditionSeverity = "Info" + + // ConditionSeverityNone should apply only to util with `Status=True`. + ConditionSeverityNone ConditionSeverity = "" ) +// ConditionType is a valid value for Condition.Type. +type ConditionType string + +const ( + // ReadyCondition defines the Ready condition type that summarizes the operational state of an object. + ReadyCondition ConditionType = "Ready" +) + +// Condition defines an observation of a object operational state. type Condition struct { // Type of condition in CamelCase or in foo.example.com/CamelCase. - // Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be - // useful (see .node.status.conditions), the ability to deconflict is important. - // +required - Type string `json:"type" protobuf:"bytes,1,opt,name=type"` + // Many .condition.type values are consistent across resources like Available, but because arbitrary util + // can be useful (see .node.status.util), the ability to deconflict is important. + Type ConditionType `json:"type" protobuf:"bytes,4,opt,name=type,casttype=ConditionType"` + // Status of the condition, one of True, False, Unknown. - // +required - Status core.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"` + Status metav1.ConditionStatus `json:"status" protobuf:"bytes,5,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"` + // If set, this represents the .metadata.generation that the condition was set based upon. // For instance, if .metadata.generation is currently 12, but the .status.condition[x].observedGeneration is 9, the condition is out of date // with respect to the current state of the instance. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"` - // Last time the condition transitioned from one status to another. - // This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - // +required - LastTransitionTime metav1.Time `json:"lastTransitionTime" protobuf:"bytes,4,opt,name=lastTransitionTime"` - // The reason for the condition's last transition in CamelCase. - // The specific API may choose whether or not this field is considered a guaranteed API. - // This field may not be empty. - // +required - Reason string `json:"reason" protobuf:"bytes,5,opt,name=reason"` - // A human readable message indicating details about the transition. - // This field may be empty. - // +required - Message string `json:"message" protobuf:"bytes,6,opt,name=message"` -} - -func NewCondition(reason string, message string, generation int64, conditionStatus ...bool) Condition { - cs := core.ConditionTrue - if len(conditionStatus) > 0 && !conditionStatus[0] { - cs = core.ConditionFalse - } - - return Condition{ - Type: reason, - Reason: reason, - Message: message, - Status: cs, - LastTransitionTime: metav1.Now(), - ObservedGeneration: generation, - } -} - -// HasCondition returns "true" if the desired condition provided in "condType" is present in the condition list. -// Otherwise, it returns "false". -func HasCondition(conditions []Condition, condType string) bool { - for i := range conditions { - if conditions[i].Type == condType { - return true - } - } - return false -} - -// GetCondition returns a pointer to the desired condition referred by "condType". Otherwise, it returns nil. -func GetCondition(conditions []Condition, condType string) (int, *Condition) { - for i := range conditions { - c := conditions[i] - if c.Type == condType { - return i, &c - } - } - return -1, nil -} -// SetCondition add/update the desired condition to the condition list. It does nothing if the condition is already in -// its desired state. -func SetCondition(conditions []Condition, newCondition Condition) []Condition { - idx, curCond := GetCondition(conditions, newCondition.Type) - // If the current condition is in its desired state, we have nothing to do. Just return the original condition list. - if curCond != nil && - curCond.Status == newCondition.Status && - curCond.Reason == newCondition.Reason && - curCond.Message == newCondition.Message && - curCond.ObservedGeneration == newCondition.ObservedGeneration { - return conditions - } - // The desired conditions is not in the condition list or is not in its desired state. - // Update it if present in the condition list, or append the new condition if it does not present. - newCondition.LastTransitionTime = metav1.Now() - if idx == -1 { - conditions = append(conditions, newCondition) - } else if newCondition.ObservedGeneration >= curCond.ObservedGeneration { - // only update if the new condition is based on observed generation at least as updated as the current condition - conditions[idx] = newCondition - } - return conditions -} - -// RemoveCondition remove a condition from the condition list referred by "condType" parameter. -func RemoveCondition(conditions []Condition, condType string) []Condition { - idx, _ := GetCondition(conditions, condType) - if idx == -1 { - // The desired condition is not present in the condition list. So, nothing to do. - return conditions - } - return append(conditions[:idx], conditions[idx+1:]...) -} - -// IsConditionTrue returns "true" if the desired condition is in true state. -// It returns "false" if the desired condition is not in "true" state or is not in the condition list. -func IsConditionTrue(conditions []Condition, condType string) bool { - for i := range conditions { - if conditions[i].Type == condType && conditions[i].Status == core.ConditionTrue { - return true - } - } - return false -} - -// IsConditionFalse returns "true" if the desired condition is in false state. -// It returns "false" if the desired condition is not in "false" state or is not in the condition list. -func IsConditionFalse(conditions []Condition, condType string) bool { - for i := range conditions { - if conditions[i].Type == condType && conditions[i].Status == core.ConditionFalse { - return true - } - } - return false -} - -// IsConditionUnknown returns "true" if the desired condition is in unknown state. -// It returns "false" if the desired condition is not in "unknown" state or is not in the condition list. -func IsConditionUnknown(conditions []Condition, condType string) bool { - for i := range conditions { - if conditions[i].Type == condType && conditions[i].Status == core.ConditionUnknown { - return true - } - } - return false -} - -// Status defines the set of statuses a resource can have. -// Based on kstatus: https://github.com/kubernetes-sigs/cli-utils/tree/master/pkg/kstatus -// +kubebuilder:validation:Enum=InProgress;Failed;Current;Terminating;NotFound;Unknown -type Status string + // Severity provides an explicit classification of Reason code, so the users or machines can immediately + // understand the current situation and act accordingly. + // The Severity field MUST be set only when Status=False. + // +optional + Severity ConditionSeverity `json:"severity,omitempty" protobuf:"bytes,6,opt,name=severity,casttype=ConditionSeverity"` -const ( - // The set of status conditions which can be assigned to resources. - InProgressStatus Status = "InProgress" - FailedStatus Status = "Failed" - CurrentStatus Status = "Current" - TerminatingStatus Status = "Terminating" - NotFoundStatus Status = "NotFound" - UnknownStatus Status = "Unknown" -) + // Last time the condition transitioned from one status to another. + // This should be when the underlying condition changed. If that is not known, then using the time when + // the API field changed is acceptable. + LastTransitionTime metav1.Time `json:"lastTransitionTime" protobuf:"bytes,7,opt,name=lastTransitionTime"` -var Statuses = []Status{InProgressStatus, FailedStatus, CurrentStatus, TerminatingStatus, UnknownStatus} + // The reason for the condition's last transition in CamelCase. + // The specific API may choose whether this field is considered a guaranteed API. + // This field may not be empty. + // +optional + Reason string `json:"reason,omitempty" protobuf:"bytes,8,opt,name=reason"` -// String returns the status as a string. -func (s Status) String() string { - return string(s) + // A human-readable message indicating details about the transition. + // This field may be empty. + // +optional + Message string `json:"message,omitempty" protobuf:"bytes,9,opt,name=message"` } -// StatusFromStringOrDie turns a string into a Status. Will panic if the provided string is -// not a valid status. -func StatusFromStringOrDie(text string) Status { - s := Status(text) - for _, r := range Statuses { - if s == r { - return s - } - } - panic(fmt.Errorf("string has invalid status: %s", s)) -} +// Conditions provide observations of the operational state of a object. +type Conditions []Condition diff --git a/vendor/kmodules.xyz/client-go/api/v1/generated.pb.go b/vendor/kmodules.xyz/client-go/api/v1/generated.pb.go index d369fcc4..afb78575 100644 --- a/vendor/kmodules.xyz/client-go/api/v1/generated.pb.go +++ b/vendor/kmodules.xyz/client-go/api/v1/generated.pb.go @@ -28,8 +28,8 @@ import ( strings "strings" proto "github.com/gogo/protobuf/proto" - k8s_io_api_core_v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" + k8s_io_apimachinery_pkg_apis_meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v11 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -540,113 +540,115 @@ func init() { } var fileDescriptor_af8e7a11c7a1ccd9 = []byte{ - // 1687 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0xcf, 0x6f, 0x1b, 0x59, - 0x1d, 0xf7, 0xd4, 0x71, 0xe2, 0xf9, 0x3a, 0xa9, 0xdb, 0xd7, 0xa2, 0x9a, 0x8a, 0x7a, 0x82, 0x57, - 0xaa, 0x52, 0xa0, 0x63, 0x5a, 0x75, 0x61, 0x59, 0x09, 0x41, 0xc7, 0x59, 0xba, 0xde, 0x4d, 0x93, - 0xf0, 0x9c, 0xb2, 0xab, 0x05, 0x09, 0xbd, 0xcc, 0x7c, 0xed, 0x3c, 0x32, 0x9e, 0x19, 0xbd, 0x37, - 0x0e, 0x64, 0x4f, 0x7b, 0x84, 0xdb, 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, 0x73, 0x63, 0x36, 0xb5, 0xae, 0xed, 0x9d, 0x85, 0xe9, 0x32, 0x1f, 0xd5, - 0x02, 0x7d, 0x15, 0x3b, 0x3c, 0x56, 0x0b, 0xaf, 0x14, 0x2d, 0x70, 0x27, 0xb7, 0xd2, 0x12, 0x43, - 0xed, 0x53, 0x0f, 0xc6, 0x81, 0x8b, 0xb2, 0x55, 0x2b, 0xf6, 0xb9, 0x9f, 0x19, 0x69, 0x81, 0x93, - 0xef, 0x42, 0x53, 0xc6, 0x02, 0x31, 0x2e, 0xbe, 0x54, 0x56, 0xb5, 0x8b, 0x6e, 0xfd, 0x83, 0x79, - 0x88, 0x2e, 0x72, 0xd5, 0x87, 0x53, 0x14, 0xca, 0x98, 0xf9, 0xbd, 0xd0, 0xcb, 0xbf, 0xb2, 0xf4, - 0x87, 0xd3, 0x7e, 0x61, 0xa6, 0x65, 0x0e, 0x79, 0x0b, 0xd6, 0x25, 0x0a, 0xce, 0xfc, 0xdd, 0xc9, - 0xf8, 0x10, 0x45, 0xab, 0xae, 0x5f, 0x2e, 0x0f, 0xd4, 0x41, 0x09, 0xa3, 0x73, 0x4c, 0xa7, 0xf7, - 0xec, 0x45, 0xbb, 0xf2, 0xfc, 0x45, 0xbb, 0xf2, 0xf9, 0x8b, 0x76, 0xe5, 0x93, 0x59, 0xdb, 0x78, - 0x36, 0x6b, 0x1b, 0xcf, 0x67, 0x6d, 0xe3, 0xf3, 0x59, 0xdb, 0xf8, 0xdb, 0xac, 0x6d, 0x7c, 0xfa, - 0xf7, 0x76, 0xe5, 0xa3, 0x5b, 0xaf, 0xfc, 0x17, 0xc8, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x3d, - 0x8f, 0x54, 0x44, 0x22, 0x11, 0x00, 0x00, + // 1728 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0xcf, 0x6f, 0x23, 0x49, +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4f, 0x80, 0x27, 0xf3, 0x66, + 0x16, 0xa8, 0xbd, 0x82, 0x8d, 0xcc, 0x30, 0xad, 0xce, 0xf3, 0x97, 0xcd, 0xd2, 0x8b, 0x97, 0xcd, + 0xd2, 0x67, 0x2f, 0x9b, 0xa5, 0x8f, 0xa7, 0x4d, 0xed, 0xf9, 0xb4, 0xa9, 0xbd, 0x98, 0x36, 0xb5, + 0xcf, 0xa6, 0x4d, 0xed, 0x6f, 0xd3, 0xa6, 0xf6, 0xc9, 0xdf, 0x9b, 0xa5, 0x0f, 0xef, 0xbd, 0xf2, + 0x8f, 0x96, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xe4, 0x6b, 0xda, 0x16, 0x88, 0x11, 0x00, 0x00, } func (m *CertificatePrivateKey) Marshal() (dAtA []byte, err error) { @@ -873,12 +875,12 @@ func (m *Condition) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Message) i = encodeVarintGenerated(dAtA, i, uint64(len(m.Message))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x4a i -= len(m.Reason) copy(dAtA[i:], m.Reason) i = encodeVarintGenerated(dAtA, i, uint64(len(m.Reason))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x42 { size, err := m.LastTransitionTime.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -888,20 +890,25 @@ func (m *Condition) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenerated(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - i = encodeVarintGenerated(dAtA, i, uint64(m.ObservedGeneration)) + dAtA[i] = 0x3a + i -= len(m.Severity) + copy(dAtA[i:], m.Severity) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Severity))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x32 i -= len(m.Status) copy(dAtA[i:], m.Status) i = encodeVarintGenerated(dAtA, i, uint64(len(m.Status))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x2a i -= len(m.Type) copy(dAtA[i:], m.Type) i = encodeVarintGenerated(dAtA, i, uint64(len(m.Type))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x22 + i = encodeVarintGenerated(dAtA, i, uint64(m.ObservedGeneration)) + i-- + dAtA[i] = 0x18 return len(dAtA) - i, nil } @@ -1583,11 +1590,13 @@ func (m *Condition) Size() (n int) { } var l int _ = l + n += 1 + sovGenerated(uint64(m.ObservedGeneration)) l = len(m.Type) n += 1 + l + sovGenerated(uint64(l)) l = len(m.Status) n += 1 + l + sovGenerated(uint64(l)) - n += 1 + sovGenerated(uint64(m.ObservedGeneration)) + l = len(m.Severity) + n += 1 + l + sovGenerated(uint64(l)) l = m.LastTransitionTime.Size() n += 1 + l + sovGenerated(uint64(l)) l = len(m.Reason) @@ -1893,9 +1902,10 @@ func (this *Condition) String() string { return "nil" } s := strings.Join([]string{`&Condition{`, + `ObservedGeneration:` + fmt.Sprintf("%v", this.ObservedGeneration) + `,`, `Type:` + fmt.Sprintf("%v", this.Type) + `,`, `Status:` + fmt.Sprintf("%v", this.Status) + `,`, - `ObservedGeneration:` + fmt.Sprintf("%v", this.ObservedGeneration) + `,`, + `Severity:` + fmt.Sprintf("%v", this.Severity) + `,`, `LastTransitionTime:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.LastTransitionTime), "Time", "v11.Time", 1), `&`, ``, 1) + `,`, `Reason:` + fmt.Sprintf("%v", this.Reason) + `,`, `Message:` + fmt.Sprintf("%v", this.Message) + `,`, @@ -2790,7 +2800,26 @@ func (m *Condition) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Condition: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ObservedGeneration", wireType) + } + m.ObservedGeneration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ObservedGeneration |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) } @@ -2820,9 +2849,9 @@ func (m *Condition) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Type = string(dAtA[iNdEx:postIndex]) + m.Type = ConditionType(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } @@ -2852,13 +2881,13 @@ func (m *Condition) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Status = k8s_io_api_core_v1.ConditionStatus(dAtA[iNdEx:postIndex]) + m.Status = k8s_io_apimachinery_pkg_apis_meta_v1.ConditionStatus(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ObservedGeneration", wireType) + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Severity", wireType) } - m.ObservedGeneration = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -2868,12 +2897,25 @@ func (m *Condition) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ObservedGeneration |= int64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 4: + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Severity = ConditionSeverity(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastTransitionTime", wireType) } @@ -2906,7 +2948,7 @@ func (m *Condition) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Reason", wireType) } @@ -2938,7 +2980,7 @@ func (m *Condition) Unmarshal(dAtA []byte) error { } m.Reason = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) } diff --git a/vendor/kmodules.xyz/client-go/api/v1/generated.proto b/vendor/kmodules.xyz/client-go/api/v1/generated.proto index ff235455..d8fc1a44 100644 --- a/vendor/kmodules.xyz/client-go/api/v1/generated.proto +++ b/vendor/kmodules.xyz/client-go/api/v1/generated.proto @@ -97,16 +97,15 @@ message ClusterMetadata { optional string provider = 4; } +// Condition defines an observation of a object operational state. message Condition { // Type of condition in CamelCase or in foo.example.com/CamelCase. - // Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be - // useful (see .node.status.conditions), the ability to deconflict is important. - // +required - optional string type = 1; + // Many .condition.type values are consistent across resources like Available, but because arbitrary util + // can be useful (see .node.status.util), the ability to deconflict is important. + optional string type = 4; // Status of the condition, one of True, False, Unknown. - // +required - optional string status = 2; + optional string status = 5; // If set, this represents the .metadata.generation that the condition was set based upon. // For instance, if .metadata.generation is currently 12, but the .status.condition[x].observedGeneration is 9, the condition is out of date @@ -114,21 +113,27 @@ message Condition { // +optional optional int64 observedGeneration = 3; + // Severity provides an explicit classification of Reason code, so the users or machines can immediately + // understand the current situation and act accordingly. + // The Severity field MUST be set only when Status=False. + // +optional + optional string severity = 6; + // Last time the condition transitioned from one status to another. - // This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - // +required - optional k8s.io.apimachinery.pkg.apis.meta.v1.Time lastTransitionTime = 4; + // This should be when the underlying condition changed. If that is not known, then using the time when + // the API field changed is acceptable. + optional k8s.io.apimachinery.pkg.apis.meta.v1.Time lastTransitionTime = 7; // The reason for the condition's last transition in CamelCase. - // The specific API may choose whether or not this field is considered a guaranteed API. + // The specific API may choose whether this field is considered a guaranteed API. // This field may not be empty. - // +required - optional string reason = 5; + // +optional + optional string reason = 8; - // A human readable message indicating details about the transition. + // A human-readable message indicating details about the transition. // This field may be empty. - // +required - optional string message = 6; + // +optional + optional string message = 9; } // HealthCheckSpec defines attributes of the health check diff --git a/vendor/kmodules.xyz/client-go/api/v1/object.go b/vendor/kmodules.xyz/client-go/api/v1/object.go index eed83c3f..af38385e 100644 --- a/vendor/kmodules.xyz/client-go/api/v1/object.go +++ b/vendor/kmodules.xyz/client-go/api/v1/object.go @@ -144,6 +144,14 @@ func ParseObjectID(key OID) (*ObjectID, error) { return &id, nil } +func MustParseObjectID(key OID) *ObjectID { + oid, err := ParseObjectID(key) + if err != nil { + panic(err) + } + return oid +} + func ObjectIDMap(key OID) (map[string]interface{}, error) { id := map[string]interface{}{ "group": "", @@ -208,8 +216,8 @@ type ObjectInfo struct { Ref ObjectReference `json:"ref" protobuf:"bytes,2,opt,name=ref"` } -// +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) +// +kubebuilder:validation:Enum=authn;authz;backup_via;catalog;cert_issuer;config;connect_via;exposed_by;located_on;monitored_by;offshoot;ops;policy;recommended_for;restore_into;scaled_by;storage;view +// ENUM(authn,authz,backup_via,catalog,cert_issuer,config,connect_via,exposed_by,located_on,monitored_by,offshoot,ops,policy,recommended_for,restore_into,scaled_by,storage,view) type EdgeLabel string func (e EdgeLabel) Direct() bool { diff --git a/vendor/kmodules.xyz/client-go/api/v1/object_enum.go b/vendor/kmodules.xyz/client-go/api/v1/object_enum.go index 2309b52c..89ec818e 100644 --- a/vendor/kmodules.xyz/client-go/api/v1/object_enum.go +++ b/vendor/kmodules.xyz/client-go/api/v1/object_enum.go @@ -12,6 +12,10 @@ import ( ) const ( + // EdgeLabelAuthn is a EdgeLabel of type authn. + EdgeLabelAuthn EdgeLabel = "authn" + // EdgeLabelAuthz is a EdgeLabel of type authz. + EdgeLabelAuthz EdgeLabel = "authz" // EdgeLabelBackupVia is a EdgeLabel of type backup_via. EdgeLabelBackupVia EdgeLabel = "backup_via" // EdgeLabelCatalog is a EdgeLabel of type catalog. @@ -24,8 +28,6 @@ const ( EdgeLabelConnectVia EdgeLabel = "connect_via" // EdgeLabelExposedBy is a EdgeLabel of type exposed_by. EdgeLabelExposedBy EdgeLabel = "exposed_by" - // EdgeLabelId is a EdgeLabel of type id. - EdgeLabelId EdgeLabel = "id" // EdgeLabelLocatedOn is a EdgeLabel of type located_on. EdgeLabelLocatedOn EdgeLabel = "located_on" // EdgeLabelMonitoredBy is a EdgeLabel of type monitored_by. @@ -42,6 +44,8 @@ const ( EdgeLabelRestoreInto EdgeLabel = "restore_into" // EdgeLabelScaledBy is a EdgeLabel of type scaled_by. EdgeLabelScaledBy EdgeLabel = "scaled_by" + // EdgeLabelStorage is a EdgeLabel of type storage. + EdgeLabelStorage EdgeLabel = "storage" // EdgeLabelView is a EdgeLabel of type view. EdgeLabelView EdgeLabel = "view" ) @@ -49,13 +53,14 @@ const ( var ErrInvalidEdgeLabel = fmt.Errorf("not a valid EdgeLabel, try [%s]", strings.Join(_EdgeLabelNames, ", ")) var _EdgeLabelNames = []string{ + string(EdgeLabelAuthn), + string(EdgeLabelAuthz), string(EdgeLabelBackupVia), string(EdgeLabelCatalog), string(EdgeLabelCertIssuer), string(EdgeLabelConfig), string(EdgeLabelConnectVia), string(EdgeLabelExposedBy), - string(EdgeLabelId), string(EdgeLabelLocatedOn), string(EdgeLabelMonitoredBy), string(EdgeLabelOffshoot), @@ -64,6 +69,7 @@ var _EdgeLabelNames = []string{ string(EdgeLabelRecommendedFor), string(EdgeLabelRestoreInto), string(EdgeLabelScaledBy), + string(EdgeLabelStorage), string(EdgeLabelView), } @@ -77,13 +83,14 @@ func EdgeLabelNames() []string { // EdgeLabelValues returns a list of the values for EdgeLabel func EdgeLabelValues() []EdgeLabel { return []EdgeLabel{ + EdgeLabelAuthn, + EdgeLabelAuthz, EdgeLabelBackupVia, EdgeLabelCatalog, EdgeLabelCertIssuer, EdgeLabelConfig, EdgeLabelConnectVia, EdgeLabelExposedBy, - EdgeLabelId, EdgeLabelLocatedOn, EdgeLabelMonitoredBy, EdgeLabelOffshoot, @@ -92,6 +99,7 @@ func EdgeLabelValues() []EdgeLabel { EdgeLabelRecommendedFor, EdgeLabelRestoreInto, EdgeLabelScaledBy, + EdgeLabelStorage, EdgeLabelView, } } @@ -109,13 +117,14 @@ func (x EdgeLabel) IsValid() bool { } var _EdgeLabelValue = map[string]EdgeLabel{ + "authn": EdgeLabelAuthn, + "authz": EdgeLabelAuthz, "backup_via": EdgeLabelBackupVia, "catalog": EdgeLabelCatalog, "cert_issuer": EdgeLabelCertIssuer, "config": EdgeLabelConfig, "connect_via": EdgeLabelConnectVia, "exposed_by": EdgeLabelExposedBy, - "id": EdgeLabelId, "located_on": EdgeLabelLocatedOn, "monitored_by": EdgeLabelMonitoredBy, "offshoot": EdgeLabelOffshoot, @@ -124,6 +133,7 @@ var _EdgeLabelValue = map[string]EdgeLabel{ "recommended_for": EdgeLabelRecommendedFor, "restore_into": EdgeLabelRestoreInto, "scaled_by": EdgeLabelScaledBy, + "storage": EdgeLabelStorage, "view": EdgeLabelView, } diff --git a/vendor/kmodules.xyz/client-go/api/v1/openapi_generated.go b/vendor/kmodules.xyz/client-go/api/v1/openapi_generated.go index daeb1a75..e33f3756 100644 --- a/vendor/kmodules.xyz/client-go/api/v1/openapi_generated.go +++ b/vendor/kmodules.xyz/client-go/api/v1/openapi_generated.go @@ -233,11 +233,12 @@ func schema_kmodulesxyz_client_go_api_v1_Condition(ref common.ReferenceCallback) return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, + Description: "Condition defines an observation of a object operational state.", + Type: []string{"object"}, Properties: map[string]spec.Schema{ "type": { SchemaProps: spec.SchemaProps{ - Description: "Type of condition in CamelCase or in foo.example.com/CamelCase. Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important.", + Description: "Type of condition in CamelCase or in foo.example.com/CamelCase. Many .condition.type values are consistent across resources like Available, but because arbitrary util can be useful (see .node.status.util), the ability to deconflict is important.", Default: "", Type: []string{"string"}, Format: "", @@ -258,31 +259,36 @@ func schema_kmodulesxyz_client_go_api_v1_Condition(ref common.ReferenceCallback) Format: "int64", }, }, + "severity": { + SchemaProps: spec.SchemaProps{ + Description: "Severity provides an explicit classification of Reason code, so the users or machines can immediately understand the current situation and act accordingly. The Severity field MUST be set only when Status=False.", + Type: []string{"string"}, + Format: "", + }, + }, "lastTransitionTime": { SchemaProps: spec.SchemaProps{ - Description: "Last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.", + Description: "Last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.", Default: map[string]interface{}{}, Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), }, }, "reason": { SchemaProps: spec.SchemaProps{ - Description: "The reason for the condition's last transition in CamelCase. The specific API may choose whether or not this field is considered a guaranteed API. This field may not be empty.", - Default: "", + Description: "The reason for the condition's last transition in CamelCase. The specific API may choose whether this field is considered a guaranteed API. This field may not be empty.", Type: []string{"string"}, Format: "", }, }, "message": { SchemaProps: spec.SchemaProps{ - Description: "A human readable message indicating details about the transition. This field may be empty.", - Default: "", + Description: "A human-readable message indicating details about the transition. This field may be empty.", Type: []string{"string"}, Format: "", }, }, }, - Required: []string{"type", "status", "lastTransitionTime", "reason", "message"}, + Required: []string{"type", "status", "lastTransitionTime"}, }, }, Dependencies: []string{ diff --git a/vendor/kmodules.xyz/client-go/api/v1/zz_generated.deepcopy.go b/vendor/kmodules.xyz/client-go/api/v1/zz_generated.deepcopy.go index dd2040bf..85fa8084 100644 --- a/vendor/kmodules.xyz/client-go/api/v1/zz_generated.deepcopy.go +++ b/vendor/kmodules.xyz/client-go/api/v1/zz_generated.deepcopy.go @@ -136,6 +136,28 @@ func (in *Condition) DeepCopy() *Condition { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Conditions) DeepCopyInto(out *Conditions) { + { + in := &in + *out = make(Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Conditions. +func (in Conditions) DeepCopy() Conditions { + if in == nil { + return nil + } + out := new(Conditions) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HealthCheckSpec) DeepCopyInto(out *HealthCheckSpec) { *out = *in diff --git a/vendor/kmodules.xyz/client-go/apiextensions/kubernetes.go b/vendor/kmodules.xyz/client-go/apiextensions/kubernetes.go index 0316e88a..a628ca66 100644 --- a/vendor/kmodules.xyz/client-go/apiextensions/kubernetes.go +++ b/vendor/kmodules.xyz/client-go/apiextensions/kubernetes.go @@ -58,7 +58,7 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err }, metav1.UpdateOptions{}, ) - if err != nil { + if err != nil && !kerr.IsAlreadyExists(err) { return err } } diff --git a/vendor/kmodules.xyz/client-go/client/client.go b/vendor/kmodules.xyz/client-go/client/client.go index ae6f44eb..66b0b0d1 100644 --- a/vendor/kmodules.xyz/client-go/client/client.go +++ b/vendor/kmodules.xyz/client-go/client/client.go @@ -18,6 +18,7 @@ package client import ( "context" + "reflect" "strings" kmapi "kmodules.xyz/client-go/api/v1" @@ -68,12 +69,13 @@ type ( TransformStatusFunc func(obj client.Object) client.Object ) -func CreateOrPatch(ctx context.Context, c client.Client, obj client.Object, transform TransformFunc, opts ...client.PatchOption) (client.Object, kutil.VerbType, error) { +func CreateOrPatch(ctx context.Context, c client.Client, obj client.Object, transform TransformFunc, opts ...client.PatchOption) (kutil.VerbType, error) { + cur := obj.DeepCopyObject().(client.Object) key := types.NamespacedName{ - Namespace: obj.GetNamespace(), - Name: obj.GetName(), + Namespace: cur.GetNamespace(), + Name: cur.GetName(), } - err := c.Get(ctx, key, obj) + err := c.Get(ctx, key, cur) if kerr.IsNotFound(err) { klog.V(3).Infof("Creating %+v %s/%s.", obj.GetObjectKind().GroupVersionKind(), key.Namespace, key.Name) @@ -83,42 +85,58 @@ func CreateOrPatch(ctx context.Context, c client.Client, obj client.Object, tran createOpts = append(createOpts, opt) } } - obj = transform(obj.DeepCopyObject().(client.Object), true) - err := c.Create(ctx, obj, createOpts...) - return obj, kutil.VerbCreated, err + mod := transform(obj.DeepCopyObject().(client.Object), true) + err := c.Create(ctx, mod, createOpts...) + if err != nil { + return kutil.VerbUnchanged, err + } + + assign(obj, mod) + return kutil.VerbCreated, err } else if err != nil { - return nil, kutil.VerbUnchanged, err + return kutil.VerbUnchanged, err } gvk, err := apiutil.GVKForObject(obj, c.Scheme()) if err != nil { - return nil, kutil.VerbUnchanged, errors.Wrapf(err, "failed to get GVK for object %T", obj) + return kutil.VerbUnchanged, errors.Wrapf(err, "failed to get GVK for object %T", obj) } _, unstructuredObj := obj.(*unstructured.Unstructured) var patch client.Patch if isOfficialTypes(gvk.Group) && !unstructuredObj { - patch = client.StrategicMergeFrom(obj) + patch = client.StrategicMergeFrom(cur) } else { - patch = client.MergeFrom(obj) + patch = client.MergeFrom(cur) } - obj = transform(obj.DeepCopyObject().(client.Object), false) - err = c.Patch(ctx, obj, patch, opts...) + mod := transform(cur.DeepCopyObject().(client.Object), false) + err = c.Patch(ctx, mod, patch, opts...) if err != nil { - return nil, kutil.VerbUnchanged, err + return kutil.VerbUnchanged, err + } + + assign(obj, mod) + return kutil.VerbPatched, nil +} + +func assign(target, src any) { + srcValue := reflect.ValueOf(src) + if srcValue.Kind() == reflect.Pointer { + srcValue = srcValue.Elem() } - return obj, kutil.VerbPatched, nil + reflect.ValueOf(target).Elem().Set(srcValue) } -func PatchStatus(ctx context.Context, c client.Client, obj client.Object, transform TransformStatusFunc, opts ...client.PatchOption) (client.Object, kutil.VerbType, error) { +func PatchStatus(ctx context.Context, c client.Client, obj client.Object, transform TransformStatusFunc, opts ...client.PatchOption) (kutil.VerbType, error) { + cur := obj.DeepCopyObject().(client.Object) key := types.NamespacedName{ - Namespace: obj.GetNamespace(), - Name: obj.GetName(), + Namespace: cur.GetNamespace(), + Name: cur.GetName(), } - err := c.Get(ctx, key, obj) + err := c.Get(ctx, key, cur) if err != nil { - return nil, kutil.VerbUnchanged, err + return kutil.VerbUnchanged, err } // The body of the request was in an unknown format - @@ -126,13 +144,14 @@ func PatchStatus(ctx context.Context, c client.Client, obj client.Object, transf // - application/json-patch+json, // - application/merge-patch+json, // - application/apply-patch+yaml - patch := client.MergeFrom(obj) - obj = transform(obj.DeepCopyObject().(client.Object)) - err = c.Status().Patch(ctx, obj, patch, opts...) + patch := client.MergeFrom(cur) + mod := transform(cur.DeepCopyObject().(client.Object)) + err = c.Status().Patch(ctx, mod, patch, opts...) if err != nil { - return nil, kutil.VerbUnchanged, err + return kutil.VerbUnchanged, err } - return obj, kutil.VerbPatched, nil + assign(obj, mod) + return kutil.VerbPatched, nil } func isOfficialTypes(group string) bool { diff --git a/vendor/kmodules.xyz/client-go/tools/clientcmd/rest_config.go b/vendor/kmodules.xyz/client-go/tools/clientcmd/rest_config.go new file mode 100644 index 00000000..833e7b95 --- /dev/null +++ b/vendor/kmodules.xyz/client-go/tools/clientcmd/rest_config.go @@ -0,0 +1,74 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package clientcmd + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/rest" + clientcmdapi "k8s.io/client-go/tools/clientcmd/api" + clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest" +) + +// https://github.com/kubernetes/client-go/issues/711#issuecomment-730112049 +func GenerateKubeConfiguration(cfg *rest.Config, namespace string) ([]byte, error) { + if err := rest.LoadTLSFiles(cfg); err != nil { + return nil, err + } + + clusters := make(map[string]*clientcmdapi.Cluster) + clusters["default-cluster"] = &clientcmdapi.Cluster{ + Server: cfg.Host, + CertificateAuthorityData: cfg.CAData, + } + + contexts := make(map[string]*clientcmdapi.Context) + contexts["default-context"] = &clientcmdapi.Context{ + Cluster: "default-cluster", + Namespace: namespace, + AuthInfo: "default-user", + } + + authinfos := make(map[string]*clientcmdapi.AuthInfo) + authinfos["default-user"] = &clientcmdapi.AuthInfo{ + LocationOfOrigin: "", + ClientCertificate: "", + ClientCertificateData: cfg.CertData, + ClientKey: "", + ClientKeyData: cfg.KeyData, + Token: cfg.BearerToken, + TokenFile: "", + Impersonate: cfg.Impersonate.UserName, + ImpersonateUID: cfg.Impersonate.UID, + ImpersonateGroups: cfg.Impersonate.Groups, + ImpersonateUserExtra: cfg.Impersonate.Extra, + Username: cfg.Username, + Password: cfg.Password, + AuthProvider: cfg.AuthProvider, + Exec: cfg.ExecProvider, + Extensions: nil, + } + + clientConfig := clientcmdapi.Config{ + Kind: "Config", + APIVersion: "v1", + Clusters: clusters, + Contexts: contexts, + CurrentContext: "default-context", + AuthInfos: authinfos, + } + return runtime.Encode(clientcmdlatest.Codec, &clientConfig) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 482ab69a..b5c0c676 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -26,8 +26,8 @@ github.com/Masterminds/goutils # github.com/Masterminds/semver/v3 v3.1.1 ## explicit; go 1.12 github.com/Masterminds/semver/v3 -# github.com/Masterminds/sprig/v3 v3.2.2 -## explicit; go 1.13 +# github.com/Masterminds/sprig/v3 v3.2.2 => github.com/gomodules/sprig/v3 v3.2.3-0.20220405051441-0a8a99bac1b8 +## explicit; go 1.17 github.com/Masterminds/sprig/v3 # github.com/NYTimes/gziphandler v1.1.1 ## explicit; go 1.11 @@ -809,9 +809,13 @@ gomodules.xyz/flags # gomodules.xyz/go-sh v0.1.0 ## explicit; go 1.15 gomodules.xyz/go-sh -# gomodules.xyz/jsonpatch/v2 v2.3.0 +# gomodules.xyz/jsonpatch/v2 v2.4.0 ## explicit; go 1.20 gomodules.xyz/jsonpatch/v2 +# gomodules.xyz/jsonpath v0.0.2 +## explicit; go 1.16 +gomodules.xyz/jsonpath +gomodules.xyz/jsonpath/third_party/forked/golang/template # gomodules.xyz/logs v0.0.6 ## explicit; go 1.16 gomodules.xyz/logs @@ -1080,7 +1084,7 @@ k8s.io/apimachinery/pkg/version k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/json k8s.io/apimachinery/third_party/forked/golang/reflect -# k8s.io/apiserver v0.25.3 => github.com/kmodules/apiserver v0.25.2-0.20220917044909-4ac5fceca518 +# k8s.io/apiserver v0.25.3 => github.com/kmodules/apiserver v0.25.2-0.20230712090038-ce87ebac4a3d ## explicit; go 1.19 k8s.io/apiserver/pkg/admission k8s.io/apiserver/pkg/admission/configuration @@ -1578,7 +1582,7 @@ k8s.io/utils/trace # kmodules.xyz/apiversion v0.2.0 ## explicit; go 1.14 kmodules.xyz/apiversion -# kmodules.xyz/client-go v0.25.23 +# kmodules.xyz/client-go v0.25.30-0.20230816023640-cf58432a4653 ## explicit; go 1.18 kmodules.xyz/client-go kmodules.xyz/client-go/api/v1 @@ -1634,7 +1638,7 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client # sigs.k8s.io/cli-utils v0.33.0 ## explicit; go 1.17 sigs.k8s.io/cli-utils/pkg/kstatus/status -# sigs.k8s.io/controller-runtime v0.13.1 +# sigs.k8s.io/controller-runtime v0.13.1 => github.com/kmodules/controller-runtime v0.13.1-0.20230725210630-f8273f9c4412 ## explicit; go 1.17 sigs.k8s.io/controller-runtime sigs.k8s.io/controller-runtime/pkg/builder @@ -1774,8 +1778,10 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.3.0 ## explicit; go 1.12 sigs.k8s.io/yaml +# github.com/Masterminds/sprig/v3 => github.com/gomodules/sprig/v3 v3.2.3-0.20220405051441-0a8a99bac1b8 +# sigs.k8s.io/controller-runtime => github.com/kmodules/controller-runtime v0.13.1-0.20230725210630-f8273f9c4412 # github.com/imdario/mergo => github.com/imdario/mergo v0.3.6 -# k8s.io/apiserver => github.com/kmodules/apiserver v0.25.2-0.20220917044909-4ac5fceca518 +# k8s.io/apiserver => github.com/kmodules/apiserver v0.25.2-0.20230712090038-ce87ebac4a3d # k8s.io/kubernetes => github.com/kmodules/kubernetes v1.26.0-alpha.0.0.20220917022409-54ac9f3f1315 # go.opencensus.io => go.opencensus.io v0.23.0 # go.opentelemetry.io/contrib => go.opentelemetry.io/contrib v0.20.0 diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/cache/internal/cache_reader.go b/vendor/sigs.k8s.io/controller-runtime/pkg/cache/internal/cache_reader.go index 9c225512..852d0d73 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/cache/internal/cache_reader.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/cache/internal/cache_reader.go @@ -113,17 +113,60 @@ func (c *CacheReader) List(_ context.Context, out client.ObjectList, opts ...cli listOpts.ApplyOptions(opts) switch { - case listOpts.FieldSelector != nil: + // listOpts.FieldSelector.Empty() == true means select all + case listOpts.FieldSelector != nil && !listOpts.FieldSelector.Empty(): // TODO(directxman12): support more complicated field selectors by // combining multiple indices, GetIndexers, etc - field, val, requiresExact := requiresExactMatch(listOpts.FieldSelector) + requiresExact := requiresExactMatch(listOpts.FieldSelector) if !requiresExact { return fmt.Errorf("non-exact field matches are not supported by the cache") } - // list all objects by the field selector. If this is namespaced and we have one, ask for the - // namespaced index key. Otherwise, ask for the non-namespaced variant by using the fake "all namespaces" - // namespace. - objs, err = c.indexer.ByIndex(FieldIndexName(field), KeyToNamespacedKey(listOpts.Namespace, val)) + + reqs := listOpts.FieldSelector.Requirements() + // len(reqs) == 0 means, select nothing + if len(reqs) > 0 { + req := reqs[0] + // list all objects by the field selector. If this is namespaced and we have one, ask for the + // namespaced index key. Otherwise, ask for the non-namespaced variant by using the fake "all namespaces" + // namespace. + list, err := c.indexer.ByIndex(FieldIndexName(req.Field), KeyToNamespacedKey(listOpts.Namespace, req.Value)) + if err != nil { + return err + } + if len(reqs) > 1 { + objmap := make(map[client.ObjectKey]interface{}, len(list)) + for i := range list { + obj := list[i].(client.Object) + objmap[client.ObjectKey{Namespace: obj.GetNamespace(), Name: obj.GetName()}] = obj + } + for _, req := range reqs[1:] { + list, err := c.indexer.ByIndex(FieldIndexName(req.Field), KeyToNamespacedKey(listOpts.Namespace, req.Value)) + if err != nil { + return err + } + + numap := make(map[client.ObjectKey]interface{}, len(list)) + for i := range list { + obj := list[i].(client.Object) + key := client.ObjectKey{Namespace: obj.GetNamespace(), Name: obj.GetName()} + if o, exists := objmap[key]; exists { + if o.(client.Object).GetGeneration() == obj.GetGeneration() { + numap[key] = obj + } else { + return fmt.Errorf("multiple generation found in indices for %+v %s/%s", obj.GetObjectKind().GroupVersionKind(), obj.GetNamespace(), obj.GetName()) + } + } + } + objmap = numap + } + objs = make([]interface{}, 0, len(objmap)) + for _, obj := range objmap { + objs = append(objs, obj) + } + } else { + objs = list + } + } case listOpts.Namespace != "": objs, err = c.indexer.ByIndex(cache.NamespaceIndex, listOpts.Namespace) default: @@ -187,16 +230,14 @@ func objectKeyToStoreKey(k client.ObjectKey) string { } // requiresExactMatch checks if the given field selector is of the form `k=v` or `k==v`. -func requiresExactMatch(sel fields.Selector) (field, val string, required bool) { +func requiresExactMatch(sel fields.Selector) (required bool) { reqs := sel.Requirements() - if len(reqs) != 1 { - return "", "", false - } - req := reqs[0] - if req.Operator != selection.Equals && req.Operator != selection.DoubleEquals { - return "", "", false + for _, req := range reqs { + if req.Operator != selection.Equals && req.Operator != selection.DoubleEquals { + return false + } } - return req.Field, req.Value, true + return true } // FieldIndexName constructs the name of the index over the given field, diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/client/metadata_client.go b/vendor/sigs.k8s.io/controller-runtime/pkg/client/metadata_client.go index 2854556f..1e1b0cb4 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/client/metadata_client.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/client/metadata_client.go @@ -98,14 +98,14 @@ func (mc *metadataClient) Patch(ctx context.Context, obj Object, patch Patch, op return err } + patchOpts := &PatchOptions{} + patchOpts.ApplyOptions(opts) + data, err := patch.Data(obj) - if err != nil { + if err != nil || (!patchOpts.SendEmptyPatch && string(data) == "{}") { return err } - patchOpts := &PatchOptions{} - patchOpts.ApplyOptions(opts) - res, err := resInt.Patch(ctx, metadata.Name, patch.Type(), data, *patchOpts.AsPatchOptions()) if err != nil { return err @@ -180,12 +180,14 @@ func (mc *metadataClient) PatchStatus(ctx context.Context, obj Object, patch Pat return err } + patchOpts := &PatchOptions{} + patchOpts.ApplyOptions(opts) + data, err := patch.Data(obj) - if err != nil { + if err != nil || (!patchOpts.SendEmptyPatch && string(data) == "{}") { return err } - patchOpts := &PatchOptions{} res, err := resInt.Patch(ctx, metadata.Name, patch.Type(), data, *patchOpts.AsPatchOptions(), "status") if err != nil { return err diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/client/options.go b/vendor/sigs.k8s.io/controller-runtime/pkg/client/options.go index 495b8694..0edf4f04 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/client/options.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/client/options.go @@ -368,7 +368,7 @@ type ListOptions struct { LabelSelector labels.Selector // FieldSelector filters results by a particular field. In order // to use this with cache-based implementations, restrict usage to - // a single field-value pair that's been added to the indexers. + // field-value pair exact matches that's been added to the indexers. FieldSelector fields.Selector // Namespace represents the namespace to list for, or empty for @@ -652,6 +652,9 @@ type PatchOptions struct { // Raw represents raw PatchOptions, as passed to the API server. Raw *metav1.PatchOptions + + // SendEmptyPatch is going to send empty patch calls to the API server. + SendEmptyPatch bool } // ApplyOptions applies the given patch options on these options, @@ -709,6 +712,16 @@ func (forceOwnership) ApplyToPatch(opts *PatchOptions) { opts.Force = &definitelyTrue } +// SendEmptyPatch sets the "sendEmptyPatch" option to true. +var SendEmptyPatch = sendEmptyPatch{} + +type sendEmptyPatch struct{} + +// ApplyToPatch applies this configuration to the given patch options. +func (sendEmptyPatch) ApplyToPatch(opts *PatchOptions) { + opts.SendEmptyPatch = true +} + // }}} // {{{ DeleteAllOf Options diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/client/typed_client.go b/vendor/sigs.k8s.io/controller-runtime/pkg/client/typed_client.go index c4e56d9b..a7fbc1ff 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/client/typed_client.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/client/typed_client.go @@ -115,17 +115,19 @@ func (c *typedClient) Patch(ctx context.Context, obj Object, patch Patch, opts . return err } + patchOpts := &PatchOptions{} + patchOpts.ApplyOptions(opts) + data, err := patch.Data(obj) - if err != nil { + if err != nil || (!patchOpts.SendEmptyPatch && string(data) == "{}") { return err } - patchOpts := &PatchOptions{} return o.Patch(patch.Type()). NamespaceIfScoped(o.GetNamespace(), o.isNamespaced()). Resource(o.resource()). Name(o.GetName()). - VersionedParams(patchOpts.ApplyOptions(opts).AsPatchOptions(), c.paramCodec). + VersionedParams(patchOpts.AsPatchOptions(), c.paramCodec). Body(data). Do(ctx). Into(obj) @@ -190,19 +192,21 @@ func (c *typedClient) PatchStatus(ctx context.Context, obj Object, patch Patch, return err } + patchOpts := &PatchOptions{} + patchOpts.ApplyOptions(opts) + data, err := patch.Data(obj) - if err != nil { + if err != nil || (!patchOpts.SendEmptyPatch && string(data) == "{}") { return err } - patchOpts := &PatchOptions{} return o.Patch(patch.Type()). NamespaceIfScoped(o.GetNamespace(), o.isNamespaced()). Resource(o.resource()). Name(o.GetName()). SubResource("status"). Body(data). - VersionedParams(patchOpts.ApplyOptions(opts).AsPatchOptions(), c.paramCodec). + VersionedParams(patchOpts.AsPatchOptions(), c.paramCodec). Do(ctx). Into(obj) } diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/client/unstructured_client.go b/vendor/sigs.k8s.io/controller-runtime/pkg/client/unstructured_client.go index 3d3dbe7b..1c00661d 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/client/unstructured_client.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/client/unstructured_client.go @@ -148,17 +148,19 @@ func (uc *unstructuredClient) Patch(ctx context.Context, obj Object, patch Patch return err } + patchOpts := &PatchOptions{} + patchOpts.ApplyOptions(opts) + data, err := patch.Data(obj) - if err != nil { + if err != nil || (!patchOpts.SendEmptyPatch && string(data) == "{}") { return err } - patchOpts := &PatchOptions{} return o.Patch(patch.Type()). NamespaceIfScoped(o.GetNamespace(), o.isNamespaced()). Resource(o.resource()). Name(o.GetName()). - VersionedParams(patchOpts.ApplyOptions(opts).AsPatchOptions(), uc.paramCodec). + VersionedParams(patchOpts.AsPatchOptions(), uc.paramCodec). Body(data). Do(ctx). Into(obj) @@ -254,19 +256,21 @@ func (uc *unstructuredClient) PatchStatus(ctx context.Context, obj Object, patch return err } + patchOpts := &PatchOptions{} + patchOpts.ApplyOptions(opts) + data, err := patch.Data(obj) - if err != nil { + if err != nil || (!patchOpts.SendEmptyPatch && string(data) == "{}") { return err } - patchOpts := &PatchOptions{} result := o.Patch(patch.Type()). NamespaceIfScoped(o.GetNamespace(), o.isNamespaced()). Resource(o.resource()). Name(o.GetName()). SubResource("status"). Body(data). - VersionedParams(patchOpts.ApplyOptions(opts).AsPatchOptions(), uc.paramCodec). + VersionedParams(patchOpts.AsPatchOptions(), uc.paramCodec). Do(ctx). Into(u) diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/manager/internal.go b/vendor/sigs.k8s.io/controller-runtime/pkg/manager/internal.go index fb79c554..5b22c628 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/manager/internal.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/manager/internal.go @@ -18,7 +18,6 @@ package manager import ( "context" - "crypto/tls" "errors" "fmt" "net" @@ -136,8 +135,6 @@ type controllerManager struct { // if not set, webhook server would look up the server key and certificate in // {TempDir}/k8s-webhook-server/serving-certs certDir string - // tlsOpts is used to allow configuring the TLS config used for the webhook server. - tlsOpts []func(*tls.Config) webhookServer *webhook.Server // webhookServerOnce will be called in GetWebhookServer() to optionally initialize @@ -308,7 +305,6 @@ func (cm *controllerManager) GetWebhookServer() *webhook.Server { Port: cm.port, Host: cm.host, CertDir: cm.certDir, - TLSOpts: cm.tlsOpts, } } if err := cm.Add(cm.webhookServer); err != nil { diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/manager/manager.go b/vendor/sigs.k8s.io/controller-runtime/pkg/manager/manager.go index 2b28fa4b..53716aa9 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/manager/manager.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/manager/manager.go @@ -18,7 +18,6 @@ package manager import ( "context" - "crypto/tls" "fmt" "net" "net/http" @@ -242,9 +241,6 @@ type Options struct { // It is used to set webhook.Server.CertDir if WebhookServer is not set. CertDir string - // TLSOpts is used to allow configuring the TLS config used for the webhook server. - TLSOpts []func(*tls.Config) - // WebhookServer is an externally configured webhook.Server. By default, // a Manager will create a default server using Port, Host, and CertDir; // if this is set, the Manager will use this server instead. @@ -425,7 +421,6 @@ func New(config *rest.Config, options Options) (Manager, error) { port: options.Port, host: options.Host, certDir: options.CertDir, - tlsOpts: options.TLSOpts, webhookServer: options.WebhookServer, leaseDuration: *options.LeaseDuration, renewDeadline: *options.RenewDeadline,