Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add additional-images flag to build command #2159

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/build/nodeimage/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ func supportedArch(arch string) bool {
// build configuration
type buildContext struct {
// option fields
image string
baseImage string
logger log.Logger
image string
baseImage string
logger log.Logger
additionalImagesToPull []string
// non-option fields
arch string // TODO(bentheelder): this should be an option
kubeRoot string
Expand Down
3 changes: 3 additions & 0 deletions pkg/build/nodeimage/build_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ func (c *buildContext) prePullImages(bits kube.Bits, dir, containerID string) ([
// all builds should install the default storage driver images currently
requiredImages = append(requiredImages, defaultStorageImages...)

// include additional images passed in by the user
requiredImages = append(requiredImages, c.additionalImagesToPull...)

// Create "images" subdir.
imagesDir := path.Join(dir, "bits", "images")
if err := os.MkdirAll(imagesDir, 0777); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/build/nodeimage/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ func WithLogger(logger log.Logger) Option {
return nil
})
}

func WithAdditionalImagesToPull(images []string) Option {
return optionAdapter(func(b *buildContext) error {
b.additionalImagesToPull = images
return nil
})
}
17 changes: 12 additions & 5 deletions pkg/cmd/kind/build/nodeimage/nodeimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import (
)

type flagpole struct {
Source string
BuildType string
Image string
BaseImage string
KubeRoot string
Source string
BuildType string
Image string
BaseImage string
KubeRoot string
AdditionalImagesToPull []string
}

// NewCommand returns a new cobra.Command for building the node image
Expand Down Expand Up @@ -68,6 +69,11 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command {
nodeimage.DefaultBaseImage,
"name:tag of the base image to use for the build",
)
cmd.Flags().StringSliceVar(
&flags.AdditionalImagesToPull, "additional-images",
[]string{},
"list of additional images to pull",
)
return cmd
}

Expand All @@ -77,6 +83,7 @@ func runE(logger log.Logger, flags *flagpole) error {
nodeimage.WithBaseImage(flags.BaseImage),
nodeimage.WithKuberoot(flags.KubeRoot),
nodeimage.WithLogger(logger),
nodeimage.WithAdditionalImagesToPull(flags.AdditionalImagesToPull),
); err != nil {
return errors.Wrap(err, "error building node image")
}
Expand Down