Open OddCN opened 6 years ago
For example, the current way to create a new node of Ali-cloud is:
alicloud, _ := gocloud.CloudProvider(gocloud.Aliprovider) create := map[string]interface{}{ "RegionId": "cn-qingdao", "ImageId": "centos_7_04_64_20G_alibase_201701015.vhd", "InstanceType": "ecs.xn4.small", "SecurityGroupId": "sg-m5egbo9s5xb21kpu6nk2", } resp, err := alicloud.Createnode(create)
In the current way, we cannot prevent user from entering wrong parameter name and missing required parameters.
If we use Builder pattern like this:
alicloud, _ := gocloud.CloudProvider(gocloud.Aliprovider) createNodeBuilder := ecs.NewCreateNodeBuilder(). RegionID("cn-qingdao"). ImageID("centos_7_04_64_20G_alibase_201701015.vhd"). InstanceType("ecs.xn4.small"). SecurityGroupID("sg-m5egbo9s5xb21kpu6nk2") createNode, err := createNodeBuilder.Build() if err != nil { // May miss required parameters } resp, err := alicloud.Createnode(createNode)
We can
I second this suggestion.
this is good suggestion one we cover all cloud providers we can do this in gocloud 2.0
+1
@PratikDhanave That's great!
For example, the current way to create a new node of Ali-cloud is:
The Problem
In the current way, we cannot prevent user from entering wrong parameter name and missing required parameters.
Suggestion
If we use Builder pattern like this:
We can