本文整理汇总了Golang中github.com/crowdmob/goamz/aws.GetAuth函数的典型用法代码示例。如果您正苦于以下问题:Golang GetAuth函数的具体用法?Golang GetAuth怎么用?Golang GetAuth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetAuth函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: updateAuth
func (r53 *Route53) updateAuth() {
r53.authLock.Lock()
// update auth
auth, err := aws.GetAuth("", "", "", time.Time{})
for ; err != nil; auth, err = aws.GetAuth("", "", "", time.Time{}) {
if debug {
log.Printf("[Route53] Error getting auth (sleeping 5s before retry): %v", err)
}
time.Sleep(5 * time.Second)
}
r53.auth = auth
if debug {
log.Printf("[Route53] auth updated. expires at %v.", auth.Expiration())
}
r53.authLock.Unlock()
}
开发者ID:jigish,项目名称:route53,代码行数:16,代码来源:route53.go
示例2: FetchMetrics
// FetchMetrics fetch elasticache values
func (p ECachePlugin) FetchMetrics() (map[string]float64, error) {
auth, err := aws.GetAuth(p.AccessKeyID, p.SecretAccessKey, "", time.Now())
if err != nil {
return nil, err
}
cloudWatch, err := cloudwatch.NewCloudWatch(auth, aws.Regions[p.Region].CloudWatchServicepoint)
if err != nil {
return nil, err
}
stat := make(map[string]float64)
perInstances := &[]cloudwatch.Dimension{
cloudwatch.Dimension{
Name: "CacheClusterId",
Value: p.CacheClusterID,
},
cloudwatch.Dimension{
Name: "CacheNodeId",
Value: p.CacheNodeID,
},
}
for _, met := range p.CacheMetrics {
v, err := getLastPoint(cloudWatch, perInstances, met)
if err == nil {
stat[met] = v
} else {
log.Printf("%s: %s", met, err)
}
}
return stat, nil
}
开发者ID:yano3,项目名称:mackerel-agent-plugins,代码行数:36,代码来源:aws-elasticache.go
示例3: main
func main() {
kingpin.Version("1.2.1")
kingpin.Parse()
sl, err := syslog.New(syslog.LOG_NOTICE|syslog.LOG_LOCAL0, "[varnish-purge-proxy]")
defer sl.Close()
if err != nil {
log.Println("Error writing to syslog")
} else {
log.SetFlags(0)
log.SetOutput(sl)
}
if len(*tags) == 0 {
fmt.Println("No tags specified")
return
}
// Set up access to ec2
auth, err := aws.GetAuth("", "", "", time.Now().Add(time.Duration(24*365*time.Hour)))
if err != nil {
log.Println(err)
return
}
ec2region := ec2.New(auth, region)
go serveHTTP(*port, ec2region)
select {}
}
开发者ID:madedotcom,项目名称:varnish-purge-proxy,代码行数:30,代码来源:varnish-purge-proxy.go
示例4: FetchMetrics
// FetchMetrics fetch the metrics
func (p CPUCreditPlugin) FetchMetrics() (map[string]float64, error) {
region := aws.Regions[p.Region]
dimension := &cloudwatch.Dimension{
Name: "InstanceId",
Value: p.InstanceID,
}
auth, err := aws.GetAuth(p.AccessKeyID, p.SecretAccessKey, "", time.Now())
if err != nil {
return nil, err
}
cw, err := cloudwatch.NewCloudWatch(auth, region.CloudWatchServicepoint)
stat := make(map[string]float64)
stat["usage"], err = getLastPointAverage(cw, dimension, "CPUCreditUsage")
if err != nil {
return nil, err
}
stat["balance"], err = getLastPointAverage(cw, dimension, "CPUCreditBalance")
if err != nil {
return nil, err
}
return stat, nil
}
开发者ID:netmarkjp,项目名称:mackerel-agent-plugins,代码行数:28,代码来源:aws-ec2-cpucredit.go
示例5: FetchMetrics
func (p RDSPlugin) FetchMetrics() (map[string]float64, error) {
auth, err := aws.GetAuth(p.AccessKeyId, p.SecretAccessKey, "", time.Now())
if err != nil {
return nil, err
}
cloudWatch, err := cloudwatch.NewCloudWatch(auth, aws.Regions[p.Region].CloudWatchServicepoint)
if err != nil {
return nil, err
}
stat := make(map[string]float64)
perInstance := &cloudwatch.Dimension{
Name: "DBInstanceIdentifier",
Value: p.Identifier,
}
for _, met := range [...]string{
"BinLogDiskUsage", "CPUUtilization", "DatabaseConnections", "DiskQueueDepth", "FreeableMemory",
"FreeStorageSpace", "ReplicaLag", "SwapUsage", "ReadIOPS", "WriteIOPS", "ReadLatency",
"WriteLatency", "ReadThroughput", "WriteThroughput", "NetworkTransmitThroughput", "NetworkReceiveThroughput",
} {
v, err := GetLastPoint(cloudWatch, perInstance, met)
if err == nil {
stat[met] = v
} else {
log.Printf("%s: %s", met, err)
}
}
return stat, nil
}
开发者ID:monochromegane,项目名称:mackerel-agent-plugins,代码行数:33,代码来源:aws-rds.go
示例6: GetAuthFromEnv
func GetAuthFromEnv() aws.Auth {
auth, err := aws.GetAuth("", "", "", time.Now())
if err != nil && os.Getenv("CLOUD_ENVIRONMENT") == "PRODUCTION" {
log.Fatalln("Failed to recieve auth from env")
}
return auth
}
开发者ID:hyandell,项目名称:aws_utils,代码行数:7,代码来源:notifier.go
示例7: getAuth
func (s *S3) getAuth() (err error) {
s.auth, err = aws.GetAuth(s.AccessKey, s.SecretKey, "", time.Time{})
if s.s3 != nil {
s.s3.Auth = s.auth
}
return
}
开发者ID:hqm,项目名称:go-docker-registry,代码行数:7,代码来源:s3.go
示例8: FetchMetrics
// FetchMetrics interface for mackerel-plugin
func (p RDSPlugin) FetchMetrics() (map[string]float64, error) {
auth, err := aws.GetAuth(p.AccessKeyID, p.SecretAccessKey, "", time.Now())
if err != nil {
return nil, err
}
cloudWatch, err := cloudwatch.NewCloudWatch(auth, aws.Regions[p.Region].CloudWatchServicepoint)
if err != nil {
return nil, err
}
stat := make(map[string]float64)
perInstance := &cloudwatch.Dimension{
Name: "DBInstanceIdentifier",
Value: p.Identifier,
}
for _, met := range p.rdsMetrics() {
v, err := getLastPoint(cloudWatch, perInstance, met)
if err == nil {
stat[met] = v
} else {
log.Printf("%s: %s", met, err)
}
}
return stat, nil
}
开发者ID:supercaracal,项目名称:mackerel-agent-plugins,代码行数:30,代码来源:aws-rds.go
示例9: setupS3Logger
func (app *AppContext) setupS3Logger() (err error) {
auth, err := aws.GetAuth("", "", "", time.Now())
if err != nil {
log.Fatalln("Failed to find AWS credentials in env")
}
awsConnection := s3.New(
auth,
getAWSRegion(app.config.aws_region),
)
bucket := awsConnection.Bucket(app.config.bucket)
instanceInfo := keygen.BuildInstanceInfo(
&keygen.EnvInstanceFetcher{},
serviceName,
app.config.logging_dir,
)
rotateCoordinator := gologging.NewRotateCoordinator(
app.config.max_log_lines,
app.config.max_log_age,
)
metricsLogger := MetricsLogger{app.metrics}
app.s3log, err = gologging.StartS3Logger(
rotateCoordinator,
instanceInfo,
&metricsLogger,
&uploader.S3UploaderBuilder{
Bucket: bucket,
KeyNameGenerator: &KeyNameGenerator{
Info: instanceInfo,
Prefix: app.config.key_prefix,
},
},
&metricsLogger,
app.config.num_workers,
)
if err != nil {
return
}
// Make sure logger is flushed when shutdown signal is received
sigc := make(chan os.Signal, 1)
signal.Notify(sigc,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT)
go func() {
<-sigc
log.Println("interrupted, closing logger...")
app.s3log.Close()
os.Exit(0)
}()
return nil
}
开发者ID:robbles,项目名称:analyticsd,代码行数:60,代码来源:s3_logger.go
示例10: s3Setup
func s3Setup(bucketName string, path string, opts sequinsOptions) *sequins {
auth, err := aws.GetAuth(*s3AccessKey, *s3SecretKey, "", time.Time{})
if err != nil {
log.Fatal(err)
}
regionName := *s3Region
if regionName == "" {
regionName = aws.InstanceRegion()
if regionName == "" {
log.Fatal("Unspecified --s3-region, and no instance region found.")
}
}
region, exists := aws.Regions[regionName]
if !exists {
log.Fatalf("Invalid AWS region: %s", regionName)
}
bucket := s3.New(auth, region).Bucket(bucketName)
backend := backend.NewS3Backend(bucket, path)
if opts.LocalPath == "" {
tmpDir, err := ioutil.TempDir("", "sequins-")
if err != nil {
log.Fatal(err)
}
opts.LocalPath = tmpDir
}
return newSequins(backend, opts)
}
开发者ID:delkyd,项目名称:sequins,代码行数:32,代码来源:main.go
示例11: setupS3
func setupS3() *backend.S3Backend {
fakeS3, _ := s3test.NewServer(&s3test.Config{})
// cargo-culted from s3test
fakeRegion := aws.Region{
Name: "faux-region-1",
S3Endpoint: fakeS3.URL(),
S3LocationConstraint: true,
}
auth, _ := aws.GetAuth("foo", "bar", "", time.Time{})
bucket := s3.New(auth, fakeRegion).Bucket("sequinstest")
bucket.PutBucket("")
putFile(bucket, "test_data/0/part-00000")
putFile(bucket, "test_data/0/part-00001")
putFile(bucket, "test_data/0/_SUCCESS")
putFile(bucket, "test_data/1/part-00000")
putFile(bucket, "test_data/1/part-00001")
bucket.Put("test_data/foo", []byte("nothing"), "", "", s3.Options{})
return backend.NewS3Backend(bucket, "test_data")
}
开发者ID:delkyd,项目名称:sequins,代码行数:25,代码来源:s3_sequins_test.go
示例12: main
func main() {
flag.Parse()
log.SetOutput(os.Stdout)
auth, err := aws.GetAuth("", "", "", time.Time{})
if err != nil {
log.Fatalln("Failed to recieve auth")
}
stats, err := lib.InitStats(statsPrefix)
if err != nil {
log.Fatalln("Error initializing stats:", err)
}
postgresBackend, err := metadata.NewPostgresStorer(&pgConfig)
listener := StartWorker(&listener.SQSAddr{
Region: aws.USWest2,
QueueName: "spade-compactor-" + env,
Auth: auth,
}, stats, postgresBackend)
wait := make(chan struct{})
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGINT)
go func() {
<-sigc
// Cause flush
listener.Close()
close(wait)
}()
<-wait
}
开发者ID:hyandell,项目名称:rs_ingester,代码行数:35,代码来源:main.go
示例13: main
func main() {
var inst_id string
if instanceID == "" {
inst_id := aws.InstanceId()
if inst_id == "unknown" {
log.Fatalln("Unable to get instance id")
}
} else {
inst_id = instanceID
}
auth, err := aws.GetAuth(accesskey, secretkey, "", time.Time{})
if err != nil {
log.Fatalln("Unable to get AWS auth", err)
}
awsec2 = ec2.New(auth, aws.GetRegion(region))
groupMap := getSecurityGroupIds(inst_id)
for _, id := range securityGroupIDs {
groupMap[id] = true
}
groupIds := make([]string, 0, len(groupMap))
for id := range groupMap {
groupIds = append(groupIds, id)
}
opts := &ec2.ModifyInstanceAttributeOptions{SecurityGroups: ec2.SecurityGroupIds(groupIds...)}
resp, err := awsec2.ModifyInstanceAttribute(inst_id, opts)
if err != nil || !resp.Return {
log.Fatalln("Error adding security groups to instance", err)
}
log.Printf("Added security groups %s to instance %s\n", securityGroupIDs.String(), inst_id)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL)
// this waits until we get a kill signal
<-c
groupMap = getSecurityGroupIds(inst_id)
for _, id := range securityGroupIDs {
delete(groupMap, id)
}
groupIds = make([]string, 0, len(groupMap))
for id := range groupMap {
groupIds = append(groupIds, id)
}
opts = &ec2.ModifyInstanceAttributeOptions{SecurityGroups: ec2.SecurityGroupIds(groupIds...)}
resp, err = awsec2.ModifyInstanceAttribute(inst_id, opts)
if err != nil || !resp.Return {
log.Fatalln("Error removing security groups from instance", err)
}
log.Printf("Removed security groups %s from instance %s\n", securityGroupIDs.String(), inst_id)
}
开发者ID:rdark,项目名称:go-ec2-security-group-presence,代码行数:59,代码来源:main.go
示例14: TestGetAuthEnv
func (s *S) TestGetAuthEnv(c *check.C) {
os.Clearenv()
os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
os.Setenv("AWS_ACCESS_KEY_ID", "access")
auth, err := aws.GetAuth("", "", "", time.Time{})
c.Assert(err, check.IsNil)
c.Assert(auth, check.Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
}
开发者ID:hayesgm,项目名称:goamz,代码行数:8,代码来源:aws_test.go
示例15: TestGetAuthStatic
func (s *S) TestGetAuthStatic(c *check.C) {
exptdate := time.Now().Add(time.Hour)
auth, err := aws.GetAuth("access", "secret", "token", exptdate)
c.Assert(err, check.IsNil)
c.Assert(auth.AccessKey, check.Equals, "access")
c.Assert(auth.SecretKey, check.Equals, "secret")
c.Assert(auth.Token(), check.Equals, "token")
c.Assert(auth.Expiration(), check.Equals, exptdate)
}
开发者ID:hayesgm,项目名称:goamz,代码行数:9,代码来源:aws_test.go
示例16: newS3Client
// create a new s3 client from the url
func newS3Client(config config.Config) (*s3.S3, error) {
auth, err := aws.GetAuth(config.AWS.AccessKeyID, config.AWS.SecretAccessKey, "", time.Now())
if err != nil {
return &s3.S3{}, err
}
if config.AWS.Region == "" {
return nil, errors.New("Region not set for S3 client lib (missing SetS3URL?)")
}
return s3.New(auth, aws.Regions[config.AWS.Region]), nil
}
开发者ID:number9code,项目名称:dogestry,代码行数:13,代码来源:s3.go
示例17: prepare
func (p *ESPlugin) prepare() error {
auth, err := aws.GetAuth(p.AccessKeyID, p.SecretAccessKey, "", time.Now())
if err != nil {
return err
}
p.CloudWatch, err = cloudwatch.NewCloudWatch(auth, aws.Regions[p.Region].CloudWatchServicepoint)
if err != nil {
return err
}
return nil
}
开发者ID:yano3,项目名称:mackerel-agent-plugins,代码行数:12,代码来源:aws-elasticsearch.go
示例18: New
func New() (*Route53, error) {
auth, err := aws.GetAuth("", "", "", time.Time{})
if err != nil {
return nil, err
}
r53 := &Route53{
auth: auth,
authLock: sync.RWMutex{},
}
go r53.updateAuthLoop()
return r53, nil
}
开发者ID:jigish,项目名称:route53,代码行数:12,代码来源:route53.go
示例19: main
func main() {
route53.DebugOn()
auth, err := aws.GetAuth("", "", "", time.Time{})
if err != nil {
fmt.Fprintln(os.Stderr, "error: no aws credentials available")
os.Exit(255)
}
r53 = route53.NewWithAuth(auth)
NewClient().Parse()
}
开发者ID:jigish,项目名称:route53,代码行数:13,代码来源:route53.go
示例20: GetBucket
func GetBucket(bucketPrefix string) (*s3.Bucket, error) {
auth, err := aws.GetAuth("", "", "", time.Time{})
if err != nil {
return nil, err
}
s := s3.New(auth, aws.USWest2)
s.ConnectTimeout = time.Second * 30
s.ReadTimeout = time.Second * 30
bucketName := strings.TrimPrefix(bucketPrefix, "s3://") + "-" + environment.GetCloudEnv()
return s.Bucket(bucketName), nil
}
开发者ID:hyandell,项目名称:rs_ingester,代码行数:13,代码来源:scooploader.go
注:本文中的github.com/crowdmob/goamz/aws.GetAuth函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论