This commit is contained in:
@@ -3,9 +3,25 @@ package alidns
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/alibabacloud-go/alidns-20150109/v5/client"
|
||||||
"github.com/ssdomei232/goodBaby/model"
|
"github.com/ssdomei232/goodBaby/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func deleteAliDNSRecord(ctx context.Context, rule *model.Rule) {
|
func deleteAliDNSRecord(ctx context.Context, rule *model.Rule) error {
|
||||||
aliDNSClient, err := GetAliDNSClient(rule)
|
aliDNSClient, err := getAliDNSClient(rule)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
deleteRecordConfig, err := getDeleteRecordConfig(rule)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = aliDNSClient.DeleteDomainRecord(&client.DeleteDomainRecordRequest{
|
||||||
|
RecordId: &deleteRecordConfig.RecordID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,3 +4,7 @@ type AliDNSAccount struct {
|
|||||||
AK string `json:"ak"`
|
AK string `json:"ak"`
|
||||||
SK string `json:"sk"`
|
SK string `json:"sk"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeleteRecordConfig struct {
|
||||||
|
RecordID string `json:"record_id"`
|
||||||
|
}
|
||||||
|
|||||||
+14
-2
@@ -1,15 +1,17 @@
|
|||||||
package alidns
|
package alidns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
alidns "github.com/alibabacloud-go/alidns-20150109/v5/client"
|
alidns "github.com/alibabacloud-go/alidns-20150109/v5/client"
|
||||||
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
|
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||||
"github.com/alibabacloud-go/tea/tea"
|
"github.com/alibabacloud-go/tea/tea"
|
||||||
"github.com/aliyun/credentials-go/credentials"
|
"github.com/aliyun/credentials-go/credentials"
|
||||||
"github.com/ssdomei232/goodBaby/handler/db"
|
"github.com/ssdomei232/goodBaby/handler/db"
|
||||||
"github.com/ssdomei232/goodBaby/model"
|
"github.com/ssdomei232/goodBaby/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetAliDNSClient(rule *model.Rule) (client *alidns.Client, err error) {
|
func getAliDNSClient(rule *model.Rule) (client *alidns.Client, err error) {
|
||||||
var accountConfig AliDNSAccount
|
var accountConfig AliDNSAccount
|
||||||
|
|
||||||
// get config
|
// get config
|
||||||
@@ -35,3 +37,13 @@ func GetAliDNSClient(rule *model.Rule) (client *alidns.Client, err error) {
|
|||||||
|
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDeleteRecordConfig(rule *model.Rule) (*DeleteRecordConfig, error) {
|
||||||
|
var deleteRecordConfig DeleteRecordConfig
|
||||||
|
|
||||||
|
if err := json.Unmarshal([]byte(rule.ConfigJson), &deleteRecordConfig); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &deleteRecordConfig, nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user