當前位置: 首頁>>代碼示例>>Golang>>正文


Golang iam.New函數代碼示例

本文整理匯總了Golang中launchpad/net/goamz/iam.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了New函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SetUpSuite

func (s *AmazonClientSuite) SetUpSuite(c *C) {
	if !testutil.Amazon {
		c.Skip("AmazonClientSuite tests not enabled")
	}
	s.srv.SetUp(c)
	s.iam = iam.New(s.srv.auth, aws.USEast)
}
開發者ID:BillTheBest,項目名稱:libswarm,代碼行數:7,代碼來源:iami_test.go

示例2: getIAMEndpoint

// getIAMEndpoint returns an iam.IAM instance configured to access the endpoint
// defined in aws:iam:endpoint. If this setting is undefined, it will use the
// default endpoint (https://iam.amazonaws.com).
func getIAMEndpoint() *iam.IAM {
	endpoint, err := config.GetString("aws:iam:endpoint")
	if err != nil {
		endpoint = "https://iam.amazonaws.com/"
	}
	region := aws.Region{IAMEndpoint: endpoint}
	return iam.New(getAWSAuth(), region)
}
開發者ID:rpeterson,項目名稱:tsuru,代碼行數:11,代碼來源:aws.go

示例3: TestCreateIAMUser

func (s *S) TestCreateIAMUser(c *gocheck.C) {
	user, err := createIAMUser("rules")
	c.Assert(err, gocheck.IsNil)
	c.Assert(user.Name, gocheck.Equals, "rules")
	c.Assert(user.Path, gocheck.Equals, "/rules/")
	auth := aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"}
	region := aws.Region{IAMEndpoint: s.t.IamServer.URL()}
	iamClient := iam.New(auth, region)
	_, err = iamClient.GetUser(user.Name)
	defer iamClient.DeleteUser(user.Name)
	c.Assert(err, gocheck.IsNil)
}
開發者ID:nihao,項目名稱:tsuru,代碼行數:12,代碼來源:aws_test.go

示例4: TestCreateIAMUserBackward

func (s *S) TestCreateIAMUserBackward(c *gocheck.C) {
	auth := aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"}
	region := aws.Region{IAMEndpoint: s.t.IamServer.URL()}
	iamClient := iam.New(auth, region)
	app := App{Name: "escape"}
	user, err := createIAMUser(app.Name)
	c.Assert(err, gocheck.IsNil)
	defer iamClient.DeleteUser(user.Name)
	ctx := action.BWContext{Params: []interface{}{&app}, FWResult: user}
	createIAMUserAction.Backward(ctx)
	_, err = iamClient.GetUser(user.Name)
	c.Assert(err, gocheck.NotNil)
}
開發者ID:rpeterson,項目名稱:tsuru,代碼行數:13,代碼來源:actions_test.go

示例5: TestCreateIAMUserForward

func (s *S) TestCreateIAMUserForward(c *gocheck.C) {
	auth := aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"}
	region := aws.Region{IAMEndpoint: s.t.IamServer.URL()}
	iamClient := iam.New(auth, region)
	app := App{Name: "trapped"}
	ctx := action.FWContext{Params: []interface{}{&app}, Previous: &app}
	result, err := createIAMUserAction.Forward(ctx)
	c.Assert(err, gocheck.IsNil)
	defer iamClient.DeleteUser(app.Name)
	u, ok := result.(*iam.User)
	c.Assert(ok, gocheck.Equals, true)
	c.Assert(u.Name, gocheck.Equals, app.Name)
}
開發者ID:rpeterson,項目名稱:tsuru,代碼行數:13,代碼來源:actions_test.go

示例6: TestCreateIAMAccessKey

func (s *S) TestCreateIAMAccessKey(c *gocheck.C) {
	auth := aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"}
	region := aws.Region{IAMEndpoint: s.t.IamServer.URL()}
	iamClient := iam.New(auth, region)
	user, err := createIAMUser("hit")
	c.Assert(err, gocheck.IsNil)
	defer iamClient.DeleteUser(user.Name)
	key, err := createIAMAccessKey(user)
	c.Assert(err, gocheck.IsNil)
	c.Assert(key.Id, gocheck.Not(gocheck.Equals), "")
	c.Assert(key.Secret, gocheck.Equals, "")
	c.Assert(key.UserName, gocheck.Equals, user.Name)
}
開發者ID:nihao,項目名稱:tsuru,代碼行數:13,代碼來源:aws_test.go

示例7: TestCreateIAMAccessKeyBackward

func (s *S) TestCreateIAMAccessKeyBackward(c *gocheck.C) {
	auth := aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"}
	region := aws.Region{IAMEndpoint: s.t.IamServer.URL()}
	iamClient := iam.New(auth, region)
	resp, err := iamClient.CreateUser("myuser", "/")
	c.Assert(err, gocheck.IsNil)
	defer iamClient.DeleteUser(resp.User.Name)
	kresp, err := iamClient.CreateAccessKey(resp.User.Name)
	c.Assert(err, gocheck.IsNil)
	defer iamClient.DeleteAccessKey(kresp.AccessKey.Id, resp.User.Name)
	ctx := action.BWContext{Params: []interface{}{nil}, FWResult: &kresp.AccessKey}
	createIAMAccessKeyAction.Backward(ctx)
	akResp, err := iamClient.AccessKeys(resp.User.Name)
	c.Assert(err, gocheck.IsNil)
	c.Assert(akResp.AccessKeys, gocheck.HasLen, 0)
}
開發者ID:rpeterson,項目名稱:tsuru,代碼行數:16,代碼來源:actions_test.go

示例8: TestCreateIAMAccessKeyForward

func (s *S) TestCreateIAMAccessKeyForward(c *gocheck.C) {
	auth := aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"}
	region := aws.Region{IAMEndpoint: s.t.IamServer.URL()}
	iamClient := iam.New(auth, region)
	resp, err := iamClient.CreateUser("puppets", "/")
	c.Assert(err, gocheck.IsNil)
	defer iamClient.DeleteUser(resp.User.Name)
	ctx := action.FWContext{Params: []interface{}{nil}, Previous: &resp.User}
	result, err := createIAMAccessKeyAction.Forward(ctx)
	c.Assert(err, gocheck.IsNil)
	ak, ok := result.(*iam.AccessKey)
	c.Assert(ok, gocheck.Equals, true)
	c.Assert(ak.UserName, gocheck.Equals, resp.User.Name)
	c.Assert(ak.Id, gocheck.Not(gocheck.Equals), "")
	c.Assert(ak.Secret, gocheck.Equals, "")
	defer iamClient.DeleteAccessKey(ak.Id, ak.UserName)
}
開發者ID:rpeterson,項目名稱:tsuru,代碼行數:17,代碼來源:actions_test.go

示例9: TestCreateIAMUserPolicy

func (s *S) TestCreateIAMUserPolicy(c *gocheck.C) {
	auth := aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"}
	region := aws.Region{IAMEndpoint: s.t.IamServer.URL()}
	iamClient := iam.New(auth, region)
	user, err := createIAMUser("fight")
	c.Assert(err, gocheck.IsNil)
	defer iamClient.DeleteUser(user.Name)
	userPolicy, err := createIAMUserPolicy(user, "fight", "mybucket")
	c.Assert(err, gocheck.IsNil)
	c.Assert(userPolicy.UserName, gocheck.Equals, user.Name)
	c.Assert(userPolicy.Name, gocheck.Equals, "app-fight-bucket")
	resp, err := iamClient.GetUserPolicy(user.Name, userPolicy.Name)
	c.Assert(err, gocheck.IsNil)
	var buf bytes.Buffer
	policy.Execute(&buf, "mybucket")
	c.Assert(resp.Policy.Document, gocheck.Equals, buf.String())
}
開發者ID:nihao,項目名稱:tsuru,代碼行數:17,代碼來源:aws_test.go

示例10: TestCreateUserPolicyBackward

func (s *S) TestCreateUserPolicyBackward(c *gocheck.C) {
	auth := aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"}
	region := aws.Region{IAMEndpoint: s.t.IamServer.URL()}
	iamClient := iam.New(auth, region)
	resp, err := iamClient.CreateUser("blackened", "/")
	c.Assert(err, gocheck.IsNil)
	defer iamClient.DeleteUser(resp.User.Name)
	app := App{Name: resp.User.Name}
	env := s3Env{
		Auth:               aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"},
		bucket:             app.Name,
		endpoint:           s.t.S3Server.URL(),
		locationConstraint: true,
	}
	_, err = iamClient.PutUserPolicy(resp.User.Name, "app-blackened-bucket", "null")
	c.Assert(err, gocheck.IsNil)
	ctx := action.BWContext{Params: []interface{}{&app}, FWResult: &env}
	createUserPolicyAction.Backward(ctx)
	_, err = iamClient.GetUserPolicy(resp.User.Name, "app-blackened-bucket")
	c.Assert(err, gocheck.NotNil)
}
開發者ID:rpeterson,項目名稱:tsuru,代碼行數:21,代碼來源:actions_test.go

示例11: TestCreateUserPolicyForward

func (s *S) TestCreateUserPolicyForward(c *gocheck.C) {
	auth := aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"}
	region := aws.Region{IAMEndpoint: s.t.IamServer.URL()}
	iamClient := iam.New(auth, region)
	resp, err := iamClient.CreateUser("blackened", "/")
	c.Assert(err, gocheck.IsNil)
	defer iamClient.DeleteUser(resp.User.Name)
	app := App{Name: resp.User.Name}
	env := s3Env{
		Auth:               aws.Auth{AccessKey: "access", SecretKey: "s3cr3t"},
		bucket:             app.Name,
		endpoint:           s.t.S3Server.URL(),
		locationConstraint: true,
	}
	ctx := action.FWContext{Params: []interface{}{&app}, Previous: &env}
	result, err := createUserPolicyAction.Forward(ctx)
	c.Assert(err, gocheck.IsNil)
	e, ok := result.(*s3Env)
	c.Assert(ok, gocheck.Equals, true)
	c.Assert(e, gocheck.Equals, &env)
	_, err = iamClient.GetUserPolicy(resp.User.Name, "app-blackened-bucket")
	c.Assert(err, gocheck.IsNil)
}
開發者ID:rpeterson,項目名稱:tsuru,代碼行數:23,代碼來源:actions_test.go

示例12: SetUpSuite

func (s *S) SetUpSuite(c *C) {
	s.HTTPSuite.SetUpSuite(c)
	auth := aws.Auth{"abc", "123"}
	s.iam = iam.New(auth, aws.Region{IAMEndpoint: testServer.URL})
}
開發者ID:felixge,項目名稱:goamz,代碼行數:5,代碼來源:iam_test.go

示例13: SetUpSuite

func (s *LocalServerSuite) SetUpSuite(c *C) {
	s.srv.SetUp(c)
	s.ClientTests.iam = iam.New(s.srv.auth, s.srv.region)
}
開發者ID:nathanleclaire,項目名稱:libswarm,代碼行數:4,代碼來源:iamt_test.go


注:本文中的launchpad/net/goamz/iam.New函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。