Пример #1
0
func main() {
	if len(os.Args) < 2 {
		s3resource.Sayf("usage: %s <sources directory>\n", os.Args[0])
		os.Exit(1)
	}

	var request out.OutRequest
	inputRequest(&request)

	sourceDir := os.Args[1]

	client, err := s3resource.NewS3Client(
		request.Source.AccessKeyID,
		request.Source.SecretAccessKey,
		request.Source.RegionName,
		request.Source.Endpoint,
		!request.Source.DisableMD5HashCheck,
	)
	if err != nil {
		s3resource.Fatal("building S3 client", err)
	}

	command := out.NewOutCommand(client)
	response, err := command.Run(sourceDir, request)
	if err != nil {
		s3resource.Fatal("running command", err)
	}

	outputResponse(response)
}
func main() {
	if len(os.Args) < 2 {
		s3resource.Sayf("usage: %s <sources directory>\n", os.Args[0])
		os.Exit(1)
	}

	var request out.OutRequest
	inputRequest(&request)

	sourceDir := os.Args[1]

	awsConfig := s3resource.NewAwsConfig(
		request.Source.AccessKeyID,
		request.Source.SecretAccessKey,
		request.Source.RegionName,
		request.Source.Endpoint,
		request.Source.DisableSSL,
	)

	client := s3resource.NewS3Client(
		os.Stderr,
		awsConfig,
	)

	command := out.NewOutCommand(os.Stderr, client)
	response, err := command.Run(sourceDir, request)
	if err != nil {
		s3resource.Fatal("running command", err)
	}

	outputResponse(response)
}
			tmpPath, err = ioutil.TempDir("", "out_command")
			Ω(err).ShouldNot(HaveOccurred())

			sourceDir = filepath.Join(tmpPath, "source")
			err = os.MkdirAll(sourceDir, 0755)
			Ω(err).ShouldNot(HaveOccurred())

			request = out.OutRequest{
				Source: s3resource.Source{
					Bucket: "bucket-name",
				},
			}

			s3client = &fakes.FakeS3Client{}
			stderr = gbytes.NewBuffer()
			command = out.NewOutCommand(stderr, s3client)
		})

		AfterEach(func() {
			stderr.Close()
			err := os.RemoveAll(tmpPath)
			Ω(err).ShouldNot(HaveOccurred())
		})

		createFile := func(path string) {
			fullPath := filepath.Join(sourceDir, path)
			err := os.MkdirAll(filepath.Dir(fullPath), 0755)
			Ω(err).ShouldNot(HaveOccurred())

			file, err := os.Create(fullPath)
			Ω(err).ShouldNot(HaveOccurred())