Skip to content

Commit

Permalink
Merge pull request #169 from yunify/fix-review
Browse files Browse the repository at this point in the history
change gopath to terraform-providers , remove unused output var
  • Loading branch information
runzexia authored Nov 6, 2018
2 parents 8942f2e + e628265 commit 11217a6
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 64 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
test:
docker:
# specify the version
- image: circleci/golang:1.9
working_directory: /go/src/github.com/yunify/terraform-provider-qingcloud
- image: circleci/golang:1.11.2
working_directory: /go/src/github.com/terraform-providers/terraform-provider-qingcloud
steps:
- checkout
- run: curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
Expand Down Expand Up @@ -41,8 +41,8 @@ jobs:
codeclimate-test-reporter < cov.out
release:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/yunify/terraform-provider-qingcloud
- image: circleci/golang:1.11.2
working_directory: /go/src/github.com/terraform-providers/terraform-provider-qingcloud
steps:
- checkout
- run: git config --global user.name runzexia
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package main

import (
"github.com/hashicorp/terraform/plugin"
"github.com/yunify/terraform-provider-qingcloud/qingcloud"
"github.com/terraform-providers/terraform-provider-qingcloud/qingcloud"
)

func main() {
Expand Down
9 changes: 3 additions & 6 deletions qingcloud/resource_qingcloud_eip_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ func modifyEipAttributes(d *schema.ResourceData, meta interface{}) error {
input.EIPName, nameUpdate = getNamePointer(d)
input.Description, descriptionUpdate = getDescriptionPointer(d)
if nameUpdate || descriptionUpdate {
var output *qc.ModifyEIPAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifyEIPAttributes(input)
_, err = clt.ModifyEIPAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand All @@ -45,10 +44,9 @@ func changeEIPBandwidth(d *schema.ResourceData, meta interface{}) error {
input := new(qc.ChangeEIPsBandwidthInput)
input.EIPs = []*string{qc.String(d.Id())}
input.Bandwidth = qc.Int(d.Get(resourceEipBandwidth).(int))
var output *qc.ChangeEIPsBandwidthOutput
var err error
simpleRetry(func() error {
output, err = clt.ChangeEIPsBandwidth(input)
_, err = clt.ChangeEIPsBandwidth(input)
return isServerBusy(err)
})
if err != nil {
Expand All @@ -66,10 +64,9 @@ func changeEIPBillMode(d *schema.ResourceData, meta interface{}) error {
input := new(qc.ChangeEIPsBillingModeInput)
input.EIPs = []*string{qc.String(d.Id())}
input.BillingMode = qc.String(d.Get(resourceEipBillMode).(string))
var output *qc.ChangeEIPsBillingModeOutput
var err error
simpleRetry(func() error {
output, err = clt.ChangeEIPsBillingMode(input)
_, err = clt.ChangeEIPsBillingMode(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,9 @@ func resourceQingcloudInstanceDelete(d *schema.ResourceData, meta interface{}) e
clt := meta.(*QingCloudClient).instance
input := new(qc.TerminateInstancesInput)
input.Instances = []*string{qc.String(d.Id())}
var output *qc.TerminateInstancesOutput
var err error
simpleRetry(func() error {
output, err = clt.TerminateInstances(input)
_, err = clt.TerminateInstances(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_keypair_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ func modifyKeypairAttributes(d *schema.ResourceData, meta interface{}) error {
input.KeyPairName, nameUpdate = getNamePointer(d)
input.Description, descriptionUpdate = getDescriptionPointer(d)
if nameUpdate || descriptionUpdate {
var output *qc.ModifyKeyPairAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifyKeyPairAttributes(input)
_, err = clt.ModifyKeyPairAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,9 @@ func resourceQingcloudLoadBalancerDelete(d *schema.ResourceData, meta interface{
}
input := new(qc.DeleteLoadBalancersInput)
input.LoadBalancers = []*string{qc.String(d.Id())}
var output *qc.DeleteLoadBalancersOutput
var err error
simpleRetry(func() error {
output, err = clt.DeleteLoadBalancers(input)
_, err = clt.DeleteLoadBalancers(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions qingcloud/resource_qingcloud_loadbalancer_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func resourceQingcloudLoadBalancerBackendCreate(d *schema.ResourceData, meta int
}
func resourceQingcloudLoadBalancerBackendDelete(d *schema.ResourceData, meta interface{}) error {
clt := meta.(*QingCloudClient).loadbalancer
var output *qc.DeleteLoadBalancerBackendsOutput
var err error
lbId, err := getLBIdFromLBB(qc.String(d.Id()), meta)
if err != nil {
Expand All @@ -102,7 +101,7 @@ func resourceQingcloudLoadBalancerBackendDelete(d *schema.ResourceData, meta int
input := new(qc.DeleteLoadBalancerBackendsInput)
input.LoadBalancerBackends = []*string{qc.String(d.Id())}
simpleRetry(func() error {
output, err = clt.DeleteLoadBalancerBackends(input)
_, err = clt.DeleteLoadBalancerBackends(input)
return isServerBusy(err)
})
if err != nil {
Expand Down Expand Up @@ -149,10 +148,9 @@ func resourceQingcloudLoadBalancerBackendUpdate(d *schema.ResourceData, meta int
input.Port = qc.Int(d.Get(resourceLoadBalancerBackendPort).(int))
input.LoadBalancerBackendName = getUpdateStringPointer(d, resourceName)

var output *qc.ModifyLoadBalancerBackendAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifyLoadBalancerBackendAttributes(input)
_, err = clt.ModifyLoadBalancerBackendAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions qingcloud/resource_qingcloud_loadbalancer_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,9 @@ func resourceQingcloudLoadBalancerListenerUpdate(d *schema.ResourceData, meta in
input.HealthyCheckOption = getSetStringPointer(d, resourceLoadBalancerListenerHealthCheckOption)
input.ListenerOption = qc.Int(d.Get(resourceLoadBalancerListenerOption).(int))
input.Timeout = qc.Int(d.Get(resourceLoadBalancerListenerTimeOut).(int))
var output *qc.ModifyLoadBalancerListenerAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifyLoadBalancerListenerAttributes(input)
_, err = clt.ModifyLoadBalancerListenerAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand All @@ -217,10 +216,9 @@ func resourceQingcloudLoadBalancerListnerDestroy(d *schema.ResourceData, meta in
clt := meta.(*QingCloudClient).loadbalancer
input := new(qc.DeleteLoadBalancerListenersInput)
input.LoadBalancerListeners = []*string{qc.String(d.Id())}
var output *qc.DeleteLoadBalancerListenersOutput
var err error
simpleRetry(func() error {
output, err = clt.DeleteLoadBalancerListeners(input)
_, err = clt.DeleteLoadBalancerListeners(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ func resourceQingcloudSecurityGroupDelete(d *schema.ResourceData, meta interface
input := new(qc.DeleteSecurityGroupsInput)
input.SecurityGroups = []*string{qc.String(d.Id())}
var err error
var output *qc.DeleteSecurityGroupsOutput
simpleRetry(func() error {
output, err = clt.DeleteSecurityGroups(input)
_, err = clt.DeleteSecurityGroups(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_security_group_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ func modifySecurityGroupAttributes(d *schema.ResourceData, meta interface{}) err
input.SecurityGroupName, nameUpdate = getNamePointer(d)
input.Description, descriptionUpdate = getDescriptionPointer(d)
if nameUpdate || descriptionUpdate {
var output *qc.ModifySecurityGroupAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifySecurityGroupAttributes(input)
_, err = clt.ModifySecurityGroupAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_security_group_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,9 @@ func resourceQingcloudSecurityGroupRuleDelete(d *schema.ResourceData, meta inter
clt := meta.(*QingCloudClient).securitygroup
input := new(qc.DeleteSecurityGroupRulesInput)
input.SecurityGroupRules = []*string{qc.String(d.Id())}
var output *qc.DeleteSecurityGroupRulesOutput
var err error
simpleRetry(func() error {
output, err = clt.DeleteSecurityGroupRules(input)
_, err = clt.DeleteSecurityGroupRules(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_security_group_rule_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ func ModifySecurityGroupRuleAttributes(d *schema.ResourceData, meta interface{})
input.Val1 = getUpdateStringPointer(d, resourceSecurityGroupRuleFromPort)
input.Val2 = getUpdateStringPointer(d, resourceSecurityGroupRuleToPort)
input.Val3 = getUpdateStringPointer(d, resourceSecurityGroupCidrBlock)
var output *qc.ModifySecurityGroupRuleAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifySecurityGroupRuleAttributes(input)
_, err = clt.ModifySecurityGroupRuleAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_server_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ func resourceQingcloudServerCertificateDelete(d *schema.ResourceData, meta inter
clt := meta.(*QingCloudClient).loadbalancer
input := new(qc.DeleteServerCertificatesInput)
input.ServerCertificates = []*string{qc.String(d.Id())}
var output *qc.DeleteServerCertificatesOutput
var err error
simpleRetry(func() error {
output, err = clt.DeleteServerCertificates(input)
_, err = clt.DeleteServerCertificates(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_server_certificate_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ func modifyServerCertificateAttributes(d *schema.ResourceData, meta interface{})
input.ServerCertificateName, nameUpdate = getNamePointer(d)
input.Description, descriptionUpdate = getDescriptionPointer(d)
if nameUpdate || descriptionUpdate {
var output *qc.ModifyServerCertificateAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifyServerCertificateAttributes(input)
_, err = clt.ModifyServerCertificateAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ func resourceQingcloudTagDelete(d *schema.ResourceData, meta interface{}) error
clt := meta.(*QingCloudClient).tag
input := new(qc.DeleteTagsInput)
input.Tags = []*string{qc.String(d.Id())}
var output *qc.DeleteTagsOutput
var err error
simpleRetry(func() error {
output, err = clt.DeleteTags(input)
_, err = clt.DeleteTags(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
9 changes: 3 additions & 6 deletions qingcloud/resource_qingcloud_tag_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ func modifyTagAttributes(d *schema.ResourceData, meta interface{}) error {
attributeUpdate = true
}
if attributeUpdate || descriptionUpdate {
var output *qc.ModifyTagAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifyTagAttributes(input)
_, err = clt.ModifyTagAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand Down Expand Up @@ -81,10 +80,9 @@ func resourceUpdateTag(d *schema.ResourceData, meta interface{}, resourceType st
}
input.ResourceTagPairs = append(input.ResourceTagPairs, &rtp)
}
var output *qc.DetachTagsOutput
var err error
simpleRetry(func() error {
output, err = clt.DetachTags(input)
_, err = clt.DetachTags(input)
return isServerBusy(err)
})
if err != nil {
Expand All @@ -101,10 +99,9 @@ func resourceUpdateTag(d *schema.ResourceData, meta interface{}, resourceType st
}
input.ResourceTagPairs = append(input.ResourceTagPairs, &rtp)
}
var output *qc.AttachTagsOutput
var err error
simpleRetry(func() error {
output, err = clt.AttachTags(input)
_, err = clt.AttachTags(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,9 @@ func resourceQingcloudVpcDelete(d *schema.ResourceData, meta interface{}) error
}
input := new(qc.DeleteRoutersInput)
input.Routers = []*string{qc.String(d.Id())}
var output *qc.DeleteRoutersOutput
var err error
simpleRetry(func() error {
output, err = clt.DeleteRouters(input)
_, err = clt.DeleteRouters(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions qingcloud/resource_qingcloud_vpc_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ func modifyRouterAttributes(d *schema.ResourceData, meta interface{}) error {
}

if attributeUpdate || descriptionUpdate {
var output *qc.ModifyRouterAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifyRouterAttributes(input)
_, err = clt.ModifyRouterAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand All @@ -54,10 +53,8 @@ func applyRouterUpdate(routerId *string, meta interface{}) error {
clt := meta.(*QingCloudClient).router
input := new(qc.UpdateRoutersInput)
input.Routers = []*string{routerId}
var output *qc.UpdateRoutersOutput
var err error
simpleRetry(func() error {
output, err = clt.UpdateRouters(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions qingcloud/resource_qingcloud_vpc_static.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ func resourceQingcloudVpcStaticUpdate(d *schema.ResourceData, meta interface{})
input.Val3 = getUpdateStringPointer(d, resourceVpcVal3)
input.Val4 = getUpdateStringPointer(d, resourceVpcVal4)
input.Val5 = getUpdateStringPointer(d, resourceVpcVal5)
var output *qc.ModifyRouterStaticAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifyRouterStaticAttributes(input)
_, err = clt.ModifyRouterStaticAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand All @@ -165,10 +164,9 @@ func resourceQingcloudVpcStaticDelete(d *schema.ResourceData, meta interface{})
clt := meta.(*QingCloudClient).router
input := new(qc.DeleteRouterStaticsInput)
input.RouterStatics = []*string{qc.String(d.Id())}
var output *qc.DeleteRouterStaticsOutput
var err error
simpleRetry(func() error {
output, err = clt.DeleteRouterStatics(input)
_, err = clt.DeleteRouterStatics(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions qingcloud/resource_qingcloud_vxnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@ func resourceQingcloudVxnetDelete(d *schema.ResourceData, meta interface{}) erro
}
input := new(qc.DeleteVxNetsInput)
input.VxNets = []*string{qc.String(d.Id())}
var output *qc.DeleteVxNetsOutput
var err error
simpleRetry(func() error {
output, err = clt.DeleteVxNets(input)
_, err = clt.DeleteVxNets(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
9 changes: 3 additions & 6 deletions qingcloud/resource_qingcloud_vxnet_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ func modifyVxnetAttributes(d *schema.ResourceData, meta interface{}) error {
input.VxNetName, nameUpdate = getNamePointer(d)
input.Description, descriptionUpdate = getDescriptionPointer(d)
if nameUpdate || descriptionUpdate {
var output *qc.ModifyVxNetAttributesOutput
var err error
simpleRetry(func() error {
output, err = clt.ModifyVxNetAttributes(input)
_, err = clt.ModifyVxNetAttributes(input)
return isServerBusy(err)
})
if err != nil {
Expand All @@ -51,10 +50,9 @@ func vxnetJoinRouter(d *schema.ResourceData, meta interface{}) error {
input.VxNet = qc.String(d.Id())
input.Router = qc.String(d.Get(resourceVxnetVpcID).(string))
input.IPNetwork = qc.String(d.Get(resourceVxnetVpcIPNetwork).(string))
var output *qc.JoinRouterOutput
var err error
simpleRetry(func() error {
output, err = clt.JoinRouter(input)
_, err = clt.JoinRouter(input)
return isServerBusy(err)
})
if err != nil {
Expand All @@ -75,10 +73,9 @@ func vxnetLeaverRouter(d *schema.ResourceData, meta interface{}) error {
input := new(qc.LeaveRouterInput)
input.VxNets = []*string{qc.String(d.Id())}
input.Router = qc.String(oldVPC.(string))
var output *qc.LeaveRouterOutput
var err error
simpleRetry(func() error {
output, err = clt.LeaveRouter(input)
_, err = clt.LeaveRouter(input)
return isServerBusy(err)
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion qingcloud/transition_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func LoadBalancerTransitionStateRefresh(clt *qc.LoadBalancerService, id *string)
return nil, "", err
}
if len(output.LoadBalancerSet) == 0 {
return nil, "", fmt.Errorf("error lb set is empty, request id %s", id)
return nil, "", fmt.Errorf("error lb set is empty, request id %s", *id)
}
return output.LoadBalancerSet[0], qc.StringValue(output.LoadBalancerSet[0].TransitionStatus), nil
}
Expand Down

0 comments on commit 11217a6

Please sign in to comment.