@@ -84,16 +84,26 @@ func (hc *HuaweiCloud) Run(enabled common.Enable, ipv4, ipv6 string) (msg []stri
84
84
}
85
85
86
86
func (hc * HuaweiCloud ) getZoneId () (err error ) {
87
- auth := basic .NewCredentialsBuilder ().
87
+ auth , err := basic .NewCredentialsBuilder ().
88
88
WithAk (hc .AccessKeyId ).
89
89
WithSk (hc .SecretAccessKey ).
90
- Build ()
90
+ SafeBuild ()
91
+ if err != nil {
92
+ return
93
+ }
91
94
92
- dnsClient := dns .NewDnsClient (
93
- dns .DnsClientBuilder ().
94
- WithRegion (region .ValueOf ("cn-east-3" )).
95
- WithCredential (auth ).
96
- Build ())
95
+ hr , err := region .SafeValueOf ("cn-east-3" )
96
+ if err != nil {
97
+ return
98
+ }
99
+ hhc , err := dns .DnsClientBuilder ().
100
+ WithRegion (hr ).
101
+ WithCredential (auth ).
102
+ SafeBuild ()
103
+ if err != nil {
104
+ return
105
+ }
106
+ dnsClient := dns .NewDnsClient (hhc )
97
107
98
108
request := & model.ListPublicZonesRequest {}
99
109
response , err := dnsClient .ListPublicZones (request )
@@ -112,16 +122,26 @@ func (hc *HuaweiCloud) getZoneId() (err error) {
112
122
}
113
123
114
124
func (hc * HuaweiCloud ) getParseRecord (domain , recordType string ) (recordSetId , recordIP string , err error ) {
115
- auth := basic .NewCredentialsBuilder ().
125
+ auth , err := basic .NewCredentialsBuilder ().
116
126
WithAk (hc .AccessKeyId ).
117
127
WithSk (hc .SecretAccessKey ).
118
- Build ()
128
+ SafeBuild ()
129
+ if err != nil {
130
+ return
131
+ }
119
132
120
- dnsClient := dns .NewDnsClient (
121
- dns .DnsClientBuilder ().
122
- WithRegion (region .ValueOf ("cn-east-3" )).
123
- WithCredential (auth ).
124
- Build ())
133
+ hr , err := region .SafeValueOf ("cn-east-3" )
134
+ if err != nil {
135
+ return
136
+ }
137
+ hhc , err := dns .DnsClientBuilder ().
138
+ WithRegion (hr ).
139
+ WithCredential (auth ).
140
+ SafeBuild ()
141
+ if err != nil {
142
+ return
143
+ }
144
+ dnsClient := dns .NewDnsClient (hhc )
125
145
126
146
request := & model.ListRecordSetsByZoneRequest {}
127
147
request .ZoneId = hc .ZoneId
@@ -145,25 +165,35 @@ func (hc *HuaweiCloud) getParseRecord(domain, recordType string) (recordSetId, r
145
165
}
146
166
147
167
func (hc * HuaweiCloud ) updateParseRecord (ipAddr , recordSetId , recordType , domain string ) (err error ) {
148
- auth := basic .NewCredentialsBuilder ().
168
+ auth , err := basic .NewCredentialsBuilder ().
149
169
WithAk (hc .AccessKeyId ).
150
170
WithSk (hc .SecretAccessKey ).
151
- Build ()
171
+ SafeBuild ()
172
+ if err != nil {
173
+ return
174
+ }
152
175
153
- dnsClient := dns .NewDnsClient (
154
- dns .DnsClientBuilder ().
155
- WithRegion (region .ValueOf ("cn-east-3" )).
156
- WithCredential (auth ).
157
- Build ())
176
+ hr , err := region .SafeValueOf ("cn-east-3" )
177
+ if err != nil {
178
+ return
179
+ }
180
+ hhc , err := dns .DnsClientBuilder ().
181
+ WithRegion (hr ).
182
+ WithCredential (auth ).
183
+ SafeBuild ()
184
+ if err != nil {
185
+ return
186
+ }
187
+ dnsClient := dns .NewDnsClient (hhc )
158
188
159
189
request := & model.UpdateRecordSetRequest {}
160
190
request .ZoneId = hc .ZoneId
161
191
request .RecordsetId = recordSetId
162
- var listRecordsbody = []string {
192
+ var listRecordsBody = []string {
163
193
ipAddr ,
164
194
}
165
195
request .Body = & model.UpdateRecordSetReq {
166
- Records : & listRecordsbody ,
196
+ Records : & listRecordsBody ,
167
197
Type : recordType ,
168
198
Name : domain ,
169
199
}
0 commit comments