Ejemplo n.º 1
0
func createDefaultDownloadSpec(c *cli.Context) *utils.SpecFiles {
	pattern := strings.TrimPrefix(c.Args().Get(0), "/")
	target := c.Args().Get(1)
	props := c.String("props")
	recursive := cliutils.GetBoolFlagValue(c, "recursive", true)
	flat := cliutils.GetBoolFlagValue(c, "flat", false)

	return utils.CreateSpec(pattern, target, props, recursive, flat, false)
}
Ejemplo n.º 2
0
func createConfigFlags(c *cli.Context) (configFlag *commands.ConfigFlags, err error) {
	configFlag = new(commands.ConfigFlags)
	configFlag.ArtDetails, err = createArtifactoryDetails(c, false)
	if err != nil {
		return
	}
	configFlag.EncPassword = cliutils.GetBoolFlagValue(c, "enc-password", true)
	configFlag.Interactive = cliutils.GetBoolFlagValue(c, "interactive", true)
	if !configFlag.Interactive && configFlag.ArtDetails.Url == "" {
		cliutils.Exit(cliutils.ExitCodeError, "The --url option is mandatory when the --interactive option is set to false")
	}
	return
}
Ejemplo n.º 3
0
func createDefaultSearchSpec(c *cli.Context) *utils.SpecFiles {
	pattern := c.Args().Get(0)
	props := c.String("props")
	recursive := cliutils.GetBoolFlagValue(c, "recursive", true)

	return utils.CreateSpec(pattern, "", props, recursive, false, false)
}
Ejemplo n.º 4
0
func createAttachLicFlags(c *cli.Context) (flags *rtinstances.AttachLicFlags, err error) {
	flags = new(rtinstances.AttachLicFlags)
	flags.MissionControlDetails, err = createMissionControlDetails(c, true)
	if err != nil {
		return
	}
	flags.LicensePath = c.String("license-path")
	if strings.HasSuffix(flags.LicensePath, ioutils.GetFileSeperator()) {
		cliutils.Exit(cliutils.ExitCodeError, "The --license-path option cannot be a directory")
	}
	if flags.BucketId = c.String("bucket-id"); flags.BucketId == "" {
		cliutils.Exit(cliutils.ExitCodeError, "The --bucket-id option is mandatory")
	}
	flags.Override = cliutils.GetBoolFlagValue(c, "override", false)
	flags.Deploy = cliutils.GetBoolFlagValue(c, "deploy", false)
	flags.NodeId = c.String("node-id")
	return
}
Ejemplo n.º 5
0
func createRemoveInstanceFlags(c *cli.Context) (flags *rtinstances.RemoveFlags, err error) {
	details, err := createMissionControlDetails(c, true)
	if err != nil {
		return
	}
	flags = &rtinstances.RemoveFlags{
		MissionControlDetails: details,
		Interactive:           cliutils.GetBoolFlagValue(c, "interactive", true)}

	return
}
Ejemplo n.º 6
0
func createUploadFlags(c *cli.Context) (*commands.UploadFlags, error) {
	deb := c.String("deb")
	if deb != "" && len(strings.Split(deb, "/")) != 3 {
		cliutils.Exit(cliutils.ExitCodeError, "The --deb option should be in the form of distribution/component/architecture")
	}
	details, err := createBintrayDetails(c, true)
	if err != nil {
		return nil, err
	}
	return &commands.UploadFlags{
		BintrayDetails: details,
		Recursive:      cliutils.GetBoolFlagValue(c, "recursive", true),
		Flat:           cliutils.GetBoolFlagValue(c, "flat", true),
		Publish:        cliutils.GetBoolFlagValue(c, "publish", false),
		Override:       cliutils.GetBoolFlagValue(c, "override", false),
		Explode:        cliutils.GetBoolFlagValue(c, "explode", false),
		UseRegExp:      c.Bool("regexp"),
		Threads:        getThreadsOptionValue(c),
		Deb:            deb,
		DryRun:         c.Bool("dry-run")}, nil
}
Ejemplo n.º 7
0
func createConfigFlags(c *cli.Context) (flags *commands.ConfigFlags, err error) {
	flags = new(commands.ConfigFlags)
	flags.Interactive = cliutils.GetBoolFlagValue(c, "interactive", true)
	flags.MissionControlDetails, err = createMissionControlDetails(c, false)
	if err != nil {
		return
	}
	if !flags.Interactive && flags.MissionControlDetails.Url == "" {
		cliutils.Exit(cliutils.ExitCodeError, "The --url option is mandatory when the --interactive option is set to false")
	}
	return
}
Ejemplo n.º 8
0
func createBuildDistributionFlags(c *cli.Context) (distributeFlags *commands.BuildDistributionFlags, err error) {
	distributeFlags = new(commands.BuildDistributionFlags)
	distributeFlags.Publish = cliutils.GetBoolFlagValue(c, "publish", true)
	distributeFlags.OverrideExistingFiles = c.Bool("override")
	distributeFlags.GpgPassphrase = c.String("passphrase")
	distributeFlags.Async = c.Bool("async")
	distributeFlags.SourceRepos = c.String("source-repos")
	distributeFlags.DryRun = c.Bool("dry-run")

	distributeFlags.ArtDetails, err = createArtifactoryDetailsByFlags(c, true)
	return
}
Ejemplo n.º 9
0
func createDownloadFlags(c *cli.Context) (*utils.DownloadFlags, error) {
	flat := false
	if c.String("flat") != "" {
		flat = c.Bool("flat")
	}
	details, err := createBintrayDetails(c, true)
	if err != nil {
		return nil, err
	}
	return &utils.DownloadFlags{
		BintrayDetails:     details,
		Threads:            getThreadsOptionValue(c),
		MinSplitSize:       getMinSplitFlag(c),
		SplitCount:         getSplitCountFlag(c),
		IncludeUnpublished: cliutils.GetBoolFlagValue(c, "unpublished", false),
		Flat:               flat}, nil
}
Ejemplo n.º 10
0
func configure(c *cli.Context) {
	if c.NArg() > 1 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	} else if c.NArg() == 1 {
		if c.Args().Get(0) == "show" {
			commands.ShowConfig()
		} else if c.Args().Get(0) == "clear" {
			commands.ClearConfig()
		} else {
			cliutils.Exit(cliutils.ExitCodeError, "Unknown argument '"+c.Args().Get(0)+"'. Available arguments are 'show' and 'clear'.")
		}
	} else {
		interactive := cliutils.GetBoolFlagValue(c, "interactive", true)
		if !interactive {
			if c.String("user") == "" || c.String("key") == "" {
				cliutils.Exit(cliutils.ExitCodeError, "The --user and --key options are mandatory when the --interactive option is set to false")
			}
		}
		bintrayDetails, err := createBintrayDetails(c, false)
		cliutils.ExitOnErr(err)
		commands.Config(bintrayDetails, nil, interactive)
	}
}
Ejemplo n.º 11
0
func offerConfig(c *cli.Context) (details *config.ArtifactoryDetails, err error) {
	var exists bool
	exists, err = config.IsArtifactoryConfExists()
	if err != nil {
		return
	}
	if exists {
		return
	}
	var val bool
	val, err = cliutils.GetBoolEnvValue("JFROG_CLI_OFFER_CONFIG", true)
	if err != nil {
		return
	}
	if !val {
		config.SaveArtifactoryConf(new(config.ArtifactoryDetails))
		return
	}
	msg := "The CLI commands require the Artifactory URL and authentication details\n" +
		"Configuring JFrog CLI with these parameters now will save you having to include them as command options.\n" +
		"You can also configure these parameters later using the 'config' command.\n" +
		"Configure now? (y/n): "
	fmt.Print(msg)
	var confirm string
	fmt.Scanln(&confirm)
	if !cliutils.ConfirmAnswer(confirm) {
		config.SaveArtifactoryConf(new(config.ArtifactoryDetails))
		return
	}
	details, err = createArtifactoryDetails(c, false)
	if err != nil {
		return
	}
	encPassword := cliutils.GetBoolFlagValue(c, "enc-password", true)
	details, err = commands.Config(nil, details, true, encPassword)
	return
}