Skip to content

Commit 319551a

Browse files
committed
ST1005: error strings should not be capitalized (stylecheck)
1 parent 58e8e99 commit 319551a

19 files changed

+180
-181
lines changed

libvirt/cloudinit_def.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func removeTmpIsoDirectory(iso string) {
4848

4949
err := os.RemoveAll(filepath.Dir(iso))
5050
if err != nil {
51-
log.Printf("Error while removing tmp directory holding the ISO file: %s", err)
51+
log.Printf("error while removing tmp directory holding the ISO file: %s", err)
5252
}
5353

5454
}
@@ -69,7 +69,7 @@ func (ci *defCloudInit) UploadIso(client *Client, iso string) (string, error) {
6969

7070
// Refresh the pool of the volume so that libvirt knows it is
7171
// not longer in use.
72-
err = waitForSuccess("Error refreshing pool for volume", func() error {
72+
err = waitForSuccess("error refreshing pool for volume", func() error {
7373
return virConn.StoragePoolRefresh(pool, 0)
7474
})
7575
if err != nil {
@@ -98,23 +98,23 @@ func (ci *defCloudInit) UploadIso(client *Client, iso string) (string, error) {
9898

9999
volumeDefXML, err := xml.Marshal(volumeDef)
100100
if err != nil {
101-
return "", fmt.Errorf("Error serializing libvirt volume: %s", err)
101+
return "", fmt.Errorf("error serializing libvirt volume: %s", err)
102102
}
103103

104104
// create the volume
105105
volume, err := virConn.StorageVolCreateXML(pool, string(volumeDefXML), 0)
106106
if err != nil {
107-
return "", fmt.Errorf("Error creating libvirt volume for cloudinit device %s: %s", ci.Name, err)
107+
return "", fmt.Errorf("error creating libvirt volume for cloudinit device %s: %s", ci.Name, err)
108108
}
109109

110110
// upload ISO file
111111
err = img.Import(newCopier(virConn, &volume, uint64(size)), volumeDef)
112112
if err != nil {
113-
return "", fmt.Errorf("Error while uploading cloudinit %s: %s", img.String(), err)
113+
return "", fmt.Errorf("error while uploading cloudinit %s: %s", img.String(), err)
114114
}
115115

116116
if volume.Key == "" {
117-
return "", fmt.Errorf("Error retrieving volume key")
117+
return "", fmt.Errorf("error retrieving volume key")
118118
}
119119

120120
return ci.buildTerraformKey(volume.Key), nil
@@ -159,7 +159,7 @@ func (ci *defCloudInit) createISO() (string, error) {
159159

160160
log.Printf("About to execute cmd: %+v", cmd)
161161
if err = cmd.Run(); err != nil {
162-
return "", fmt.Errorf("Error while starting the creation of CloudInit's ISO image: %s", err)
162+
return "", fmt.Errorf("error while starting the creation of CloudInit's ISO image: %s", err)
163163
}
164164
log.Printf("ISO created at %s", isoDestination)
165165

@@ -173,20 +173,20 @@ func (ci *defCloudInit) createFiles() (string, error) {
173173
log.Print("Creating ISO contents")
174174
tmpDir, err := ioutil.TempDir("", "cloudinit")
175175
if err != nil {
176-
return "", fmt.Errorf("Cannot create tmp directory for cloudinit ISO generation: %s",
176+
return "", fmt.Errorf("cannot create tmp directory for cloudinit ISO generation: %s",
177177
err)
178178
}
179179
// user-data
180180
if err = ioutil.WriteFile(filepath.Join(tmpDir, userDataFileName), []byte(ci.UserData), os.ModePerm); err != nil {
181-
return "", fmt.Errorf("Error while writing user-data to file: %s", err)
181+
return "", fmt.Errorf("error while writing user-data to file: %s", err)
182182
}
183183
// meta-data
184184
if err = ioutil.WriteFile(filepath.Join(tmpDir, metaDataFileName), []byte(ci.MetaData), os.ModePerm); err != nil {
185-
return "", fmt.Errorf("Error while writing meta-data to file: %s", err)
185+
return "", fmt.Errorf("error while writing meta-data to file: %s", err)
186186
}
187187
// network-config
188188
if err = ioutil.WriteFile(filepath.Join(tmpDir, networkConfigFileName), []byte(ci.NetworkConfig), os.ModePerm); err != nil {
189-
return "", fmt.Errorf("Error while writing network-config to file: %s", err)
189+
return "", fmt.Errorf("error while writing network-config to file: %s", err)
190190
}
191191

192192
log.Print("ISO contents created")
@@ -206,7 +206,7 @@ func newCloudInitDefFromRemoteISO(virConn *libvirt.Libvirt, id string) (defCloud
206206

207207
volume, err := virConn.StorageVolLookupByKey(key)
208208
if err != nil {
209-
return ci, fmt.Errorf("Can't retrieve volume %s: %v", key, err)
209+
return ci, fmt.Errorf("can't retrieve volume %s: %v", key, err)
210210
}
211211

212212
err = ci.setCloudInitDiskNameFromExistingVol(virConn, volume)
@@ -239,7 +239,7 @@ func newCloudInitDefFromRemoteISO(virConn *libvirt.Libvirt, id string) (defCloud
239239
func (ci *defCloudInit) setCloudInitDataFromExistingCloudInitDisk(virConn *libvirt.Libvirt, isoFile *os.File) error {
240240
isoReader, err := iso9660.NewReader(isoFile)
241241
if err != nil {
242-
return fmt.Errorf("Error initializing ISO reader: %s", err)
242+
return fmt.Errorf("error initializing ISO reader: %s", err)
243243
}
244244

245245
for {
@@ -276,11 +276,11 @@ func (ci *defCloudInit) setCloudInitDataFromExistingCloudInitDisk(virConn *libvi
276276
func (ci *defCloudInit) setCloudInitPoolNameFromExistingVol(virConn *libvirt.Libvirt, volume libvirt.StorageVol) error {
277277
volPool, err := virConn.StoragePoolLookupByVolume(volume)
278278
if err != nil {
279-
return fmt.Errorf("Error retrieving pool for cloudinit volume: %s", err)
279+
return fmt.Errorf("error retrieving pool for cloudinit volume: %s", err)
280280
}
281281

282282
if volPool.Name == "" {
283-
return fmt.Errorf("Error retrieving pool name for cloudinit volume: %s", volume.Name)
283+
return fmt.Errorf("error retrieving pool name for cloudinit volume: %s", volume.Name)
284284
}
285285
ci.PoolName = volPool.Name
286286
return nil
@@ -290,7 +290,7 @@ func (ci *defCloudInit) setCloudInitPoolNameFromExistingVol(virConn *libvirt.Lib
290290
// setCloudInitDisklNameFromVol retrieve CloudInitname from an existing CloudInitDisk
291291
func (ci *defCloudInit) setCloudInitDiskNameFromExistingVol(virConn *libvirt.Libvirt, volume libvirt.StorageVol) error {
292292
if volume.Name == "" {
293-
return fmt.Errorf("Error retrieving cloudinit volume name for volume key: %s", volume.Key)
293+
return fmt.Errorf("error retrieving cloudinit volume name for volume key: %s", volume.Key)
294294
}
295295
ci.Name = volume.Name
296296
return nil
@@ -301,7 +301,7 @@ func readIso9660File(file os.FileInfo) ([]byte, error) {
301301

302302
dataBytes, err := ioutil.ReadAll(file.Sys().(io.Reader))
303303
if err != nil {
304-
return nil, fmt.Errorf("Error while reading %s: %s", file.Name(), err)
304+
return nil, fmt.Errorf("error while reading %s: %s", file.Name(), err)
305305
}
306306
return dataBytes, nil
307307
}
@@ -313,31 +313,31 @@ func downloadISO(virConn *libvirt.Libvirt, volume libvirt.StorageVol) (*os.File,
313313
// get Volume info (required to get size later)
314314
_, size, _, err := virConn.StorageVolGetInfo(volume)
315315
if err != nil {
316-
return nil, fmt.Errorf("Error retrieving info for volume: %s", err)
316+
return nil, fmt.Errorf("error retrieving info for volume: %s", err)
317317
}
318318

319319
// create tmp file for the ISO
320320
tmpFile, err := ioutil.TempFile("", "cloudinit")
321321
if err != nil {
322-
return nil, fmt.Errorf("Cannot create tmp file: %s", err)
322+
return nil, fmt.Errorf("cannot create tmp file: %s", err)
323323
}
324324

325325
w := bufio.NewWriterSize(tmpFile, int(size))
326326

327327
// download ISO file
328328
if err := virConn.StorageVolDownload(volume, w, 0, size, 0); err != nil {
329-
return tmpFile, fmt.Errorf("Error while downloading volume: %s", err)
329+
return tmpFile, fmt.Errorf("error while downloading volume: %s", err)
330330
}
331331

332332
bytesCopied := w.Buffered()
333333
err = w.Flush()
334334
if err != nil {
335-
return tmpFile, fmt.Errorf("Error while copying remote volume to local disk: %s", err)
335+
return tmpFile, fmt.Errorf("error while copying remote volume to local disk: %s", err)
336336
}
337337

338338
log.Printf("%d bytes downloaded", bytesCopied)
339339
if uint64(bytesCopied) != size {
340-
return tmpFile, fmt.Errorf("Error while copying remote volume to local disk, bytesCopied %d != %d volume.size", bytesCopied, size)
340+
return tmpFile, fmt.Errorf("error while copying remote volume to local disk, bytesCopied %d != %d volume.size", bytesCopied, size)
341341
}
342342

343343
tmpFile.Seek(0, 0)

libvirt/coreos_ignition_def.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,23 @@ func (ign *defIgnition) CreateAndUpload(client *Client) (string, error) {
8080

8181
volumeDefXML, err := xml.Marshal(volumeDef)
8282
if err != nil {
83-
return "", fmt.Errorf("Error serializing libvirt volume: %s", err)
83+
return "", fmt.Errorf("error serializing libvirt volume: %s", err)
8484
}
8585

8686
// create the volume
8787
volume, err := virConn.StorageVolCreateXML(pool, string(volumeDefXML), 0)
8888
if err != nil {
89-
return "", fmt.Errorf("Error creating libvirt volume for Ignition %s: %s", ign.Name, err)
89+
return "", fmt.Errorf("error creating libvirt volume for Ignition %s: %s", ign.Name, err)
9090
}
9191

9292
// upload ignition file
9393
err = img.Import(newCopier(virConn, &volume, volumeDef.Capacity.Value), volumeDef)
9494
if err != nil {
95-
return "", fmt.Errorf("Error while uploading ignition file %s: %s", img.String(), err)
95+
return "", fmt.Errorf("error while uploading ignition file %s: %s", img.String(), err)
9696
}
9797

9898
if volume.Key == "" {
99-
return "", fmt.Errorf("Error retrieving volume key")
99+
return "", fmt.Errorf("error retrieving volume key")
100100
}
101101

102102
return ign.buildTerraformKey(volume.Key), nil
@@ -123,7 +123,7 @@ func (ign *defIgnition) createFile() (string, error) {
123123
log.Print("Creating Ignition temporary file")
124124
tempFile, err := ioutil.TempFile("", ign.Name)
125125
if err != nil {
126-
return "", fmt.Errorf("Error creating tmp file: %v", err)
126+
return "", fmt.Errorf("error creating tmp file: %v", err)
127127
}
128128
defer tempFile.Close()
129129

@@ -140,18 +140,18 @@ func (ign *defIgnition) createFile() (string, error) {
140140

141141
if !file {
142142
if _, err := tempFile.WriteString(ign.Content); err != nil {
143-
return "", fmt.Errorf("Cannot write Ignition object to temporary " +
143+
return "", fmt.Errorf("cannot write Ignition object to temporary " +
144144
"ignition file")
145145
}
146146
} else if file {
147147
ignFile, err := os.Open(ign.Content)
148148
if err != nil {
149-
return "", fmt.Errorf("Error opening supplied Ignition file %s", ign.Content)
149+
return "", fmt.Errorf("error opening supplied Ignition file %s", ign.Content)
150150
}
151151
defer ignFile.Close()
152152
_, err = io.Copy(tempFile, ignFile)
153153
if err != nil {
154-
return "", fmt.Errorf("Error copying supplied Igition file to temporary file: %s", ign.Content)
154+
return "", fmt.Errorf("error copying supplied Igition file to temporary file: %s", ign.Content)
155155
}
156156
}
157157
return tempFile.Name(), nil
@@ -168,22 +168,22 @@ func newIgnitionDefFromRemoteVol(virConn *libvirt.Libvirt, id string) (defIgniti
168168

169169
volume, err := virConn.StorageVolLookupByKey(key)
170170
if err != nil {
171-
return ign, fmt.Errorf("Can't retrieve volume %s: %v", key, err)
171+
return ign, fmt.Errorf("can't retrieve volume %s: %v", key, err)
172172
}
173173

174174
ign.Name = volume.Name
175175
if ign.Name == "" {
176-
return ign, fmt.Errorf("Error retrieving volume name from key: %s", key)
176+
return ign, fmt.Errorf("error retrieving volume name from key: %s", key)
177177
}
178178

179179
volPool, err := virConn.StoragePoolLookupByVolume(volume)
180180
if err != nil {
181-
return ign, fmt.Errorf("Error retrieving pool for volume: %s", volume.Name)
181+
return ign, fmt.Errorf("error retrieving pool for volume: %s", volume.Name)
182182
}
183183

184184
ign.PoolName = volPool.Name
185185
if ign.PoolName == "" {
186-
return ign, fmt.Errorf("Error retrieving pool name for volume: %s", volume.Name)
186+
return ign, fmt.Errorf("error retrieving pool name for volume: %s", volume.Name)
187187
}
188188

189189
return ign, nil

libvirt/data_source_libvirt_network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func resourceLibvirtNetworkDNSHostRead(d *schema.ResourceData, meta interface{})
5555
if address, ok := d.GetOk("ip"); ok {
5656
ip := net.ParseIP(address.(string))
5757
if ip == nil {
58-
return fmt.Errorf("Could not parse address '%s'", address)
58+
return fmt.Errorf("could not parse address '%s'", address)
5959
}
6060
dnsHost["ip"] = ip.String()
6161
}

0 commit comments

Comments
 (0)