remove unused lifted codes
Signed-off-by: carlory <baofa.fan@daocloud.io>
This commit is contained in:
parent
24f0823a13
commit
0bf9750533
|
@ -35,8 +35,6 @@ package lifted
|
|||
| discovery.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/garbagecollector/garbagecollector.go#L696-L732 | func GetDeletableResources | N |
|
||||
| discovery_test.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/garbagecollector/garbagecollector_test.go#L943-L990 | type fakeServerResources | N |
|
||||
| discovery_test.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/garbagecollector/garbagecollector_test.go#L707-L797 | func TestGetDeletableResources | N |
|
||||
| logs.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/cmd/logs/logs.go#L411-L440 | func DefaultConsumeRequest | N |
|
||||
| logs.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/util/util.go#L32-L42 | func ParseRFC3339 | N |
|
||||
| nodeselector.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L365-L397 | func NodeSelectorRequirementsAsSelector | N |
|
||||
| objectwatcher.go | https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/util/propagatedversion.go#L35-L43 | func ObjectVersion | N |
|
||||
| objectwatcher.go | https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/util/propagatedversion.go#L45-L59 | func ObjectNeedsUpdate | N |
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 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.
|
||||
*/
|
||||
|
||||
// This code is directly lifted from the Kubernetes codebase.
|
||||
// For reference:
|
||||
// https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/cmd/logs/logs.go#L411-L440
|
||||
// https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/util/util.go#L32-L42
|
||||
|
||||
package lifted
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
// +lifted:source=https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/cmd/logs/logs.go#L411-L440
|
||||
|
||||
// DefaultConsumeRequest reads the data from request and writes into
|
||||
// the out writer. It buffers data from requests until the newline or io.EOF
|
||||
// occurs in the data, so it doesn't interleave logs sub-line
|
||||
// when running concurrently.
|
||||
//
|
||||
// A successful read returns err == nil, not err == io.EOF.
|
||||
// Because the function is defined to read from request until io.EOF, it does
|
||||
// not treat an io.EOF as an error to be reported.
|
||||
func DefaultConsumeRequest(request rest.ResponseWrapper, out io.Writer) error {
|
||||
readCloser, err := request.Stream(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer readCloser.Close()
|
||||
|
||||
r := bufio.NewReader(readCloser)
|
||||
for {
|
||||
bytes, err := r.ReadBytes('\n')
|
||||
if _, err := out.Write(bytes); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// +lifted:source=https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/util/util.go#L32-L42
|
||||
|
||||
// ParseRFC3339 parses an RFC3339 date in either RFC3339Nano or RFC3339 format.
|
||||
func ParseRFC3339(s string, nowFn func() metav1.Time) (metav1.Time, error) {
|
||||
if t, timeErr := time.Parse(time.RFC3339Nano, s); timeErr == nil {
|
||||
return metav1.Time{Time: t}, nil
|
||||
}
|
||||
t, err := time.Parse(time.RFC3339, s)
|
||||
if err != nil {
|
||||
return metav1.Time{}, err
|
||||
}
|
||||
return metav1.Time{Time: t}, nil
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 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.
|
||||
*/
|
||||
|
||||
// This code is directly lifted from the Kubernetes codebase.
|
||||
// For reference:
|
||||
// https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/cmd/logs/logs_test.go#L724-L789
|
||||
|
||||
package lifted
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"testing"
|
||||
"testing/iotest"
|
||||
|
||||
restclient "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
func TestDefaultConsumeRequest(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
request restclient.ResponseWrapper
|
||||
expectedErr string
|
||||
expectedOut string
|
||||
}{
|
||||
{
|
||||
name: "error from request stream",
|
||||
request: &responseWrapperMock{
|
||||
err: errors.New("err from the stream"),
|
||||
},
|
||||
expectedErr: "err from the stream",
|
||||
},
|
||||
{
|
||||
name: "error while reading",
|
||||
request: &responseWrapperMock{
|
||||
data: iotest.TimeoutReader(strings.NewReader("Some data")),
|
||||
},
|
||||
expectedErr: iotest.ErrTimeout.Error(),
|
||||
expectedOut: "Some data",
|
||||
},
|
||||
{
|
||||
name: "read with empty string",
|
||||
request: &responseWrapperMock{
|
||||
data: strings.NewReader(""),
|
||||
},
|
||||
expectedOut: "",
|
||||
},
|
||||
{
|
||||
name: "read without new lines",
|
||||
request: &responseWrapperMock{
|
||||
data: strings.NewReader("some string without a new line"),
|
||||
},
|
||||
expectedOut: "some string without a new line",
|
||||
},
|
||||
{
|
||||
name: "read with newlines in the middle",
|
||||
request: &responseWrapperMock{
|
||||
data: strings.NewReader("foo\nbar"),
|
||||
},
|
||||
expectedOut: "foo\nbar",
|
||||
},
|
||||
{
|
||||
name: "read with newline at the end",
|
||||
request: &responseWrapperMock{
|
||||
data: strings.NewReader("foo\n"),
|
||||
},
|
||||
expectedOut: "foo\n",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
buf := &bytes.Buffer{}
|
||||
err := DefaultConsumeRequest(test.request, buf)
|
||||
|
||||
if err != nil && !strings.Contains(err.Error(), test.expectedErr) {
|
||||
t.Errorf("%s: expected to find:\n\t%s\nfound:\n\t%s\n", test.name, test.expectedErr, err.Error())
|
||||
}
|
||||
|
||||
if buf.String() != test.expectedOut {
|
||||
t.Errorf("%s: did not get expected log content. Got: %s", test.name, buf.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type responseWrapperMock struct {
|
||||
data io.Reader
|
||||
err error
|
||||
}
|
||||
|
||||
func (r *responseWrapperMock) DoRaw(context.Context) ([]byte, error) {
|
||||
data, _ := ioutil.ReadAll(r.data)
|
||||
return data, r.err
|
||||
}
|
||||
|
||||
func (r *responseWrapperMock) Stream(context.Context) (io.ReadCloser, error) {
|
||||
return ioutil.NopCloser(r.data), r.err
|
||||
}
|
Loading…
Reference in New Issue