cmd

package
v1.0.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:     "canned-whale",
	Aliases: []string{"canned-whale"},
	Short:   "A docker registry export tool",
	Long: `A docker registry export tool implement by Go.
    Complete documentation is available at https://github.com/DockerAcCn/canned-whale`,
	RunE: func(cmd *cobra.Command, args []string) error {
		fmt.Println("start docker registry...")
		err := InitBinFS()
		if err != nil {
			return fmt.Errorf("init registry client error: %+v", err)
		}
		command := exec.Command("chmod", "a+x", "bin/registry")
		err = command.Run()
		if err != nil {
			return fmt.Errorf("start registry client error: %+v", err)
		}
		if configFile == "" {
			err := copyFSFile("bin/config.yml", "bin/config.yml")
			if err != nil {
				return fmt.Errorf("generate registry config file error: %+v", err)
			}
			configFile = "./bin/config.yml"
		}
		runRegistryCmd := exec.Command("./bin/registry", "serve", configFile)
		go func() {
			err := runRegistryCmd.Run()
			if err != nil {
				fmt.Printf("start docker registry error: %+v\n", err)
			}
		}()
		fmt.Println("start sync task...")
		client, err := client.NewSyncClient("", authFile, imageFile, "", procNum, retries, "", "", osFilterList, archFilterList)
		if err != nil {
			return fmt.Errorf("init sync client error: %+v", err)
		}
		client.Run()
		fmt.Println("start package...")
		command = exec.Command("mv", "/tmp/registry", "./registry")
		err = command.Run()
		if err != nil {
			return fmt.Errorf("move package error: %+v", err)
		}
		command = exec.Command("tar", "zcvf", "registry.tgz", "registry")
		err = command.Run()
		if err != nil {
			return fmt.Errorf("package error: %+v", err)
		}
		command = exec.Command("rm", "-rf", "./registry")
		err = command.Run()
		if err != nil {
			return fmt.Errorf("remove cache error: %+v", err)
		}
		runRegistryCmd.Process.Kill()
		path.RemovePath(cachedPath)
		fmt.Println("Finished")
		return nil
	},
}

Functions

func Execute

func Execute()

func InitBinFS

func InitBinFS() (err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL