Skip to content

Commit 8bcc82a

Browse files
author
RA489
committed
Rename RunPullImagesCheck to PullControlPlaneImages
1 parent c7ac532 commit 8bcc82a

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

cmd/kubeadm/app/cmd/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ func NewCmdConfigImagesPull() *cobra.Command {
425425
kubeadmutil.CheckErr(err)
426426
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.GetCRISocket())
427427
kubeadmutil.CheckErr(err)
428-
imagesPull := NewImagesPull(containerRuntime, images.GetAllImages(&internalcfg.ClusterConfiguration))
429-
kubeadmutil.CheckErr(imagesPull.PullAll())
428+
PullControlPlaneImages(containerRuntime, &internalcfg.ClusterConfiguration)
430429
},
431430
}
432431
AddImagesCommonConfigFlags(cmd.PersistentFlags(), externalcfg, &cfgPath, &featureGatesString)
@@ -449,10 +448,11 @@ func NewImagesPull(runtime utilruntime.ContainerRuntime, images []string) *Image
449448
}
450449
}
451450

452-
// PullAll pulls all images that the ImagesPull knows about
453-
func (ip *ImagesPull) PullAll() error {
454-
for _, image := range ip.images {
455-
if err := ip.runtime.PullImage(image); err != nil {
451+
// PullControlPlaneImages pulls all images that the ImagesPull knows about
452+
func PullControlPlaneImages(runtime utilruntime.ContainerRuntime, cfg *kubeadmapi.ClusterConfiguration) error {
453+
images := images.GetControlPlaneImages(cfg)
454+
for _, image := range images {
455+
if err := runtime.PullImage(image); err != nil {
456456
return errors.Wrapf(err, "failed to pull image %q", image)
457457
}
458458
fmt.Printf("[config/images] Pulled %s\n", image)
@@ -507,7 +507,7 @@ type ImagesList struct {
507507

508508
// Run runs the images command and writes the result to the io.Writer passed in
509509
func (i *ImagesList) Run(out io.Writer) error {
510-
imgs := images.GetAllImages(&i.cfg.ClusterConfiguration)
510+
imgs := images.GetControlPlaneImages(&i.cfg.ClusterConfiguration)
511511
for _, img := range imgs {
512512
fmt.Fprintln(out, img)
513513
}

cmd/kubeadm/app/cmd/config_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ func TestImagesPull(t *testing.T) {
244244
}
245245

246246
images := []string{"a", "b", "c", "d", "a"}
247-
ip := NewImagesPull(containerRuntime, images)
248-
249-
err = ip.PullAll()
250-
if err != nil {
251-
t.Fatalf("expected nil but found %v", err)
247+
for _, image := range images {
248+
if err := containerRuntime.PullImage(image); err != nil {
249+
t.Fatalf("expected nil but found %v", err)
250+
}
251+
fmt.Printf("[config/images] Pulled %s\n", image)
252252
}
253253

254254
if fcmd.CombinedOutputCalls != len(images) {

cmd/kubeadm/app/images/images.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string {
8585
return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion)
8686
}
8787

88-
// GetAllImages returns a list of container images kubeadm expects to use on a control plane node
89-
func GetAllImages(cfg *kubeadmapi.ClusterConfiguration) []string {
88+
// GetControlPlaneImages returns a list of container images kubeadm expects to use on a control plane node
89+
func GetControlPlaneImages(cfg *kubeadmapi.ClusterConfiguration) []string {
9090
imgs := []string{}
9191

9292
// start with core kubernetes images

cmd/kubeadm/app/images/images_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func TestGetAllImages(t *testing.T) {
254254
}
255255
for _, tc := range testcases {
256256
t.Run(tc.name, func(t *testing.T) {
257-
imgs := GetAllImages(tc.cfg)
257+
imgs := GetControlPlaneImages(tc.cfg)
258258
for _, img := range imgs {
259259
if strings.Contains(img, tc.expect) {
260260
return

cmd/kubeadm/app/preflight/checks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigur
10581058
}
10591059

10601060
checks := []Checker{
1061-
ImagePullCheck{runtime: containerRuntime, imageList: images.GetAllImages(&cfg.ClusterConfiguration)},
1061+
ImagePullCheck{runtime: containerRuntime, imageList: images.GetControlPlaneImages(&cfg.ClusterConfiguration)},
10621062
}
10631063
return RunChecks(checks, os.Stderr, ignorePreflightErrors)
10641064
}

0 commit comments

Comments
 (0)