create

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Create = &cobra.Command{
		Use:        "create",
		SuggestFor: []string{"config", "init"},
		Short:      "Creates a new container/config for this project",
		Args:       cobra.MaximumNArgs(1),
		Example:    "develbox create -c alpine/latest",
		Run: func(cmd *cobra.Command, args []string) {
			configExists := config.ConfigExists()

			if createCfg || !configExists {
				if configExists && !forceReplace {
					glg.Errorf("Config file already exists!\nUse -f to force the creation of a new config file.")
					os.Exit(1)
				}

				cfg := config.Struct{}

				if len(args) == 0 {
					cfg = promptConfig()
				} else {
					cfg = downloadConfig(args[0])
				}

				checkDocker(&cfg)
				config.SetDefaults(&cfg)

				promptName(&cfg)
				promptPorts(&cfg)
				promptVolumes(&cfg)

				err := config.Write(&cfg)
				if err != nil {
					glg.Error(err)
				}

				fmt.Println("Config file created!")

				if config.FileExists(".git") {
					err = setupGitIgnore()
					if err != nil {
						glg.Error(err)
					}
				}

				if !promptCont() {
					fmt.Println("Run again the following command create when you're ready to create the container:")
					fmt.Println("develbox create")
					return
				}
			}

			cfg, err := config.Read()
			if err != nil {
				glg.Errorf("Failed to read .develbox/config.json! Try running 'develbox create -c --force' to create a new one.")
				return
			}
			container.Create(cfg, forceReplace)
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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