From 8bcc82a9e4875002fbce46ae211d030ab763f5d3 Mon Sep 17 00:00:00 2001 From: RA489 Date: Fri, 22 Feb 2019 13:02:25 +0530 Subject: [PATCH] Rename RunPullImagesCheck to PullControlPlaneImages --- cmd/kubeadm/app/cmd/config.go | 14 +++++++------- cmd/kubeadm/app/cmd/config_test.go | 10 +++++----- cmd/kubeadm/app/images/images.go | 4 ++-- cmd/kubeadm/app/images/images_test.go | 2 +- cmd/kubeadm/app/preflight/checks.go | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cmd/kubeadm/app/cmd/config.go b/cmd/kubeadm/app/cmd/config.go index b846d2eb33b..6d93c3b17fe 100644 --- a/cmd/kubeadm/app/cmd/config.go +++ b/cmd/kubeadm/app/cmd/config.go @@ -425,8 +425,7 @@ func NewCmdConfigImagesPull() *cobra.Command { kubeadmutil.CheckErr(err) containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.GetCRISocket()) kubeadmutil.CheckErr(err) - imagesPull := NewImagesPull(containerRuntime, images.GetAllImages(&internalcfg.ClusterConfiguration)) - kubeadmutil.CheckErr(imagesPull.PullAll()) + PullControlPlaneImages(containerRuntime, &internalcfg.ClusterConfiguration) }, } AddImagesCommonConfigFlags(cmd.PersistentFlags(), externalcfg, &cfgPath, &featureGatesString) @@ -449,10 +448,11 @@ func NewImagesPull(runtime utilruntime.ContainerRuntime, images []string) *Image } } -// PullAll pulls all images that the ImagesPull knows about -func (ip *ImagesPull) PullAll() error { - for _, image := range ip.images { - if err := ip.runtime.PullImage(image); err != nil { +// PullControlPlaneImages pulls all images that the ImagesPull knows about +func PullControlPlaneImages(runtime utilruntime.ContainerRuntime, cfg *kubeadmapi.ClusterConfiguration) error { + images := images.GetControlPlaneImages(cfg) + for _, image := range images { + if err := runtime.PullImage(image); err != nil { return errors.Wrapf(err, "failed to pull image %q", image) } fmt.Printf("[config/images] Pulled %s\n", image) @@ -507,7 +507,7 @@ type ImagesList struct { // Run runs the images command and writes the result to the io.Writer passed in func (i *ImagesList) Run(out io.Writer) error { - imgs := images.GetAllImages(&i.cfg.ClusterConfiguration) + imgs := images.GetControlPlaneImages(&i.cfg.ClusterConfiguration) for _, img := range imgs { fmt.Fprintln(out, img) } diff --git a/cmd/kubeadm/app/cmd/config_test.go b/cmd/kubeadm/app/cmd/config_test.go index 7445b982f58..3f43d987ee5 100644 --- a/cmd/kubeadm/app/cmd/config_test.go +++ b/cmd/kubeadm/app/cmd/config_test.go @@ -244,11 +244,11 @@ func TestImagesPull(t *testing.T) { } images := []string{"a", "b", "c", "d", "a"} - ip := NewImagesPull(containerRuntime, images) - - err = ip.PullAll() - if err != nil { - t.Fatalf("expected nil but found %v", err) + for _, image := range images { + if err := containerRuntime.PullImage(image); err != nil { + t.Fatalf("expected nil but found %v", err) + } + fmt.Printf("[config/images] Pulled %s\n", image) } if fcmd.CombinedOutputCalls != len(images) { diff --git a/cmd/kubeadm/app/images/images.go b/cmd/kubeadm/app/images/images.go index c988fe0f280..4cbd0e0b317 100644 --- a/cmd/kubeadm/app/images/images.go +++ b/cmd/kubeadm/app/images/images.go @@ -85,8 +85,8 @@ func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string { return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion) } -// GetAllImages returns a list of container images kubeadm expects to use on a control plane node -func GetAllImages(cfg *kubeadmapi.ClusterConfiguration) []string { +// GetControlPlaneImages returns a list of container images kubeadm expects to use on a control plane node +func GetControlPlaneImages(cfg *kubeadmapi.ClusterConfiguration) []string { imgs := []string{} // start with core kubernetes images diff --git a/cmd/kubeadm/app/images/images_test.go b/cmd/kubeadm/app/images/images_test.go index d72ff458543..4714db8f86a 100644 --- a/cmd/kubeadm/app/images/images_test.go +++ b/cmd/kubeadm/app/images/images_test.go @@ -254,7 +254,7 @@ func TestGetAllImages(t *testing.T) { } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { - imgs := GetAllImages(tc.cfg) + imgs := GetControlPlaneImages(tc.cfg) for _, img := range imgs { if strings.Contains(img, tc.expect) { return diff --git a/cmd/kubeadm/app/preflight/checks.go b/cmd/kubeadm/app/preflight/checks.go index 9406cef528d..a7c4c611eda 100644 --- a/cmd/kubeadm/app/preflight/checks.go +++ b/cmd/kubeadm/app/preflight/checks.go @@ -1058,7 +1058,7 @@ func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigur } checks := []Checker{ - ImagePullCheck{runtime: containerRuntime, imageList: images.GetAllImages(&cfg.ClusterConfiguration)}, + ImagePullCheck{runtime: containerRuntime, imageList: images.GetControlPlaneImages(&cfg.ClusterConfiguration)}, } return RunChecks(checks, os.Stderr, ignorePreflightErrors) }