Merge pull request #65609 from CaoShuFeng/sample-controller

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

fix sample-controller README

The guide in doc causes an error
```
$ go run *.go -kubeconfig=$HOME/.kube/config
go run: cannot run *_test.go files (controller_test.go)
```

**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```

Kubernetes-commit: cf14f027c59f50c897ae5b6bb5a1f69581d1549b
This commit is contained in:
Kubernetes Publisher 2018-06-29 07:22:27 -07:00
commit 4066b6ae6b
6 changed files with 90 additions and 77 deletions

142
Godeps/Godeps.json generated
View File

@ -172,287 +172,287 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/apps/v1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/coordination/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/scheduling/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "9e5ffd1f1320950b238cfce291b926411f0af722"
"Rev": "ded72da34a273a447508135b315f865aa6e48fc8"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "ed135c5b96450fd24e5e981c708114fbbd950697"
"Rev": "97cca6cc910b472c65890ea424e84795ef4ddfb9"
},
{
"ImportPath": "k8s.io/client-go/discovery",

View File

@ -42,7 +42,8 @@ This is an example of how to build a kube-like controller with a single type.
```sh
# assumes you have a working kubeconfig, not required if operating in-cluster
$ go run *.go -kubeconfig=$HOME/.kube/config
$ go build -o sample-controller .
$ ./sample-controller -kubeconfig=$HOME/.kube/config
# create a CustomResourceDefinition
$ kubectl create -f artifacts/examples/crd.yaml

View File

@ -4513,7 +4513,7 @@ message VolumeMount {
// mountPropagation determines how mounts are propagated from the host
// to container and the other way around.
// When not set, MountPropagationHostToContainer is used.
// When not set, MountPropagationNone is used.
// This field is beta in 1.10.
// +optional
optional string mountPropagation = 5;

2
vendor/k8s.io/api/core/v1/types.go generated vendored
View File

@ -1686,7 +1686,7 @@ type VolumeMount struct {
SubPath string `json:"subPath,omitempty" protobuf:"bytes,4,opt,name=subPath"`
// mountPropagation determines how mounts are propagated from the host
// to container and the other way around.
// When not set, MountPropagationHostToContainer is used.
// When not set, MountPropagationNone is used.
// This field is beta in 1.10.
// +optional
MountPropagation *MountPropagationMode `json:"mountPropagation,omitempty" protobuf:"bytes,5,opt,name=mountPropagation,casttype=MountPropagationMode"`

View File

@ -2230,7 +2230,7 @@ var map_VolumeMount = map[string]string{
"readOnly": "Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.",
"mountPath": "Path within the container at which the volume should be mounted. Must not contain ':'.",
"subPath": "Path within the volume from which the container's volume should be mounted. Defaults to \"\" (volume's root).",
"mountPropagation": "mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationHostToContainer is used. This field is beta in 1.10.",
"mountPropagation": "mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10.",
}
func (VolumeMount) SwaggerDoc() map[string]string {

View File

@ -91,7 +91,8 @@ func SetOldTransportDefaults(t *http.Transport) *http.Transport {
// ProxierWithNoProxyCIDR allows CIDR rules in NO_PROXY
t.Proxy = NewProxierWithNoProxyCIDR(http.ProxyFromEnvironment)
}
if t.DialContext == nil {
// If no custom dialer is set, use the default context dialer
if t.DialContext == nil && t.Dial == nil {
t.DialContext = defaultTransport.DialContext
}
if t.TLSHandshakeTimeout == 0 {
@ -129,7 +130,18 @@ func DialerFor(transport http.RoundTripper) (DialFunc, error) {
switch transport := transport.(type) {
case *http.Transport:
return transport.DialContext, nil
// transport.DialContext takes precedence over transport.Dial
if transport.DialContext != nil {
return transport.DialContext, nil
}
// adapt transport.Dial to the DialWithContext signature
if transport.Dial != nil {
return func(ctx context.Context, net, addr string) (net.Conn, error) {
return transport.Dial(net, addr)
}, nil
}
// otherwise return nil
return nil, nil
case RoundTripperWrapper:
return DialerFor(transport.WrappedRoundTripper())
default: