func getConnection(args []string) []string { secret, access = getKeys() if secret == "" || access == "" { fmt.Println("could not get keys") os.Exit(1) } if len(args) < 1 { fmt.Println("no region argument") os.Exit(1) } var region *aws.Region for _, v := range aws.Regions { if v.Name == args[0] { region = v break } } if region == nil { fmt.Println("could not find region:", args[0]) os.Exit(1) } connection = glacier.NewConnection(secret, access, region) connection.Signature.NewKeys = aws.KeysFromEnviroment return args[1:] }
// GetCon create a new glacier.Connection using environment variables. func GetCon(region string) *glacier.Connection { accessKey := os.Getenv("S3_ACCESS_KEY") secretKey := os.Getenv("S3_SECRET_KEY") if accessKey == "" || secretKey == "" { panic("S3_ACCESS_KEY or S3_SECRET_KEY not set") } con := glacier.NewConnection(secretKey, accessKey, getRegion(region)) return con }