mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Merge pull request #120506 from alexzielenski/import-restrictions
Update e2e import restrictions
This commit is contained in:
commit
a68093a3ff
2
go.mod
2
go.mod
@ -110,7 +110,7 @@ require (
|
||||
k8s.io/csi-translation-lib v0.0.0
|
||||
k8s.io/dynamic-resource-allocation v0.0.0
|
||||
k8s.io/endpointslice v0.0.0
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01
|
||||
k8s.io/klog/v2 v2.100.1
|
||||
k8s.io/kms v0.0.0
|
||||
k8s.io/kube-aggregator v0.0.0
|
||||
|
4
go.sum
4
go.sum
@ -1417,8 +1417,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d h1:U9tB195lKdzwqicbJvyJeOXV7Klv+wNAWENRnXEGi08=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
|
@ -23,7 +23,7 @@ package v1alpha1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
cloudproviderconfigv1alpha1 "k8s.io/cloud-provider/config/v1alpha1"
|
||||
configv1alpha1 "k8s.io/cloud-provider/config/v1alpha1"
|
||||
v1alpha1 "k8s.io/kube-controller-manager/config/v1alpha1"
|
||||
)
|
||||
|
||||
@ -39,5 +39,5 @@ func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
|
||||
func SetObjectDefaults_KubeControllerManagerConfiguration(in *v1alpha1.KubeControllerManagerConfiguration) {
|
||||
SetDefaults_KubeControllerManagerConfiguration(in)
|
||||
cloudproviderconfigv1alpha1.SetDefaults_KubeCloudSharedConfiguration(&in.KubeCloudShared)
|
||||
configv1alpha1.SetDefaults_KubeCloudSharedConfiguration(&in.KubeCloudShared)
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ require (
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
|
||||
k8s.io/kms v0.0.0 // indirect
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect
|
||||
)
|
||||
|
@ -824,8 +824,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d h1:U9tB195lKdzwqicbJvyJeOXV7Klv+wNAWENRnXEGi08=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
|
||||
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
|
@ -9,7 +9,7 @@ require (
|
||||
github.com/google/gnostic-models v0.6.8
|
||||
github.com/spf13/pflag v1.0.5
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01
|
||||
k8s.io/klog/v2 v2.100.1
|
||||
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9
|
||||
)
|
||||
|
4
staging/src/k8s.io/code-generator/go.sum
generated
4
staging/src/k8s.io/code-generator/go.sum
generated
@ -141,8 +141,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d h1:U9tB195lKdzwqicbJvyJeOXV7Klv+wNAWENRnXEGi08=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
|
||||
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
|
@ -104,7 +104,7 @@ require (
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
|
||||
k8s.io/kms v0.0.0 // indirect
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||
|
4
staging/src/k8s.io/kube-aggregator/go.sum
generated
4
staging/src/k8s.io/kube-aggregator/go.sum
generated
@ -799,8 +799,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d h1:U9tB195lKdzwqicbJvyJeOXV7Klv+wNAWENRnXEGi08=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
|
||||
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
|
2
staging/src/k8s.io/kubectl/go.sum
generated
2
staging/src/k8s.io/kubectl/go.sum
generated
@ -318,7 +318,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
|
||||
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ=
|
||||
|
@ -48,7 +48,7 @@ require (
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
|
||||
k8s.io/klog/v2 v2.100.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
|
||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
|
||||
|
4
staging/src/k8s.io/metrics/go.sum
generated
4
staging/src/k8s.io/metrics/go.sum
generated
@ -162,8 +162,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d h1:U9tB195lKdzwqicbJvyJeOXV7Klv+wNAWENRnXEGi08=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
|
||||
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
|
@ -100,7 +100,7 @@ require (
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/api v0.0.0 // indirect
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
|
||||
k8s.io/klog/v2 v2.100.1 // indirect
|
||||
k8s.io/kms v0.0.0 // indirect
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect
|
||||
|
4
staging/src/k8s.io/sample-apiserver/go.sum
generated
4
staging/src/k8s.io/sample-apiserver/go.sum
generated
@ -798,8 +798,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d h1:U9tB195lKdzwqicbJvyJeOXV7Klv+wNAWENRnXEGi08=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
|
||||
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
|
@ -49,7 +49,7 @@ require (
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
|
||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
|
||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||
|
4
staging/src/k8s.io/sample-controller/go.sum
generated
4
staging/src/k8s.io/sample-controller/go.sum
generated
@ -164,8 +164,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d h1:U9tB195lKdzwqicbJvyJeOXV7Klv+wNAWENRnXEGi08=
|
||||
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=
|
||||
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
|
||||
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
|
@ -11,14 +11,49 @@ rules:
|
||||
- selectorRegexp: ^[a-z]+(/|$)
|
||||
allowedPrefixes: [ "" ]
|
||||
|
||||
# Ginkgo + Gomega.
|
||||
# stdlib x and proto
|
||||
- selectorRegexp: ^golang.org/x|^google.golang.org/protobuf
|
||||
allowedPrefixes: [ "" ]
|
||||
|
||||
# Ginkgo + Gomega
|
||||
- selectorRegexp: github.com/onsi/(ginkgo|gomega)|^k8s[.]io/kubernetes/test/(e2e/framework/internal/|utils)
|
||||
allowedPrefixes: [ "" ]
|
||||
|
||||
# kube-openapi
|
||||
- selectorRegexp: ^k8s.io/kube-openapi
|
||||
allowedPrefixes: [ "" ]
|
||||
|
||||
# Public SIG Repos
|
||||
- selectorRegexp: ^sigs.k8s.io/(json|yaml|structured-merge-diff)
|
||||
allowedPrefixes: [ "" ]
|
||||
|
||||
# some of the shared test helpers (but not E2E sub-packages!)
|
||||
- selectorRegexp: ^k8s[.]io/kubernetes/test/(e2e/framework/internal/|utils)
|
||||
allowedPrefixes: [ "" ]
|
||||
|
||||
# Third party deps
|
||||
- selectorRegexp: ^github.com/|^gopkg.in
|
||||
allowedPrefixes: [
|
||||
"gopkg.in/inf.v0",
|
||||
"github.com/davecgh/go-spew/spew",
|
||||
"github.com/evanphx/json-patch",
|
||||
"github.com/go-logr/logr",
|
||||
"github.com/gogo/protobuf/proto",
|
||||
"github.com/gogo/protobuf/sortkeys",
|
||||
"github.com/golang/protobuf/proto",
|
||||
"github.com/google/gnostic-models/openapiv2",
|
||||
"github.com/google/gnostic-models/openapiv3",
|
||||
"github.com/google/go-cmp/cmp",
|
||||
"github.com/google/go-cmp/cmp/cmpopts",
|
||||
"github.com/google/gofuzz",
|
||||
"github.com/google/uuid",
|
||||
"github.com/imdario/mergo",
|
||||
"github.com/spf13/cobra",
|
||||
"github.com/spf13/pflag",
|
||||
"github.com/stretchr/testify/assert",
|
||||
"github.com/stretchr/testify/require"
|
||||
]
|
||||
|
||||
# Everything else isn't.
|
||||
#
|
||||
# In particular importing any test/e2e/framework/* package would be a
|
||||
|
@ -5,6 +5,7 @@ rules:
|
||||
- k8s.io/kubernetes/test/e2e/common
|
||||
- k8s.io/kubernetes/test/e2e/dra/test-driver/app
|
||||
- k8s.io/kubernetes/test/e2e/framework
|
||||
- k8s.io/kubernetes/test/e2e/storage/utils
|
||||
- k8s.io/kubernetes/test/e2e/network/common
|
||||
- k8s.io/kubernetes/test/e2e/perftype
|
||||
- k8s.io/kubernetes/test/e2e/testing-manifests
|
||||
|
19
vendor/k8s.io/gengo/args/args.go
generated
vendored
19
vendor/k8s.io/gengo/args/args.go
generated
vendored
@ -32,7 +32,6 @@ import (
|
||||
"k8s.io/gengo/generator"
|
||||
"k8s.io/gengo/namer"
|
||||
"k8s.io/gengo/parser"
|
||||
"k8s.io/gengo/types"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
@ -155,24 +154,6 @@ func (g *GeneratorArgs) NewBuilder() (*parser.Builder, error) {
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// InputIncludes returns true if the given package is a (sub) package of one of
|
||||
// the InputDirs.
|
||||
func (g *GeneratorArgs) InputIncludes(p *types.Package) bool {
|
||||
for _, dir := range g.InputDirs {
|
||||
d := dir
|
||||
if strings.HasSuffix(d, "...") {
|
||||
d = strings.TrimSuffix(d, "...")
|
||||
}
|
||||
if strings.HasPrefix(d, "./vendor/") {
|
||||
d = strings.TrimPrefix(d, "./vendor/")
|
||||
}
|
||||
if strings.HasPrefix(p.Path, d) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// DefaultSourceTree returns the /src directory of the first entry in $GOPATH.
|
||||
// If $GOPATH is empty, it returns "./". Useful as a default output location.
|
||||
func DefaultSourceTree() string {
|
||||
|
14
vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go
generated
vendored
14
vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go
generated
vendored
@ -173,19 +173,25 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
pkgNeedsGeneration := (ptagValue == tagValuePackage)
|
||||
if !pkgNeedsGeneration {
|
||||
// If the pkg-scoped tag did not exist, scan all types for one that
|
||||
// explicitly wants generation.
|
||||
// explicitly wants generation. Ensure all types that want generation
|
||||
// can be copied.
|
||||
var uncopyable []string
|
||||
for _, t := range pkg.Types {
|
||||
klog.V(5).Infof(" considering type %q", t.Name.String())
|
||||
ttag := extractEnabledTypeTag(t)
|
||||
if ttag != nil && ttag.value == "true" {
|
||||
klog.V(5).Infof(" tag=true")
|
||||
if !copyableType(t) {
|
||||
klog.Fatalf("Type %v requests deepcopy generation but is not copyable", t)
|
||||
uncopyable = append(uncopyable, fmt.Sprintf("%v", t))
|
||||
} else {
|
||||
pkgNeedsGeneration = true
|
||||
}
|
||||
pkgNeedsGeneration = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(uncopyable) > 0 {
|
||||
klog.Fatalf("Types requested deepcopy generation but are not copyable: %s",
|
||||
strings.Join(uncopyable, ", "))
|
||||
}
|
||||
}
|
||||
|
||||
if pkgNeedsGeneration {
|
||||
|
267
vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go
generated
vendored
267
vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go
generated
vendored
@ -23,6 +23,7 @@ import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -441,6 +442,8 @@ func newCallTreeForType(existingDefaulters, newDefaulters defaulterFuncMap) *cal
|
||||
}
|
||||
}
|
||||
|
||||
// resolveType follows pointers and aliases of `t` until reaching the first
|
||||
// non-pointer type in `t's` herarchy
|
||||
func resolveTypeAndDepth(t *types.Type) (*types.Type, int) {
|
||||
var prev *types.Type
|
||||
depth := 0
|
||||
@ -456,6 +459,42 @@ func resolveTypeAndDepth(t *types.Type) (*types.Type, int) {
|
||||
return t, depth
|
||||
}
|
||||
|
||||
// getPointerElementPath follows pointers and aliases to returns all
|
||||
// pointer elements in the path from the given type, to its base value type.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// type MyString string
|
||||
// type MyStringPointer *MyString
|
||||
// type MyStringPointerPointer *MyStringPointer
|
||||
// type MyStringAlias MyStringPointer
|
||||
// type MyStringAliasPointer *MyStringAlias
|
||||
// type MyStringAliasDoublePointer **MyStringAlias
|
||||
//
|
||||
// t | defaultPointerElementPath(t)
|
||||
// ---------------------------|----------------------------------------
|
||||
// MyString | []
|
||||
// MyStringPointer | [MyString]
|
||||
// MyStringPointerPointer | [MyStringPointer, MyString]
|
||||
// MyStringAlias | [MyStringPointer, MyString]
|
||||
// MyStringAliasPointer | [MyStringAlias, MyStringPointer, MyString]
|
||||
// MyStringAliasDoublePointer | [*MyStringAlias, MyStringAlias, MyStringPointer, MyString]
|
||||
func getPointerElementPath(t *types.Type) []*types.Type {
|
||||
var path []*types.Type
|
||||
for t != nil {
|
||||
switch t.Kind {
|
||||
case types.Alias:
|
||||
t = t.Underlying
|
||||
case types.Pointer:
|
||||
t = t.Elem
|
||||
path = append(path, t)
|
||||
default:
|
||||
t = nil
|
||||
}
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// getNestedDefault returns the first default value when resolving alias types
|
||||
func getNestedDefault(t *types.Type) string {
|
||||
var prev *types.Type
|
||||
@ -497,29 +536,57 @@ func mustEnforceDefault(t *types.Type, depth int, omitEmpty bool) (interface{},
|
||||
}
|
||||
}
|
||||
|
||||
func populateDefaultValue(node *callNode, t *types.Type, tags string, commentLines []string) *callNode {
|
||||
var refRE = regexp.MustCompile(`^ref\((?P<reference>[^"]+)\)$`)
|
||||
var refREIdentIndex = refRE.SubexpIndex("reference")
|
||||
|
||||
// ParseSymbolReference looks for strings that match one of the following:
|
||||
// - ref(Ident)
|
||||
// - ref(pkgpath.Ident)
|
||||
// If the input string matches either of these, it will return the (optional)
|
||||
// pkgpath, the Ident, and true. Otherwise it will return empty strings and
|
||||
// false.
|
||||
func ParseSymbolReference(s, sourcePackage string) (types.Name, bool) {
|
||||
matches := refRE.FindStringSubmatch(s)
|
||||
if len(matches) < refREIdentIndex || matches[refREIdentIndex] == "" {
|
||||
return types.Name{}, false
|
||||
}
|
||||
|
||||
contents := matches[refREIdentIndex]
|
||||
name := types.ParseFullyQualifiedName(contents)
|
||||
if len(name.Package) == 0 {
|
||||
name.Package = sourcePackage
|
||||
}
|
||||
return name, true
|
||||
}
|
||||
|
||||
func populateDefaultValue(node *callNode, t *types.Type, tags string, commentLines []string, commentPackage string) *callNode {
|
||||
defaultMap := extractDefaultTag(commentLines)
|
||||
var defaultString string
|
||||
if len(defaultMap) == 1 {
|
||||
defaultString = defaultMap[0]
|
||||
} else if len(defaultMap) > 1 {
|
||||
klog.Fatalf("Found more than one default tag for %v", t.Kind)
|
||||
}
|
||||
|
||||
t, depth := resolveTypeAndDepth(t)
|
||||
baseT, depth := resolveTypeAndDepth(t)
|
||||
if depth > 0 && defaultString == "" {
|
||||
defaultString = getNestedDefault(t)
|
||||
}
|
||||
if len(defaultMap) > 1 {
|
||||
klog.Fatalf("Found more than one default tag for %v", t.Kind)
|
||||
} else if len(defaultMap) == 0 {
|
||||
|
||||
if len(defaultString) == 0 {
|
||||
return node
|
||||
}
|
||||
var symbolReference types.Name
|
||||
var defaultValue interface{}
|
||||
if err := json.Unmarshal([]byte(defaultString), &defaultValue); err != nil {
|
||||
if id, ok := ParseSymbolReference(defaultString, commentPackage); ok {
|
||||
symbolReference = id
|
||||
defaultString = ""
|
||||
} else if err := json.Unmarshal([]byte(defaultString), &defaultValue); err != nil {
|
||||
klog.Fatalf("Failed to unmarshal default: %v", err)
|
||||
}
|
||||
|
||||
omitEmpty := strings.Contains(reflect.StructTag(tags).Get("json"), "omitempty")
|
||||
if enforced, err := mustEnforceDefault(t, depth, omitEmpty); err != nil {
|
||||
if enforced, err := mustEnforceDefault(baseT, depth, omitEmpty); err != nil {
|
||||
klog.Fatal(err)
|
||||
} else if enforced != nil {
|
||||
if defaultValue != nil {
|
||||
@ -540,10 +607,11 @@ func populateDefaultValue(node *callNode, t *types.Type, tags string, commentLin
|
||||
node.markerOnly = true
|
||||
}
|
||||
|
||||
node.defaultIsPrimitive = t.IsPrimitive()
|
||||
node.defaultType = t.String()
|
||||
node.defaultValue = defaultString
|
||||
node.defaultDepth = depth
|
||||
node.defaultIsPrimitive = baseT.IsPrimitive()
|
||||
node.defaultType = baseT
|
||||
node.defaultTopLevelType = t
|
||||
node.defaultValue.InlineConstant = defaultString
|
||||
node.defaultValue.SymbolReference = symbolReference
|
||||
return node
|
||||
}
|
||||
|
||||
@ -619,7 +687,7 @@ func (c *callTreeForType) build(t *types.Type, root bool) *callNode {
|
||||
child.elem = true
|
||||
}
|
||||
parent.children = append(parent.children, *child)
|
||||
} else if member := populateDefaultValue(nil, t.Elem, "", t.Elem.CommentLines); member != nil {
|
||||
} else if member := populateDefaultValue(nil, t.Elem, "", t.Elem.CommentLines, t.Elem.Name.Package); member != nil {
|
||||
member.index = true
|
||||
parent.children = append(parent.children, *member)
|
||||
}
|
||||
@ -627,7 +695,7 @@ func (c *callTreeForType) build(t *types.Type, root bool) *callNode {
|
||||
if child := c.build(t.Elem, false); child != nil {
|
||||
child.key = true
|
||||
parent.children = append(parent.children, *child)
|
||||
} else if member := populateDefaultValue(nil, t.Elem, "", t.Elem.CommentLines); member != nil {
|
||||
} else if member := populateDefaultValue(nil, t.Elem, "", t.Elem.CommentLines, t.Elem.Name.Package); member != nil {
|
||||
member.key = true
|
||||
parent.children = append(parent.children, *member)
|
||||
}
|
||||
@ -644,9 +712,9 @@ func (c *callTreeForType) build(t *types.Type, root bool) *callNode {
|
||||
}
|
||||
if child := c.build(field.Type, false); child != nil {
|
||||
child.field = name
|
||||
populateDefaultValue(child, field.Type, field.Tags, field.CommentLines)
|
||||
populateDefaultValue(child, field.Type, field.Tags, field.CommentLines, field.Type.Name.Package)
|
||||
parent.children = append(parent.children, *child)
|
||||
} else if member := populateDefaultValue(nil, field.Type, field.Tags, field.CommentLines); member != nil {
|
||||
} else if member := populateDefaultValue(nil, field.Type, field.Tags, field.CommentLines, t.Name.Package); member != nil {
|
||||
member.field = name
|
||||
parent.children = append(parent.children, *member)
|
||||
}
|
||||
@ -690,7 +758,7 @@ func NewGenDefaulter(sanitizedName, typesPackage, outputPackage string, existing
|
||||
peerPackages: peerPkgs,
|
||||
newDefaulters: newDefaulters,
|
||||
existingDefaulters: existingDefaulters,
|
||||
imports: generator.NewImportTracker(),
|
||||
imports: generator.NewImportTrackerForPackage(outputPackage),
|
||||
typesForInit: make([]*types.Type, 0),
|
||||
}
|
||||
}
|
||||
@ -766,6 +834,15 @@ func (g *genDefaulter) GenerateType(c *generator.Context, t *types.Type, w io.Wr
|
||||
}
|
||||
i := 0
|
||||
callTree.VisitInOrder(func(ancestors []*callNode, current *callNode) {
|
||||
if ref := ¤t.defaultValue.SymbolReference; len(ref.Name) > 0 {
|
||||
// Ensure package for symbol is imported in output generation
|
||||
g.imports.AddSymbol(*ref)
|
||||
|
||||
// Rewrite the fully qualified name using the local package name
|
||||
// from the imports
|
||||
ref.Package = g.imports.LocalNameOf(ref.Package)
|
||||
}
|
||||
|
||||
if len(current.call) == 0 {
|
||||
return
|
||||
}
|
||||
@ -795,26 +872,26 @@ func (g *genDefaulter) generateDefaulter(inType *types.Type, callTree *callNode,
|
||||
// how in Go code an access would be performed. For example, if a defaulting function exists on a container
|
||||
// lifecycle hook, to invoke that defaulter correctly would require this Go code:
|
||||
//
|
||||
// for i := range pod.Spec.Containers {
|
||||
// o := &pod.Spec.Containers[i]
|
||||
// if o.LifecycleHook != nil {
|
||||
// SetDefaults_LifecycleHook(o.LifecycleHook)
|
||||
// }
|
||||
// }
|
||||
// for i := range pod.Spec.Containers {
|
||||
// o := &pod.Spec.Containers[i]
|
||||
// if o.LifecycleHook != nil {
|
||||
// SetDefaults_LifecycleHook(o.LifecycleHook)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// That would be represented by a call tree like:
|
||||
//
|
||||
// callNode
|
||||
// field: "Spec"
|
||||
// children:
|
||||
// - field: "Containers"
|
||||
// children:
|
||||
// - index: true
|
||||
// children:
|
||||
// - field: "LifecycleHook"
|
||||
// elem: true
|
||||
// call:
|
||||
// - SetDefaults_LifecycleHook
|
||||
// callNode
|
||||
// field: "Spec"
|
||||
// children:
|
||||
// - field: "Containers"
|
||||
// children:
|
||||
// - index: true
|
||||
// children:
|
||||
// - field: "LifecycleHook"
|
||||
// elem: true
|
||||
// call:
|
||||
// - SetDefaults_LifecycleHook
|
||||
//
|
||||
// which we can traverse to build that Go struct (you must call the field Spec, then Containers, then range over
|
||||
// that field, then check whether the LifecycleHook field is nil, before calling SetDefaults_LifecycleHook on
|
||||
@ -836,7 +913,7 @@ type callNode struct {
|
||||
|
||||
// defaultValue is the defaultValue of a callNode struct
|
||||
// Only primitive types and pointer types are eligible to have a default value
|
||||
defaultValue string
|
||||
defaultValue defaultValue
|
||||
|
||||
// defaultIsPrimitive is used to determine how to assign the default value.
|
||||
// Primitive types will be directly assigned while complex types will use JSON unmarshalling
|
||||
@ -845,21 +922,41 @@ type callNode struct {
|
||||
// markerOnly is true if the callNode exists solely to fill in a default value
|
||||
markerOnly bool
|
||||
|
||||
// defaultDepth is used to determine pointer level of the default value
|
||||
// For example 1 corresponds to setting a default value and taking its pointer while
|
||||
// 2 corresponds to setting a default value and taking its pointer's pointer
|
||||
// 0 implies that no pointers are used
|
||||
// This is used in situations where a field is a pointer to a primitive value rather than a primitive value itself.
|
||||
// defaultType is the transitive underlying/element type of the node.
|
||||
// The provided default value literal or reference is expected to be
|
||||
// convertible to this type.
|
||||
//
|
||||
// type A {
|
||||
// +default="foo"
|
||||
// Field *string
|
||||
// }
|
||||
defaultDepth int
|
||||
|
||||
// defaultType is the type of the default value.
|
||||
// e.g:
|
||||
// node type = *string -> defaultType = string
|
||||
// node type = StringPointerAlias -> defaultType = string
|
||||
// Only populated if defaultIsPrimitive is true
|
||||
defaultType string
|
||||
defaultType *types.Type
|
||||
|
||||
// defaultTopLevelType is the final type the value should resolve to
|
||||
// This is in constrast with default type, which resolves aliases and pointers.
|
||||
defaultTopLevelType *types.Type
|
||||
}
|
||||
|
||||
type defaultValue struct {
|
||||
// The value was written directly in the marker comment and
|
||||
// has been parsed as JSON
|
||||
InlineConstant string
|
||||
// The name of the symbol relative to the parsed package path
|
||||
// i.e. k8s.io/pkg.apis.v1.Foo if from another package or simply `Foo`
|
||||
// if within the same package.
|
||||
SymbolReference types.Name
|
||||
}
|
||||
|
||||
func (d defaultValue) IsEmpty() bool {
|
||||
resolved := d.Resolved()
|
||||
return resolved == ""
|
||||
}
|
||||
|
||||
func (d defaultValue) Resolved() string {
|
||||
if len(d.InlineConstant) > 0 {
|
||||
return d.InlineConstant
|
||||
}
|
||||
return d.SymbolReference.String()
|
||||
}
|
||||
|
||||
// CallNodeVisitorFunc is a function for visiting a call tree. ancestors is the list of all parents
|
||||
@ -929,15 +1026,14 @@ func getTypeZeroValue(t string) (interface{}, error) {
|
||||
}
|
||||
|
||||
func (n *callNode) writeDefaulter(varName string, index string, isVarPointer bool, sw *generator.SnippetWriter) {
|
||||
if n.defaultValue == "" {
|
||||
if n.defaultValue.IsEmpty() {
|
||||
return
|
||||
}
|
||||
args := generator.Args{
|
||||
"defaultValue": n.defaultValue,
|
||||
"defaultValue": n.defaultValue.Resolved(),
|
||||
"varName": varName,
|
||||
"index": index,
|
||||
"varDepth": n.defaultDepth,
|
||||
"varType": n.defaultType,
|
||||
"varTopType": n.defaultTopLevelType,
|
||||
}
|
||||
|
||||
variablePlaceholder := ""
|
||||
@ -961,25 +1057,72 @@ func (n *callNode) writeDefaulter(varName string, index string, isVarPointer boo
|
||||
if n.defaultIsPrimitive {
|
||||
// If the default value is a primitive when the assigned type is a pointer
|
||||
// keep using the address-of operator on the primitive value until the types match
|
||||
if n.defaultDepth > 0 {
|
||||
sw.Do(fmt.Sprintf("if %s == nil {\n", variablePlaceholder), args)
|
||||
sw.Do("var ptrVar$.varDepth$ $.varType$ = $.defaultValue$\n", args)
|
||||
// We iterate until a depth of 1 instead of 0 because the following line
|
||||
// `if $.varName$ == &ptrVar1` accounts for 1 level already
|
||||
for i := n.defaultDepth; i > 1; i-- {
|
||||
sw.Do("ptrVar$.ptri$ := &ptrVar$.i$\n", generator.Args{"i": fmt.Sprintf("%d", i), "ptri": fmt.Sprintf("%d", (i - 1))})
|
||||
if pointerPath := getPointerElementPath(n.defaultTopLevelType); len(pointerPath) > 0 {
|
||||
// If the destination is a pointer, the last element in
|
||||
// defaultDepth is the element type of the bottommost pointer:
|
||||
// the base type of our default value.
|
||||
destElemType := pointerPath[len(pointerPath)-1]
|
||||
pointerArgs := args.WithArgs(generator.Args{
|
||||
"varDepth": len(pointerPath),
|
||||
"baseElemType": destElemType,
|
||||
})
|
||||
|
||||
sw.Do(fmt.Sprintf("if %s == nil {\n", variablePlaceholder), pointerArgs)
|
||||
if len(n.defaultValue.InlineConstant) > 0 {
|
||||
// If default value is a literal then it can be assigned via var stmt
|
||||
sw.Do("var ptrVar$.varDepth$ $.baseElemType|raw$ = $.defaultValue$\n", pointerArgs)
|
||||
} else {
|
||||
// If default value is not a literal then it may need to be casted
|
||||
// to the base type of the destination pointer
|
||||
sw.Do("ptrVar$.varDepth$ := $.baseElemType|raw$($.defaultValue$)\n", pointerArgs)
|
||||
}
|
||||
|
||||
for i := len(pointerPath); i >= 1; i-- {
|
||||
dest := fmt.Sprintf("ptrVar%d", i-1)
|
||||
assignment := ":="
|
||||
if i == 1 {
|
||||
// Last assignment is into the storage destination
|
||||
dest = variablePlaceholder
|
||||
assignment = "="
|
||||
}
|
||||
|
||||
sourceType := "*" + destElemType.String()
|
||||
if i == len(pointerPath) {
|
||||
// Initial value is not a pointer
|
||||
sourceType = destElemType.String()
|
||||
}
|
||||
destElemType = pointerPath[i-1]
|
||||
|
||||
// Cannot include `dest` into args since its value may be
|
||||
// `variablePlaceholder` which is a template, not a value
|
||||
elementArgs := pointerArgs.WithArgs(generator.Args{
|
||||
"assignment": assignment,
|
||||
"source": fmt.Sprintf("ptrVar%d", i),
|
||||
"destElemType": destElemType,
|
||||
})
|
||||
|
||||
// Skip cast if type is exact match
|
||||
if destElemType.String() == sourceType {
|
||||
sw.Do(fmt.Sprintf("%v $.assignment$ &$.source$\n", dest), elementArgs)
|
||||
} else {
|
||||
sw.Do(fmt.Sprintf("%v $.assignment$ (*$.destElemType|raw$)(&$.source$)\n", dest), elementArgs)
|
||||
}
|
||||
}
|
||||
sw.Do(fmt.Sprintf("%s = &ptrVar1", variablePlaceholder), args)
|
||||
} else {
|
||||
// For primitive types, nil checks cannot be used and the zero value must be determined
|
||||
defaultZero, err := getTypeZeroValue(n.defaultType)
|
||||
defaultZero, err := getTypeZeroValue(n.defaultType.String())
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
}
|
||||
args["defaultZero"] = defaultZero
|
||||
|
||||
sw.Do(fmt.Sprintf("if %s == $.defaultZero$ {\n", variablePlaceholder), args)
|
||||
sw.Do(fmt.Sprintf("%s = $.defaultValue$", variablePlaceholder), args)
|
||||
|
||||
if len(n.defaultValue.InlineConstant) > 0 {
|
||||
sw.Do(fmt.Sprintf("%s = $.defaultValue$", variablePlaceholder), args)
|
||||
} else {
|
||||
sw.Do(fmt.Sprintf("%s = $.varTopType|raw$($.defaultValue$)", variablePlaceholder), args)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sw.Do(fmt.Sprintf("if %s == nil {\n", variablePlaceholder), args)
|
||||
@ -1046,7 +1189,7 @@ func (n *callNode) WriteMethod(varName string, depth int, ancestors []*callNode,
|
||||
}
|
||||
sw.Do("}\n", nil)
|
||||
case n.key:
|
||||
if n.defaultValue != "" {
|
||||
if !n.defaultValue.IsEmpty() {
|
||||
// Map keys are typed and cannot share the same index variable as arrays and other maps
|
||||
index = index + "_" + ancestors[len(ancestors)-1].field
|
||||
vars["index"] = index
|
||||
|
26
vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict.go
generated
vendored
26
vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict.go
generated
vendored
@ -64,7 +64,7 @@ func Packages(c *generator.Context, arguments *args.GeneratorArgs) generator.Pac
|
||||
}
|
||||
|
||||
for _, p := range c.Universe {
|
||||
if !arguments.InputIncludes(p) {
|
||||
if !inputIncludes(arguments.InputDirs, p) {
|
||||
// Don't run on e.g. third party dependencies.
|
||||
continue
|
||||
}
|
||||
@ -89,6 +89,30 @@ func Packages(c *generator.Context, arguments *args.GeneratorArgs) generator.Pac
|
||||
return pkgs
|
||||
}
|
||||
|
||||
// inputIncludes returns true if the given package is a (sub) package of one of
|
||||
// the InputDirs.
|
||||
func inputIncludes(inputs []string, p *types.Package) bool {
|
||||
// TODO: This does not handle conversion of local paths (./foo) into
|
||||
// canonical packages (github.com/example/project/foo).
|
||||
for _, input := range inputs {
|
||||
// Normalize paths
|
||||
input := strings.TrimSuffix(input, "/")
|
||||
input = strings.TrimPrefix(input, "./vendor/")
|
||||
seek := strings.TrimSuffix(p.Path, "/")
|
||||
|
||||
if input == seek {
|
||||
return true
|
||||
}
|
||||
if strings.HasSuffix(input, "...") {
|
||||
input = strings.TrimSuffix(input, "...")
|
||||
if strings.HasPrefix(seek+"/", input) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// A single import restriction rule.
|
||||
type Rule struct {
|
||||
// All import paths that match this regexp...
|
||||
|
23
vendor/k8s.io/gengo/generator/import_tracker.go
generated
vendored
23
vendor/k8s.io/gengo/generator/import_tracker.go
generated
vendored
@ -26,15 +26,34 @@ import (
|
||||
"k8s.io/gengo/types"
|
||||
)
|
||||
|
||||
func NewImportTracker(typesToAdd ...*types.Type) namer.ImportTracker {
|
||||
tracker := namer.NewDefaultImportTracker(types.Name{})
|
||||
// NewImportTrackerForPackage creates a new import tracker which is aware
|
||||
// of a generator's output package. The tracker will not add import lines
|
||||
// when symbols or types are added from the same package, and LocalNameOf
|
||||
// will return empty string for the output package.
|
||||
//
|
||||
// e.g.:
|
||||
//
|
||||
// tracker := NewImportTrackerForPackage("bar.com/pkg/foo")
|
||||
// tracker.AddSymbol(types.Name{"bar.com/pkg/foo.MyType"})
|
||||
// tracker.AddSymbol(types.Name{"bar.com/pkg/baz.MyType"})
|
||||
// tracker.AddSymbol(types.Name{"bar.com/pkg/baz/baz.MyType"})
|
||||
//
|
||||
// tracker.LocalNameOf("bar.com/pkg/foo") -> ""
|
||||
// tracker.LocalNameOf("bar.com/pkg/baz") -> "baz"
|
||||
// tracker.LocalNameOf("bar.com/pkg/baz/baz") -> "bazbaz"
|
||||
// tracker.ImportLines() -> {`baz "bar.com/pkg/baz"`, `bazbaz "bar.com/pkg/baz/baz"`}
|
||||
func NewImportTrackerForPackage(local string, typesToAdd ...*types.Type) *namer.DefaultImportTracker {
|
||||
tracker := namer.NewDefaultImportTracker(types.Name{Package: local})
|
||||
tracker.IsInvalidType = func(*types.Type) bool { return false }
|
||||
tracker.LocalName = func(name types.Name) string { return golangTrackerLocalName(&tracker, name) }
|
||||
tracker.PrintImport = func(path, name string) string { return name + " \"" + path + "\"" }
|
||||
|
||||
tracker.AddTypes(typesToAdd...)
|
||||
return &tracker
|
||||
}
|
||||
|
||||
func NewImportTracker(typesToAdd ...*types.Type) *namer.DefaultImportTracker {
|
||||
return NewImportTrackerForPackage("", typesToAdd...)
|
||||
}
|
||||
|
||||
func golangTrackerLocalName(tracker namer.ImportTracker, t types.Name) string {
|
||||
|
35
vendor/k8s.io/gengo/namer/import_tracker.go
generated
vendored
35
vendor/k8s.io/gengo/namer/import_tracker.go
generated
vendored
@ -55,6 +55,27 @@ func (tracker *DefaultImportTracker) AddTypes(types ...*types.Type) {
|
||||
tracker.AddType(t)
|
||||
}
|
||||
}
|
||||
func (tracker *DefaultImportTracker) AddSymbol(symbol types.Name) {
|
||||
if tracker.local.Package == symbol.Package {
|
||||
return
|
||||
}
|
||||
|
||||
if len(symbol.Package) == 0 {
|
||||
return
|
||||
}
|
||||
path := symbol.Path
|
||||
if len(path) == 0 {
|
||||
path = symbol.Package
|
||||
}
|
||||
if _, ok := tracker.pathToName[path]; ok {
|
||||
return
|
||||
}
|
||||
|
||||
name := tracker.LocalName(symbol)
|
||||
tracker.nameToPath[name] = path
|
||||
tracker.pathToName[path] = name
|
||||
}
|
||||
|
||||
func (tracker *DefaultImportTracker) AddType(t *types.Type) {
|
||||
if tracker.local.Package == t.Name.Package {
|
||||
return
|
||||
@ -70,19 +91,7 @@ func (tracker *DefaultImportTracker) AddType(t *types.Type) {
|
||||
return
|
||||
}
|
||||
|
||||
if len(t.Name.Package) == 0 {
|
||||
return
|
||||
}
|
||||
path := t.Name.Path
|
||||
if len(path) == 0 {
|
||||
path = t.Name.Package
|
||||
}
|
||||
if _, ok := tracker.pathToName[path]; ok {
|
||||
return
|
||||
}
|
||||
name := tracker.LocalName(t.Name)
|
||||
tracker.nameToPath[name] = path
|
||||
tracker.pathToName[path] = name
|
||||
tracker.AddSymbol(t.Name)
|
||||
}
|
||||
|
||||
func (tracker *DefaultImportTracker) ImportLines() []string {
|
||||
|
1
vendor/k8s.io/gengo/namer/namer.go
generated
vendored
1
vendor/k8s.io/gengo/namer/namer.go
generated
vendored
@ -300,6 +300,7 @@ func (ns *NameStrategy) Name(t *types.Type) string {
|
||||
// import. You can implement yourself or use the one in the generation package.
|
||||
type ImportTracker interface {
|
||||
AddType(*types.Type)
|
||||
AddSymbol(types.Name)
|
||||
LocalNameOf(packagePath string) string
|
||||
PathOf(localName string) (string, bool)
|
||||
ImportLines() []string
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -2074,7 +2074,7 @@ k8s.io/endpointslice
|
||||
k8s.io/endpointslice/metrics
|
||||
k8s.io/endpointslice/topologycache
|
||||
k8s.io/endpointslice/util
|
||||
# k8s.io/gengo v0.0.0-20220902162205-c0856e24416d
|
||||
# k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01
|
||||
## explicit; go 1.13
|
||||
k8s.io/gengo/args
|
||||
k8s.io/gengo/examples/deepcopy-gen/generators
|
||||
|
Loading…
Reference in New Issue
Block a user