Beispiel #1
0
func oci2docker(c *cli.Context) {
	ociPath := c.String("oci-bundle")
	imgName := c.String("image-name")
	port := c.String("port")
	flagDebug := c.Bool("debug")

	if c.NumFlags() == 0 {
		cli.ShowCommandHelp(c, "convert")
		return
	}

	if ociPath == "" {
		logrus.Infof("Please specify OCI bundle path.")
		return
	}

	_, err := os.Stat(ociPath)
	if os.IsNotExist(err) {
		logrus.Infof("OCI bundle path does not exsit.")
		return
	}

	if imgName == "" {
		logrus.Infof("Please specify docker image name for output.")
		return
	}

	convert.RunOCI2Docker(ociPath, flagDebug, imgName, port)

	return
}
Beispiel #2
0
func (cmd *Entity) Run(scope scope.Scope, c *cli.Context) {
	if err := net.VerifyLoginURL(cmd.network); err != nil {
		error_handler.ErrorExit(err)
	}
	if c.NumFlags() > 0 && c.FlagNames()[0] == "children" {
		cmd.listentity(scope.Application, c.StringSlice("children")[0])
	} else {
		if c.Args().Present() {
			cmd.show(scope.Application, c.Args().First())
		} else {
			if scope.Entity == scope.Application {
				cmd.listapp(scope.Application)
			} else {
				cmd.listentity(scope.Application, scope.Entity)
			}
		}
	}
}
Beispiel #3
0
func makeConfig(ctx *cli.Context) (*Config, []error) {
	var errs []error

	if ctx.GlobalBool("help") || ctx.NumFlags() == 0 {
		errs = append(errs, errors.New(""))
		return nil, errs
	}

	if ctx.GlobalString("pattern") == "" {
		errs = append(errs, errors.New("Specify --pattern (-p) to extract imports.\n\n"))
	}

	pattern, err := regexp.Compile(ctx.GlobalString("pattern"))
	if err != nil {
		errs = append(errs, errors.New(regexErrorMessage("--pattern (-p)")+err.Error()+"\n\n"))
	}

	module, err := regexp.Compile(ctx.GlobalString("module"))
	if err != nil {
		errs = append(errs, errors.New(regexErrorMessage("--module (-m)")+err.Error()+"\n\n"))
	}
	if ctx.GlobalString("module") == "" {
		module = nil
	}

	start, err := regexp.Compile(ctx.GlobalString("start"))
	if err != nil {
		errs = append(errs, errors.New(regexErrorMessage("--start (-s)")+err.Error()+"\n\n"))
	}
	if ctx.GlobalString("start") == "" {
		start = nil
	}

	end, err := regexp.Compile(ctx.GlobalString("end"))
	if err != nil {
		errs = append(errs, errors.New(regexErrorMessage("--end (-e)")+err.Error()+"\n\n"))
	}
	if ctx.GlobalString("end") == "" {
		end = nil
	}

	root := ctx.GlobalString("root")
	if root != "" {
		root, err = filepath.Abs(root)
		if err != nil {
			errs = append(errs, errors.New(regexErrorMessage("--root")+err.Error()+"\n\n"))
		}
	}

	output := ctx.App.Writer
	outfile := ctx.GlobalString("output")
	if outfile != "" {
		file, err := os.Create(outfile)
		if err != nil {
			errs = append(errs, errors.New("Cannot create the output file: "+outfile+"\n\n"))
		} else {
			output = file
		}
	}

	paths := ctx.Args()
	if len(paths) == 0 {
		errs = append(errs, errors.New("Specify source codes.\n\n"))
	}

	if len(errs) > 0 {
		return nil, errs
	}

	return &Config{
		Pattern:   pattern,
		Module:    module,
		Reverse:   ctx.GlobalBool("reverse"),
		Start:     start,
		End:       end,
		Format:    ctx.GlobalString("format"),
		Paths:     paths,
		Recursive: ctx.GlobalBool("recursive"),
		Root:      root,
		Output:    output,
	}, nil
}