Merge pull request #74399 from RA489/runpullimagescleanup

Rename RunPullImagesCheck to PullControlPlaneImages
k3s-v1.15.3
Kubernetes Prow Robot 2019-03-27 16:01:03 -07:00 committed by GitHub
commit 7131617d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 16 deletions

View File

@ -423,8 +423,7 @@ func NewCmdConfigImagesPull() *cobra.Command {
kubeadmutil.CheckErr(err)
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.NodeRegistration.CRISocket)
kubeadmutil.CheckErr(err)
imagesPull := NewImagesPull(containerRuntime, images.GetAllImages(&internalcfg.ClusterConfiguration))
kubeadmutil.CheckErr(imagesPull.PullAll())
PullControlPlaneImages(containerRuntime, &internalcfg.ClusterConfiguration)
},
}
AddImagesCommonConfigFlags(cmd.PersistentFlags(), externalcfg, &cfgPath, &featureGatesString)
@ -447,10 +446,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)
@ -505,7 +505,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)
}

View File

@ -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) {

View File

@ -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

View File

@ -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

View File

@ -1074,7 +1074,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)
}