@@ -57,10 +57,12 @@ import (
57
57
// Do some initialization to decode the query parameters correctly.
58
58
"k8s.io/apiserver/pkg/server/healthz"
59
59
utilfeature "k8s.io/apiserver/pkg/util/feature"
60
+ imagepullprogress "k8s.io/client-go/tools/imagepullprogress"
60
61
featuregatetesting "k8s.io/component-base/featuregate/testing"
61
62
zpagesfeatures "k8s.io/component-base/zpages/features"
62
63
"k8s.io/component-base/zpages/flagz"
63
64
"k8s.io/kubelet/pkg/cri/streaming"
65
+ imagepullprogressserver "k8s.io/kubelet/pkg/cri/streaming/imagepullprogress"
64
66
"k8s.io/kubelet/pkg/cri/streaming/portforward"
65
67
remotecommandserver "k8s.io/kubelet/pkg/cri/streaming/remotecommand"
66
68
_ "k8s.io/kubernetes/pkg/apis/core/install"
@@ -78,15 +80,16 @@ const (
78
80
)
79
81
80
82
type fakeKubelet struct {
81
- podByNameFunc func (namespace , name string ) (* v1.Pod , bool )
82
- machineInfoFunc func () (* cadvisorapi.MachineInfo , error )
83
- podsFunc func () []* v1.Pod
84
- runningPodsFunc func (ctx context.Context ) ([]* v1.Pod , error )
85
- logFunc func (w http.ResponseWriter , req * http.Request )
86
- runFunc func (podFullName string , uid types.UID , containerName string , cmd []string ) ([]byte , error )
87
- getExecCheck func (string , types.UID , string , []string , remotecommandserver.Options )
88
- getAttachCheck func (string , types.UID , string , remotecommandserver.Options )
89
- getPortForwardCheck func (string , string , types.UID , portforward.V4Options )
83
+ podByNameFunc func (namespace , name string ) (* v1.Pod , bool )
84
+ machineInfoFunc func () (* cadvisorapi.MachineInfo , error )
85
+ podsFunc func () []* v1.Pod
86
+ runningPodsFunc func (ctx context.Context ) ([]* v1.Pod , error )
87
+ logFunc func (w http.ResponseWriter , req * http.Request )
88
+ runFunc func (podFullName string , uid types.UID , containerName string , cmd []string ) ([]byte , error )
89
+ getExecCheck func (string , types.UID , string , []string , remotecommandserver.Options )
90
+ getAttachCheck func (string , types.UID , string , remotecommandserver.Options )
91
+ getPortForwardCheck func (string , string , types.UID , portforward.V4Options )
92
+ getImagePullProgressCheck func (podName , podNamespace string , podUID types.UID , imagePullProgressOpts imagepullprogressserver.Options )
90
93
91
94
containerLogsFunc func (ctx context.Context , podFullName , containerName string , logOptions * v1.PodLogOptions , stdout , stderr io.Writer ) error
92
95
hostnameFunc func () string
@@ -169,9 +172,10 @@ func (fk *fakeKubelet) SyncLoopHealthCheck(req *http.Request) error {
169
172
}
170
173
171
174
type fakeRuntime struct {
172
- execFunc func (string , []string , io.Reader , io.WriteCloser , io.WriteCloser , bool , <- chan remotecommand.TerminalSize ) error
173
- attachFunc func (string , io.Reader , io.WriteCloser , io.WriteCloser , bool , <- chan remotecommand.TerminalSize ) error
174
- portForwardFunc func (string , int32 , io.ReadWriteCloser ) error
175
+ execFunc func (string , []string , io.Reader , io.WriteCloser , io.WriteCloser , bool , <- chan remotecommand.TerminalSize ) error
176
+ attachFunc func (string , io.Reader , io.WriteCloser , io.WriteCloser , bool , <- chan remotecommand.TerminalSize ) error
177
+ portForwardFunc func (string , int32 , io.ReadWriteCloser ) error
178
+ imagePullProgressFunc func (string , chan <- imagepullprogress.Progress ) error
175
179
}
176
180
177
181
func (f * fakeRuntime ) Exec (_ context.Context , containerID string , cmd []string , stdin io.Reader , stdout , stderr io.WriteCloser , tty bool , resize <- chan remotecommand.TerminalSize ) error {
@@ -186,6 +190,10 @@ func (f *fakeRuntime) PortForward(_ context.Context, podSandboxID string, port i
186
190
return f .portForwardFunc (podSandboxID , port , stream )
187
191
}
188
192
193
+ func (f * fakeRuntime ) ImagePullProgress (_ context.Context , podSandboxID string , progress chan <- imagepullprogress.Progress ) error {
194
+ return f .imagePullProgressFunc (podSandboxID , progress )
195
+ }
196
+
189
197
type testStreamingServer struct {
190
198
streaming.Server
191
199
fakeRuntime * fakeRuntime
@@ -273,6 +281,20 @@ func (fk *fakeKubelet) GetPortForward(ctx context.Context, podName, podNamespace
273
281
return url .Parse (resp .GetUrl ())
274
282
}
275
283
284
+ func (fk * fakeKubelet ) GetImagePullProgress (ctx context.Context , podName , podNamespace string , podUID types.UID , imagePullProgressOpts imagepullprogressserver.Options ) (* url.URL , error ) {
285
+ if fk .getImagePullProgressCheck != nil {
286
+ fk .getImagePullProgressCheck (podName , podNamespace , podUID , imagePullProgressOpts )
287
+ }
288
+ // Always use testPodSandboxID
289
+ resp , err := fk .streamingRuntime .GetImagePullProgress (& runtimeapi.ImagePullProgressRequest {
290
+ PodSandboxId : testPodSandboxID ,
291
+ })
292
+ if err != nil {
293
+ return nil , err
294
+ }
295
+ return url .Parse (resp .GetUrl ())
296
+ }
297
+
276
298
// Unused functions
277
299
func (* fakeKubelet ) GetNode () (* v1.Node , error ) { return nil , nil }
278
300
func (* fakeKubelet ) GetNodeConfig () cm.NodeConfig { return cm.NodeConfig {} }
0 commit comments