func (s *AmazonServer) SetUp(c *C) { auth, err := aws.EnvAuth() if err != nil { c.Fatal(err.Error()) } s.auth = auth }
func (s *S) TestEnvAuthLegacy(c *C) { os.Clearenv() os.Setenv("EC2_SECRET_KEY", "secret") os.Setenv("EC2_ACCESS_KEY", "access") auth, err := aws.EnvAuth() c.Assert(err, IsNil) c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"}) }
func (r *Runner) start() error { r.githubToken = os.Getenv("GITHUB_TOKEN") if r.githubToken == "" { return errors.New("GITHUB_TOKEN not set") } awsAuth, err := aws.EnvAuth() if err != nil { return err } r.s3Bucket = s3.New(awsAuth, aws.USEast).Bucket(logBucket) if r.dockerFS == "" { var err error bc := r.bc bc.Network, err = r.allocateNet() if err != nil { return err } if r.dockerFS, err = cluster.BuildFlynn(bc, "", util.Repos, os.Stdout); err != nil { return fmt.Errorf("could not build flynn: %s", err) } r.releaseNet(bc.Network) defer os.RemoveAll(r.dockerFS) } db, err := bolt.Open(args.DBPath, 0600, &bolt.Options{Timeout: 5 * time.Second}) if err != nil { return fmt.Errorf("could not open db: %s", err) } r.db = db defer r.db.Close() if err := r.db.Update(func(tx *bolt.Tx) error { _, err := tx.CreateBucketIfNotExists([]byte("pending-builds")) return err }); err != nil { return fmt.Errorf("could not create pending-builds bucket: %s", err) } for i := 0; i < maxBuilds; i++ { r.buildCh <- struct{}{} } if err := r.buildPending(); err != nil { log.Printf("could not build pending builds: %s", err) } go r.watchEvents() http.Handle("/", handlers.CombinedLoggingHandler(os.Stdout, http.HandlerFunc(r.httpEventHandler))) log.Println("Listening on :80...") if err := http.ListenAndServe(":80", nil); err != nil { return fmt.Errorf("ListenAndServer: %s", err) } return nil }
func (s *LiveSuite) SetUpSuite(c *C) { if !Amazon { c.Skip("amazon tests not enabled (-amazon flag)") } auth, err := aws.EnvAuth() if err != nil { c.Fatal(err.Error()) } s.auth = auth }
func (s *S) TestEnvAuthNoAccess(c *C) { os.Clearenv() os.Setenv("AWS_SECRET_ACCESS_KEY", "foo") _, err := aws.EnvAuth() c.Assert(err, ErrorMatches, "AWS_ACCESS_KEY_ID not found in environment") }
func (s *S) TestEnvAuthNoSecret(c *C) { os.Clearenv() _, err := aws.EnvAuth() c.Assert(err, ErrorMatches, "AWS_SECRET_ACCESS_KEY not found in environment") }