瀏覽代碼

Modifying the naming specification

归邪 8 年之前
父節點
當前提交
2bf724d91f

+ 1 - 0
ChangeLog.txt

@@ -2,6 +2,7 @@
 1. Set default timeout to 10s
 1. Set default timeout to 10s
 2. Make integration tests more stable
 2. Make integration tests more stable
 3. Fix the problem of LocationResolver in concurrency
 3. Fix the problem of LocationResolver in concurrency
+4. Modifying the naming specification
 
 
 2018-01-16 Version: 0.8.0
 2018-01-16 Version: 0.8.0
 1,  Add TriggerMode param in AddMediaWorkflow.
 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
 package credentials
 
 
-type KeyPairCredential struct {
+type RsaKeyPairCredential struct {
 	PrivateKey        string
 	PrivateKey        string
 	PublicKeyId       string
 	PublicKeyId       string
 	SessionExpiration int
 	SessionExpiration int

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

@@ -1,6 +1,6 @@
 package credentials
 package credentials
 
 
-type StsAssumeRoleCredential struct {
+type StsRoleArnCredential struct {
 	AccessKeyId           string
 	AccessKeyId           string
 	AccessKeySecret       string
 	AccessKeySecret       string
 	RoleArn               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)
 			signer, err = signers.NewSignerSts(instance)
 		}
 		}
-	case *credentials.StsAssumeRoleCredential:
+	case *credentials.StsRoleArnCredential:
 		{
 		{
 			signer, err = signers.NewSignerStsAssumeRole(instance, commonApi)
 			signer, err = signers.NewSignerStsAssumeRole(instance, commonApi)
 		}
 		}
-	case *credentials.KeyPairCredential:
+	case *credentials.RsaKeyPairCredential:
 		{
 		{
 			signer, err = signers.NewSignerKeyPair(instance, commonApi)
 			signer, err = signers.NewSignerKeyPair(instance, commonApi)
 		}
 		}
-	case *credentials.EcsInstanceCredential:
+	case *credentials.StsRoleNameOnEcsCredential:
 		{
 		{
 			signer, err = signers.NewSignereEcsInstance(instance, commonApi)
 			signer, err = signers.NewSignereEcsInstance(instance, commonApi)
 		}
 		}

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

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

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

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

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

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

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

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

+ 9 - 9
sdk/client.go

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

+ 2 - 2
sdk/client_test.go

@@ -118,11 +118,11 @@ func testSetup() {
 	if err != nil {
 	if err != nil {
 		panic(err)
 		panic(err)
 	}
 	}
-	clientEcs, err = NewClientWithRamRoleNameOnEcs("cn-hangzhou", clientConfig, "conan")
+	clientEcs, err = NewClientWithStsRoleNameOnEcs("cn-hangzhou", clientConfig, "conan")
 	if err != nil {
 	if err != nil {
 		panic(err)
 		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 {
 	if err != nil {
 		panic(err)
 		panic(err)
 	}
 	}