Skip to content

Commit

Permalink
rest client watch: use same name for package as folder
Browse files Browse the repository at this point in the history
Kubernetes-commit: 8e1d0c664c60c094605f692360213b0284cdbe0f
  • Loading branch information
aojea authored and k8s-publishing-bot committed Nov 4, 2024
1 parent be38ea1 commit d69191c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion rest/watch/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package versioned
package watch

import (
"fmt"
Expand Down
9 changes: 4 additions & 5 deletions rest/watch/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package versioned_test
package watch

import (
"encoding/json"
Expand All @@ -23,7 +23,7 @@ import (
"testing"
"time"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -32,7 +32,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes/scheme"
restclientwatch "k8s.io/client-go/rest/watch"
)

// getDecoder mimics how k8s.io/client-go/rest.createSerializers creates a decoder
Expand All @@ -48,7 +47,7 @@ func TestDecoder(t *testing.T) {
for _, eventType := range table {
out, in := io.Pipe()

decoder := restclientwatch.NewDecoder(streaming.NewDecoder(out, getDecoder()), getDecoder())
decoder := NewDecoder(streaming.NewDecoder(out, getDecoder()), getDecoder())
expect := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}
encoder := json.NewEncoder(in)
eType := eventType
Expand Down Expand Up @@ -108,7 +107,7 @@ func TestDecoder(t *testing.T) {

func TestDecoder_SourceClose(t *testing.T) {
out, in := io.Pipe()
decoder := restclientwatch.NewDecoder(streaming.NewDecoder(out, getDecoder()), getDecoder())
decoder := NewDecoder(streaming.NewDecoder(out, getDecoder()), getDecoder())

done := make(chan struct{})

Expand Down
2 changes: 1 addition & 1 deletion rest/watch/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package versioned
package watch

import (
"encoding/json"
Expand Down
9 changes: 4 additions & 5 deletions rest/watch/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package versioned_test
package watch

import (
"bytes"
"io"
"testing"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
runtimejson "k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes/scheme"
restclientwatch "k8s.io/client-go/rest/watch"
)

// getEncoder mimics how k8s.io/client-go/rest.createSerializers creates a encoder
Expand Down Expand Up @@ -64,14 +63,14 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
for i, testCase := range testCases {
buf := &bytes.Buffer{}

encoder := restclientwatch.NewEncoder(streaming.NewEncoder(buf, getEncoder()), getEncoder())
encoder := NewEncoder(streaming.NewEncoder(buf, getEncoder()), getEncoder())
if err := encoder.Encode(&watch.Event{Type: testCase.Type, Object: testCase.Object}); err != nil {
t.Errorf("%d: unexpected error: %v", i, err)
continue
}

rc := io.NopCloser(buf)
decoder := restclientwatch.NewDecoder(streaming.NewDecoder(rc, getDecoder()), getDecoder())
decoder := NewDecoder(streaming.NewDecoder(rc, getDecoder()), getDecoder())
event, obj, err := decoder.Decode()
if err != nil {
t.Errorf("%d: unexpected error: %v", i, err)
Expand Down

0 comments on commit d69191c

Please sign in to comment.