Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
makisu pull: add support for --registry-config
Browse files Browse the repository at this point in the history
This is useful to authenticate with the registry when pulling images.
  • Loading branch information
lbpdt committed Mar 11, 2021
1 parent 7d88e9f commit aad9b0f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions bin/makisu/cmd/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ import (
type pullCmd struct {
*cobra.Command

registry string
tag string
cacerts string
extract string
registryConfig string
registry string
tag string
cacerts string
extract string
}

func getPullCmd() *pullCmd {
pullCmd := &pullCmd{
Command: &cobra.Command{
Use: "pull --dest <destination of rootfs> <image repository>",
Use: "pull --dest <destination of rootfs> <image repository>",
DisableFlagsInUseLine: true,
Short: "Pull docker image from registry into the storage directory of makisu.",
Short: "Pull docker image from registry into the storage directory of makisu.",
},
}
pullCmd.Args = func(cmd *cobra.Command, args []string) error {
Expand All @@ -44,6 +45,7 @@ func getPullCmd() *pullCmd {
pullCmd.Pull(args[0])
}

pullCmd.PersistentFlags().StringVar(&pullCmd.registryConfig, "registry-config", "", "Set build-time variables")
pullCmd.PersistentFlags().StringVar(&pullCmd.registry, "registry", "index.docker.io", "The registry to pull the image from.")
pullCmd.PersistentFlags().StringVar(&pullCmd.tag, "tag", "latest", "The tag of the image to pull.")
pullCmd.PersistentFlags().StringVar(&pullCmd.cacerts, "cacerts", "/etc/ssl/certs", "The location of the CA certs to use for TLS authentication with the registry.")
Expand All @@ -53,6 +55,10 @@ func getPullCmd() *pullCmd {
}

func (cmd *pullCmd) Pull(repository string) {
if err := initRegistryConfig(cmd.registryConfig); err != nil {
panic(fmt.Errorf("failed to initialize registry configuration: %s", err))
}

store, err := storage.NewImageStore("/tmp/makisu-storage")
if err != nil {
panic(err)
Expand Down

0 comments on commit aad9b0f

Please sign in to comment.