Unverified Commit 95235fc8 authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub

Merge pull request #80241 from…

Merge pull request #80241 from wojtek-t/automated-cherry-pick-of-#80157-#80236-upstream-release-1.15 Automated cherry pick of #80157 #80236 upstream release 1.15
parents dda8703d ba36d3b8
...@@ -93,7 +93,7 @@ func Test_buildClientCertificateManager(t *testing.T) { ...@@ -93,7 +93,7 @@ func Test_buildClientCertificateManager(t *testing.T) {
// get an expired CSR (simulating historical output) // get an expired CSR (simulating historical output)
server.backdate = 2 * time.Hour server.backdate = 2 * time.Hour
server.expectUserAgent = "FirstClient" server.SetExpectUserAgent("FirstClient")
ok, err := r.RotateCerts() ok, err := r.RotateCerts()
if !ok || err != nil { if !ok || err != nil {
t.Fatalf("unexpected rotation err: %t %v", ok, err) t.Fatalf("unexpected rotation err: %t %v", ok, err)
...@@ -109,7 +109,7 @@ func Test_buildClientCertificateManager(t *testing.T) { ...@@ -109,7 +109,7 @@ func Test_buildClientCertificateManager(t *testing.T) {
// if m.Current() == nil, then we try again and get a valid // if m.Current() == nil, then we try again and get a valid
// client // client
server.backdate = 0 server.backdate = 0
server.expectUserAgent = "FirstClient" server.SetExpectUserAgent("FirstClient")
if ok, err := r.RotateCerts(); !ok || err != nil { if ok, err := r.RotateCerts(); !ok || err != nil {
t.Fatalf("unexpected rotation err: %t %v", ok, err) t.Fatalf("unexpected rotation err: %t %v", ok, err)
} }
...@@ -122,7 +122,7 @@ func Test_buildClientCertificateManager(t *testing.T) { ...@@ -122,7 +122,7 @@ func Test_buildClientCertificateManager(t *testing.T) {
} }
// if m.Current() != nil, then we should use the second client // if m.Current() != nil, then we should use the second client
server.expectUserAgent = "SecondClient" server.SetExpectUserAgent("SecondClient")
if ok, err := r.RotateCerts(); !ok || err != nil { if ok, err := r.RotateCerts(); !ok || err != nil {
t.Fatalf("unexpected rotation err: %t %v", ok, err) t.Fatalf("unexpected rotation err: %t %v", ok, err)
} }
...@@ -243,12 +243,24 @@ type csrSimulator struct { ...@@ -243,12 +243,24 @@ type csrSimulator struct {
serverCA *x509.Certificate serverCA *x509.Certificate
backdate time.Duration backdate time.Duration
userAgentLock sync.Mutex
expectUserAgent string expectUserAgent string
lock sync.Mutex lock sync.Mutex
csr *certapi.CertificateSigningRequest csr *certapi.CertificateSigningRequest
} }
func (s *csrSimulator) SetExpectUserAgent(a string) {
s.userAgentLock.Lock()
defer s.userAgentLock.Unlock()
s.expectUserAgent = a
}
func (s *csrSimulator) ExpectUserAgent() string {
s.userAgentLock.Lock()
defer s.userAgentLock.Unlock()
return s.expectUserAgent
}
func (s *csrSimulator) ServeHTTP(w http.ResponseWriter, req *http.Request) { func (s *csrSimulator) ServeHTTP(w http.ResponseWriter, req *http.Request) {
s.lock.Lock() s.lock.Lock()
defer s.lock.Unlock() defer s.lock.Unlock()
...@@ -258,11 +270,12 @@ func (s *csrSimulator) ServeHTTP(w http.ResponseWriter, req *http.Request) { ...@@ -258,11 +270,12 @@ func (s *csrSimulator) ServeHTTP(w http.ResponseWriter, req *http.Request) {
q := req.URL.Query() q := req.URL.Query()
q.Del("timeout") q.Del("timeout")
q.Del("timeoutSeconds") q.Del("timeoutSeconds")
q.Del("allowWatchBookmarks")
req.URL.RawQuery = q.Encode() req.URL.RawQuery = q.Encode()
t.Logf("Request %q %q %q", req.Method, req.URL, req.UserAgent()) t.Logf("Request %q %q %q", req.Method, req.URL, req.UserAgent())
if len(s.expectUserAgent) > 0 && req.UserAgent() != s.expectUserAgent { if a := s.ExpectUserAgent(); len(a) > 0 && req.UserAgent() != a {
t.Errorf("Unexpected user agent: %s", req.UserAgent()) t.Errorf("Unexpected user agent: %s", req.UserAgent())
} }
......
...@@ -24,7 +24,6 @@ go_test( ...@@ -24,7 +24,6 @@ go_test(
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"conversion.go",
"doc.go", "doc.go",
"register.go", "register.go",
"types.go", "types.go",
......
/*
Copyright 2017 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 internalversion
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion"
)
func Convert_internalversion_ListOptions_To_v1_ListOptions(in *ListOptions, out *metav1.ListOptions, s conversion.Scope) error {
if err := metav1.Convert_fields_Selector_To_string(&in.FieldSelector, &out.FieldSelector, s); err != nil {
return err
}
if err := metav1.Convert_labels_Selector_To_string(&in.LabelSelector, &out.LabelSelector, s); err != nil {
return err
}
out.ResourceVersion = in.ResourceVersion
out.TimeoutSeconds = in.TimeoutSeconds
out.Watch = in.Watch
out.Limit = in.Limit
out.Continue = in.Continue
return nil
}
func Convert_v1_ListOptions_To_internalversion_ListOptions(in *metav1.ListOptions, out *ListOptions, s conversion.Scope) error {
if err := metav1.Convert_string_To_fields_Selector(&in.FieldSelector, &out.FieldSelector, s); err != nil {
return err
}
if err := metav1.Convert_string_To_labels_Selector(&in.LabelSelector, &out.LabelSelector, s); err != nil {
return err
}
out.ResourceVersion = in.ResourceVersion
out.TimeoutSeconds = in.TimeoutSeconds
out.Watch = in.Watch
out.Limit = in.Limit
out.Continue = in.Continue
return nil
}
...@@ -66,9 +66,6 @@ func addToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion) ...@@ -66,9 +66,6 @@ func addToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion)
metav1.Convert_Map_string_To_string_To_v1_LabelSelector, metav1.Convert_Map_string_To_string_To_v1_LabelSelector,
metav1.Convert_v1_LabelSelector_To_Map_string_To_string, metav1.Convert_v1_LabelSelector_To_Map_string_To_string,
Convert_internalversion_ListOptions_To_v1_ListOptions,
Convert_v1_ListOptions_To_internalversion_ListOptions,
) )
if err != nil { if err != nil {
return err return err
......
...@@ -55,16 +55,6 @@ func RegisterConversions(s *runtime.Scheme) error { ...@@ -55,16 +55,6 @@ func RegisterConversions(s *runtime.Scheme) error {
}); err != nil { }); err != nil {
return err return err
} }
if err := s.AddConversionFunc((*ListOptions)(nil), (*v1.ListOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_internalversion_ListOptions_To_v1_ListOptions(a.(*ListOptions), b.(*v1.ListOptions), scope)
}); err != nil {
return err
}
if err := s.AddConversionFunc((*v1.ListOptions)(nil), (*ListOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_ListOptions_To_internalversion_ListOptions(a.(*v1.ListOptions), b.(*ListOptions), scope)
}); err != nil {
return err
}
return nil return nil
} }
...@@ -126,6 +116,11 @@ func autoConvert_internalversion_ListOptions_To_v1_ListOptions(in *ListOptions, ...@@ -126,6 +116,11 @@ func autoConvert_internalversion_ListOptions_To_v1_ListOptions(in *ListOptions,
return nil return nil
} }
// Convert_internalversion_ListOptions_To_v1_ListOptions is an autogenerated conversion function.
func Convert_internalversion_ListOptions_To_v1_ListOptions(in *ListOptions, out *v1.ListOptions, s conversion.Scope) error {
return autoConvert_internalversion_ListOptions_To_v1_ListOptions(in, out, s)
}
func autoConvert_v1_ListOptions_To_internalversion_ListOptions(in *v1.ListOptions, out *ListOptions, s conversion.Scope) error { func autoConvert_v1_ListOptions_To_internalversion_ListOptions(in *v1.ListOptions, out *ListOptions, s conversion.Scope) error {
if err := v1.Convert_string_To_labels_Selector(&in.LabelSelector, &out.LabelSelector, s); err != nil { if err := v1.Convert_string_To_labels_Selector(&in.LabelSelector, &out.LabelSelector, s); err != nil {
return err return err
...@@ -141,3 +136,8 @@ func autoConvert_v1_ListOptions_To_internalversion_ListOptions(in *v1.ListOption ...@@ -141,3 +136,8 @@ func autoConvert_v1_ListOptions_To_internalversion_ListOptions(in *v1.ListOption
out.Continue = in.Continue out.Continue = in.Continue
return nil return nil
} }
// Convert_v1_ListOptions_To_internalversion_ListOptions is an autogenerated conversion function.
func Convert_v1_ListOptions_To_internalversion_ListOptions(in *v1.ListOptions, out *ListOptions, s conversion.Scope) error {
return autoConvert_v1_ListOptions_To_internalversion_ListOptions(in, out, s)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment