// behavior to implement:
// 1. parse the transfer file list
// 2. lookup cached result
// 3. if miss, or X days old, actually lookup bucket
// 4. cache lookup if successful
behavior to implement:
1. parse the transfer file list
2. lookup cached result
3. if miss, or X days old, actually lookup bucket
4. cache lookup if successful
// behavior to implement : // 1 . parse the transfer file list // 2 . lookup cached result // 3 . if miss or X days old actually lookup bucket // 4 . cache lookup if successful
func locateBucket(cmd *cobra.Command, args []string) {
	bucket := aws.String(args[0])
	secretAccessKeyID, err := ioutil.ReadFile(secretAccessKeyIDFile)
	secretAccessKey, err := ioutil.ReadFile(secretAccessKeyFile)
	svc := s3.New(session.New(), &aws.Config{
		Region:   aws.String("us-central1"),
		Endpoint: aws.String("storage.googleapis.com"),
		Credentials: credentials.NewStaticCredentials(
			strings.TrimSpace(string(secretAccessKeyID)),
			strings.TrimSpace(string(secretAccessKey)),
			""),
	})
	input := &s3.GetBucketLocationInput{
		Bucket: bucket,
	}
	result, err := svc.GetBucketLocation(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			fmt.Println(err.Error())
		}
		return
	}
	fmt.Println("+CloudDataProvider=\"GCP\"")
	fmt.Println("+CloudDataLocation=\"" + *result.LocationConstraint + "\"")
}
func locateBucket ( cmd * cobra . Command , args [ ] string ) { bucket := aws . String ( args [ 0 ] ) secretAccessKeyID , err := ioutil . ReadFile ( secretAccessKeyIDFile ) secretAccessKey , err := ioutil . ReadFile ( secretAccessKeyFile ) svc := s3 . New ( session . New ( ) , & aws . Config { Region : aws . String ( " " ) , Endpoint : aws . String ( " " ) , Credentials : credentials . NewStaticCredentials ( strings . TrimSpace ( string ( secretAccessKeyID ) ) , strings . TrimSpace ( string ( secretAccessKey ) ) , " " ) , } ) input := & s3 . GetBucketLocationInput { Bucket : bucket , } result , err := svc . GetBucketLocation ( input ) if err != nil { if aerr , ok := err . ( awserr . Error ) ; ok { switch aerr . Code ( ) { default : fmt . Println ( aerr . Error ( ) ) } } else { fmt . Println ( err . Error ( ) ) } return } fmt . Println ( " \" \" " ) fmt . Println ( " \" " + * result . LocationConstraint + " \" " ) }
behavior to implement:
1. parse the transfer file list
2. lookup cached result
3. if miss, or X days old, actually lookup bucket
4. cache lookup if successful
behavior to implement : 1 . parse the transfer file list 2 . lookup cached result 3 . if miss or X days old actually lookup bucket 4 . cache lookup if successful
// Print the error, cast err to awserr.Error to get the Code and // Message from an error.