Пример #1
0
func PullAction(c *cli.Context) {
	if !hasExpectedArgs(c.Args(), 1) {
		log.Fatal("Incorrect number of arguments to 'pull' command")
	}

	endpointDsn, err := dsn.Parse(c.Args()[0])
	if err != nil {
		log.Fatal(err)
	}

	switch endpointDsn.Scheme {
	case "s3":
		err := endpointDsn.SetDefaults(gS3Defaults)
		if err != nil {
			log.Fatal(err)
		}

		err = DownloadUsingS3(endpointDsn)
		if err != nil {
			log.Fatal(err)
		}
	case "scp":
		privateKey := c.String("ssh-private-key")

		err := endpointDsn.SetDefaults(gScpDefaults)
		if err != nil {
			log.Fatal(err)
		}

		err = DownloadUsingScp(endpointDsn, privateKey)
		if err != nil {
			log.Fatal(err)
		}
	}
}
Пример #2
0
func PullAction(c *cli.Context) {
	if !hasExpectedArgs(c.Args(), 1) {
		log.Fatal("Incorrect number of arguments to 'pull' command")
	}

	endpointDsn, err := dsn.Parse(c.Args()[0])
	if err != nil {
		log.Fatal(err)
	}

	switch endpointDsn.Scheme {
	case "s3":
		err := endpointDsn.SetDefaults(gS3Defaults)
		if err != nil {
			log.Fatal(err)
		}

		err = DownloadUsingS3(endpointDsn)
		if err != nil {
			log.Fatal(err)
		}
		Logger.Info("Trousseau data store succesfully pulled from S3")
	case "scp":
		privateKey := c.String("ssh-private-key")

		err := endpointDsn.SetDefaults(gScpDefaults)
		if err != nil {
			log.Fatal(err)
		}

		if c.Bool("ask-password") == true {
			password := PromptForPassword()
			endpointDsn.Secret = password
		}

		err = DownloadUsingScp(endpointDsn, privateKey)
		if err != nil {
			log.Fatal(err)
		}
		Logger.Info("Trousseau data store succesfully pulled from ssh remote storage")
	case "gist":
		err = DownloadUsingGist(endpointDsn)
		if err != nil {
			log.Fatal(err)
		}
		Logger.Info("Trousseau data store succesfully pulled from gist")
	default:
		if endpointDsn.Scheme == "" {
			log.Fatalf("No dsn scheme supplied")
		} else {
			log.Fatalf("Invalid dsn scheme supplied: %s", endpointDsn.Scheme)
		}
	}

	Logger.Info("Trousseau data store succesfully pulled from remote storage")
}
Пример #3
0
func PullAction(source string, sshPrivateKey string, askPassword bool) {
	endpointDsn, err := dsn.Parse(source)
	if err != nil {
		ErrorLogger.Fatal(err)
	}

	switch endpointDsn.Scheme {
	case "s3":
		err := endpointDsn.SetDefaults(S3Defaults)
		if err != nil {
			ErrorLogger.Fatal(err)
		}

		err = DownloadUsingS3(endpointDsn)
		if err != nil {
			ErrorLogger.Fatal(err)
		}
		InfoLogger.Println("Trousseau data store succesfully pulled from S3")
	case "scp":
		err := endpointDsn.SetDefaults(ScpDefaults)
		if err != nil {
			ErrorLogger.Fatal(err)
		}

		if askPassword == true {
			password := PromptForPassword()
			endpointDsn.Secret = password
		}

		err = DownloadUsingScp(endpointDsn, sshPrivateKey)
		if err != nil {
			ErrorLogger.Fatal(err)
		}
		InfoLogger.Println("Trousseau data store succesfully pulled from ssh remote storage")
	case "gist":
		err = DownloadUsingGist(endpointDsn)
		if err != nil {
			ErrorLogger.Fatal(err)
		}
		InfoLogger.Println("Trousseau data store succesfully pulled from gist")
	default:
		if endpointDsn.Scheme == "" {
			ErrorLogger.Fatalf("No dsn scheme supplied")
		} else {
			ErrorLogger.Fatalf("Invalid dsn scheme supplied: %s", endpointDsn.Scheme)
		}
	}

	InfoLogger.Println("Trousseau data store succesfully pulled from remote storage")
}
Пример #4
0
func PushAction(c *cli.Context) {
	if !hasExpectedArgs(c.Args(), 1) {
		log.Fatal("Incorrect number of arguments to 'push' command")
	}

	endpointDsn, err := dsn.Parse(c.Args()[0])
	if err != nil {
		log.Fatal(err)
	}

	switch endpointDsn.Scheme {
	case "s3":
		err := endpointDsn.SetDefaults(gS3Defaults)
		if err != nil {
			log.Fatal(err)
		}

		err = uploadUsingS3(endpointDsn)
		if err != nil {
			log.Fatal(err)
		}
		Logger.Info("Trousseau data store succesfully pushed to s3")
	case "scp":
		privateKey := c.String("ssh-private-key")

		err := endpointDsn.SetDefaults(gScpDefaults)
		if err != nil {
			log.Fatal(err)
		}

		if c.Bool("ask-password") == true {
			password := PromptForPassword()
			endpointDsn.Secret = password
		}

		err = uploadUsingScp(endpointDsn, privateKey)
		if err != nil {
			log.Fatal(err)
		}
		Logger.Info("Trousseau data store succesfully pushed to ssh remote storage")
	case "gist":
		err = uploadUsingGist(endpointDsn)
		if err != nil {
			log.Fatal(err)
		}
		Logger.Info("Trousseau data store succesfully pushed to gist")
	}
}
Пример #5
0
func PushAction(destination string, sshPrivateKey string, askPassword bool) {
	endpointDsn, err := dsn.Parse(destination)
	if err != nil {
		ErrorLogger.Fatal(err)
	}

	switch endpointDsn.Scheme {
	case "s3":
		err := endpointDsn.SetDefaults(S3Defaults)
		if err != nil {
			ErrorLogger.Fatal(err)
		}

		err = UploadUsingS3(endpointDsn)
		if err != nil {
			ErrorLogger.Fatal(err)
		}
		InfoLogger.Println("Trousseau data store succesfully pushed to s3")
	case "scp":
		err := endpointDsn.SetDefaults(ScpDefaults)
		if err != nil {
			ErrorLogger.Fatal(err)
		}

		if askPassword == true {
			password := PromptForPassword()
			endpointDsn.Secret = password
		}

		err = UploadUsingScp(endpointDsn, sshPrivateKey)
		if err != nil {
			ErrorLogger.Fatal(err)
		}
		InfoLogger.Println("Trousseau data store succesfully pushed to ssh remote storage")
	case "gist":
		err = UploadUsingGist(endpointDsn)
		if err != nil {
			ErrorLogger.Fatal(err)
		}
		InfoLogger.Println("Trousseau data store succesfully pushed to gist")
	}
}