Browse Source

Modifying the naming specification

归邪 7 years ago
parent
commit
2bf724d91f

+ 1 - 0
ChangeLog.txt

@@ -2,6 +2,7 @@
 1. Set default timeout to 10s
 2. Make integration tests more stable
 3. Fix the problem of LocationResolver in concurrency
+4. Modifying the naming specification
 
 2018-01-16 Version: 0.8.0
 1,  Add TriggerMode param in AddMediaWorkflow.

+ 0 - 5
sdk/auth/credentials/EcsInstanceCredential.go

@@ -1,5 +0,0 @@
-package credentials
-
-type EcsInstanceCredential struct {
-	RoleName string
-}

+ 1 - 1
sdk/auth/credentials/KeyPairCredential.go → sdk/auth/credentials/RsaKeyPairCredential.go

@@ -1,6 +1,6 @@
 package credentials
 
-type KeyPairCredential struct {
+type RsaKeyPairCredential struct {
 	PrivateKey        string
 	PublicKeyId       string
 	SessionExpiration int

+ 1 - 1
sdk/auth/credentials/StsAssumeRoleCredential.go → sdk/auth/credentials/StsRoleArnCredential.go

@@ -1,6 +1,6 @@
 package credentials
 
-type StsAssumeRoleCredential struct {
+type StsRoleArnCredential struct {
 	AccessKeyId           string
 	AccessKeySecret       string
 	RoleArn               string

+ 5 - 0
sdk/auth/credentials/StsRoleNameOnEcsCredential.go

@@ -0,0 +1,5 @@
+package credentials
+
+type StsRoleNameOnEcsCredential struct {
+	RoleName string
+}

+ 3 - 3
sdk/auth/signer.go

@@ -44,15 +44,15 @@ func NewSignerWithCredential(credential Credential, commonApi func(request *requ
 		{
 			signer, err = signers.NewSignerSts(instance)
 		}
-	case *credentials.StsAssumeRoleCredential:
+	case *credentials.StsRoleArnCredential:
 		{
 			signer, err = signers.NewSignerStsAssumeRole(instance, commonApi)
 		}
-	case *credentials.KeyPairCredential:
+	case *credentials.RsaKeyPairCredential:
 		{
 			signer, err = signers.NewSignerKeyPair(instance, commonApi)
 		}
-	case *credentials.EcsInstanceCredential:
+	case *credentials.StsRoleNameOnEcsCredential:
 		{
 			signer, err = signers.NewSignereEcsInstance(instance, commonApi)
 		}

+ 2 - 2
sdk/auth/signers/signer_ecs_instance.go

@@ -29,11 +29,11 @@ import (
 type SignerEcsInstance struct {
 	*credentialUpdater
 	sessionCredential *sessionCredential
-	credential        *credentials.EcsInstanceCredential
+	credential        *credentials.StsRoleNameOnEcsCredential
 	commonApi         func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error)
 }
 
-func NewSignereEcsInstance(credential *credentials.EcsInstanceCredential, commonApi func(*requests.CommonRequest, interface{}) (response *responses.CommonResponse, err error)) (signer *SignerEcsInstance, err error) {
+func NewSignereEcsInstance(credential *credentials.StsRoleNameOnEcsCredential, commonApi func(*requests.CommonRequest, interface{}) (response *responses.CommonResponse, err error)) (signer *SignerEcsInstance, err error) {
 	signer = &SignerEcsInstance{
 		credential: credential,
 		commonApi:  commonApi,

+ 2 - 2
sdk/auth/signers/signer_key_pair.go

@@ -29,7 +29,7 @@ import (
 type SignerKeyPair struct {
 	*credentialUpdater
 	sessionCredential *SessionAkCredential
-	credential        *credentials.KeyPairCredential
+	credential        *credentials.RsaKeyPairCredential
 	commonApi         func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error)
 }
 
@@ -38,7 +38,7 @@ type SessionAkCredential struct {
 	accessKeySecret string
 }
 
-func NewSignerKeyPair(credential *credentials.KeyPairCredential, commonApi func(*requests.CommonRequest, interface{}) (response *responses.CommonResponse, err error)) (signer *SignerKeyPair, err error) {
+func NewSignerKeyPair(credential *credentials.RsaKeyPairCredential, commonApi func(*requests.CommonRequest, interface{}) (response *responses.CommonResponse, err error)) (signer *SignerKeyPair, err error) {
 	signer = &SignerKeyPair{
 		credential: credential,
 		commonApi:  commonApi,

+ 2 - 2
sdk/auth/signers/signer_sts_assume_role.go

@@ -35,7 +35,7 @@ type SignerStsAssumeRole struct {
 	*credentialUpdater
 	roleSessionName   string
 	sessionCredential *sessionCredential
-	credential        *credentials.StsAssumeRoleCredential
+	credential        *credentials.StsRoleArnCredential
 	commonApi         func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error)
 }
 
@@ -45,7 +45,7 @@ type sessionCredential struct {
 	securityToken   string
 }
 
-func NewSignerStsAssumeRole(credential *credentials.StsAssumeRoleCredential, commonApi func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error)) (signer *SignerStsAssumeRole, err error) {
+func NewSignerStsAssumeRole(credential *credentials.StsRoleArnCredential, commonApi func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error)) (signer *SignerStsAssumeRole, err error) {
 	signer = &SignerStsAssumeRole{
 		credential: credential,
 		commonApi:  commonApi,

+ 2 - 2
sdk/auth/signers/signer_v2.go

@@ -19,14 +19,14 @@ import (
 )
 
 type SignerV2 struct {
-	credential *credentials.KeyPairCredential
+	credential *credentials.RsaKeyPairCredential
 }
 
 func (signer *SignerV2) GetExtraParam() map[string]string {
 	return nil
 }
 
-func NewSignerV2(credential *credentials.KeyPairCredential) (*SignerV2, error) {
+func NewSignerV2(credential *credentials.RsaKeyPairCredential) (*SignerV2, error) {
 	return &SignerV2{
 		credential: credential,
 	}, nil

+ 9 - 9
sdk/client.go

@@ -92,9 +92,9 @@ func (client *Client) InitWithAccessKey(regionId, accessKeyId, accessKeySecret s
 	return client.InitWithOptions(regionId, config, credential)
 }
 
-func (client *Client) InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (err error) {
+func (client *Client) InitWithStsRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (err error) {
 	config := client.InitClientConfig()
-	credential := &credentials.StsAssumeRoleCredential{
+	credential := &credentials.StsRoleArnCredential{
 		AccessKeyId:     accessKeyId,
 		AccessKeySecret: accessKeySecret,
 		RoleArn:         roleArn,
@@ -105,7 +105,7 @@ func (client *Client) InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret,
 
 func (client *Client) InitWithRsaKeyPair(regionId, publicKeyId, privateKey string, sessionExpiration int) (err error) {
 	config := client.InitClientConfig()
-	credential := &credentials.KeyPairCredential{
+	credential := &credentials.RsaKeyPairCredential{
 		PrivateKey:        privateKey,
 		PublicKeyId:       publicKeyId,
 		SessionExpiration: sessionExpiration,
@@ -113,9 +113,9 @@ func (client *Client) InitWithRsaKeyPair(regionId, publicKeyId, privateKey strin
 	return client.InitWithOptions(regionId, config, credential)
 }
 
-func (client *Client) InitWithRamRoleNameOnEcs(regionId, roleName string) (err error) {
+func (client *Client) InitWithStsRoleNameOnEcs(regionId, roleName string) (err error) {
 	config := client.InitClientConfig()
-	credential := &credentials.EcsInstanceCredential{
+	credential := &credentials.StsRoleNameOnEcsCredential{
 		RoleName: roleName,
 	}
 	return client.InitWithOptions(regionId, config, credential)
@@ -258,17 +258,17 @@ func NewClientWithRsaKeyPair(regionId string, config *Config, publicKeyId, priva
 	return
 }
 
-func NewClientWithRamRoleNameOnEcs(regionId string, config *Config, roleName string) (client *Client, err error) {
+func NewClientWithStsRoleNameOnEcs(regionId string, config *Config, roleName string) (client *Client, err error) {
 	client = &Client{}
 	client.config = config
-	err = client.InitWithRamRoleNameOnEcs(regionId, roleName)
+	err = client.InitWithStsRoleNameOnEcs(regionId, roleName)
 	return
 }
 
-func NewClientWithRamRoleArn(regionId string, config *Config, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
+func NewClientWithStsRoleArn(regionId string, config *Config, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
 	client = &Client{}
 	client.config = config
-	err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
+	err = client.InitWithStsRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
 	return
 }
 

+ 2 - 2
sdk/client_test.go

@@ -118,11 +118,11 @@ func testSetup() {
 	if err != nil {
 		panic(err)
 	}
-	clientEcs, err = NewClientWithRamRoleNameOnEcs("cn-hangzhou", clientConfig, "conan")
+	clientEcs, err = NewClientWithStsRoleNameOnEcs("cn-hangzhou", clientConfig, "conan")
 	if err != nil {
 		panic(err)
 	}
-	clientRoleArn, err = NewClientWithRamRoleArn("cn-hangzhou", clientConfig, testConfig.ChildAK, testConfig.ChildSecret, testConfig.RoleArn, "clientTest")
+	clientRoleArn, err = NewClientWithStsRoleArn("cn-hangzhou", clientConfig, testConfig.ChildAK, testConfig.ChildSecret, testConfig.RoleArn, "clientTest")
 	if err != nil {
 		panic(err)
 	}