Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
flash-singh committed Feb 8, 2023
1 parent cec107d commit 53baa35
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
4 changes: 2 additions & 2 deletions api/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
)

type GetCloudInput struct {
Expand Down Expand Up @@ -38,7 +38,7 @@ func GetCloud(in *GetCloudInput) (gpuTypes []interface{}, err error) {
return
}
defer res.Body.Close()
rawData, err := ioutil.ReadAll(res.Body)
rawData, err := io.ReadAll(res.Body)
if err != nil {
return
}
Expand Down
14 changes: 7 additions & 7 deletions api/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"strings"
)

Expand Down Expand Up @@ -86,7 +86,7 @@ func GetPods() (pods []*Pod, err error) {
return
}
defer res.Body.Close()
rawData, err := ioutil.ReadAll(res.Body)
rawData, err := io.ReadAll(res.Body)
if err != nil {
return
}
Expand Down Expand Up @@ -151,7 +151,7 @@ func CreatePod(podInput *CreatePodInput) (pod map[string]interface{}, err error)
return
}
defer res.Body.Close()
rawData, err := ioutil.ReadAll(res.Body)
rawData, err := io.ReadAll(res.Body)
if err != nil {
return
}
Expand Down Expand Up @@ -204,7 +204,7 @@ func StopPod(id string) (podStop map[string]interface{}, err error) {
return
}
defer res.Body.Close()
rawData, err := ioutil.ReadAll(res.Body)
rawData, err := io.ReadAll(res.Body)
if err != nil {
return
}
Expand Down Expand Up @@ -249,7 +249,7 @@ func RemovePod(id string) (ok bool, err error) {
return
}
defer res.Body.Close()
rawData, err := ioutil.ReadAll(res.Body)
rawData, err := io.ReadAll(res.Body)
if err != nil {
return
}
Expand Down Expand Up @@ -295,7 +295,7 @@ func StartOnDemandPod(id string) (pod map[string]interface{}, err error) {
return
}
defer res.Body.Close()
rawData, err := ioutil.ReadAll(res.Body)
rawData, err := io.ReadAll(res.Body)
if err != nil {
return
}
Expand Down Expand Up @@ -345,7 +345,7 @@ func StartSpotPod(id string, bidPerGpu float32) (podBidResume map[string]interfa
return
}
defer res.Body.Close()
rawData, err := ioutil.ReadAll(res.Body)
rawData, err := io.ReadAll(res.Body)
if err != nil {
return
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ var ConfigCmd = &cobra.Command{

func init() {
ConfigCmd.Flags().StringVar(&apiKey, "apiKey", "", "runpod api key")
viper.BindPFlag("apiKey", ConfigCmd.Flags().Lookup("apiKey"))
viper.BindPFlag("apiKey", ConfigCmd.Flags().Lookup("apiKey")) //nolint
viper.SetDefault("apiKey", "")

ConfigCmd.Flags().StringVar(&apiUrl, "apiUrl", "", "runpod api url")
viper.BindPFlag("apiUrl", ConfigCmd.Flags().Lookup("apiUrl"))
viper.BindPFlag("apiUrl", ConfigCmd.Flags().Lookup("apiUrl")) //nolint
viper.SetDefault("apiUrl", "https://api.runpod.io/graphql")
}
20 changes: 10 additions & 10 deletions cmd/croc/croc.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func GetFilesInfo(fnames []string, zipfolder bool) (filesInfo []FileInfo, emptyF
}
path := filepath.Dir(path)
dest := filepath.Base(path) + ".zip"
utils.ZipDirectory(dest, path)
utils.ZipDirectory(dest, path) //nolint
stat, errStat = os.Lstat(dest)
if errStat != nil {
err = errStat
Expand Down Expand Up @@ -909,7 +909,7 @@ func (c *Client) transfer() (err error) {
if c.SuccessfulTransfer && !c.Options.IsSender {
for _, file := range c.FilesToTransfer {
if file.TempFile {
utils.UnzipDirectory(".", file.Name)
utils.UnzipDirectory(".", file.Name) //nolint
os.Remove(file.Name)
log.Debugf("Removing %s\n", file.Name)
}
Expand Down Expand Up @@ -961,7 +961,7 @@ func (c *Client) createEmptyFolder(i int) (err error) {
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionSetVisibility(!c.Options.SendingText),
)
c.bar.Finish()
c.bar.Finish() //nolint
return
}

Expand Down Expand Up @@ -1276,7 +1276,7 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
}
}
case message.TypeCloseSender:
c.bar.Finish()
c.bar.Finish() //nolint
log.Debug("close-sender received...")
c.Step4FileTransferred = false
c.Step3RecipientRequestFile = false
Expand Down Expand Up @@ -1482,7 +1482,7 @@ func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error)
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionSetVisibility(!c.Options.SendingText),
)
c.bar.Finish()
c.bar.Finish() //nolint
return
}

Expand Down Expand Up @@ -1560,7 +1560,7 @@ func (c *Client) updateIfRecipientHasFileInfo() (err error) {
break
}
}
c.recipientGetFileReady(finished)
c.recipientGetFileReady(finished) //nolint
return
}

Expand Down Expand Up @@ -1611,7 +1611,7 @@ func (c *Client) updateState() (err error) {
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionSetVisibility(!c.Options.SendingText),
)
c.bar.Finish()
c.bar.Finish() //nolint
}
}
}
Expand Down Expand Up @@ -1667,7 +1667,7 @@ func (c *Client) setBar() {
log.Debug(c.FilesToTransfer[c.FilesToTransferCurrentNum].Size)
log.Debug(bytesDone)
if bytesDone > 0 {
c.bar.Add64(bytesDone)
c.bar.Add64(bytesDone) //nolint
}
}
}
Expand Down Expand Up @@ -1706,7 +1706,7 @@ func (c *Client) receiveData(i int) {
if err != nil {
panic(err)
}
c.bar.Add(len(data[8:]))
c.bar.Add(len(data[8:])) //nolint
c.TotalSent += int64(len(data[8:]))
c.TotalChunksTransferred++
// log.Debug(len(c.CurrentFileChunks), c.TotalChunksTransferred, c.TotalSent, c.FilesToTransfer[c.FilesToTransferCurrentNum].Size)
Expand Down Expand Up @@ -1806,7 +1806,7 @@ func (c *Client) sendData(i int) {
if err != nil {
panic(err)
}
c.bar.Add(n)
c.bar.Add(n) //nolint
c.TotalSent += int64(n)
// time.Sleep(100 * time.Millisecond)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/pod/createPod.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ func init() {
CreatePodCmd.Flags().IntVar(&volumeInGb, "volumeSize", 1, "persistant volume disk size in GB")
CreatePodCmd.Flags().StringVar(&volumeMountPath, "volumePath", "/runpod", "container volume path")

CreatePodCmd.MarkFlagRequired("gpuType")
CreatePodCmd.MarkFlagRequired("imageName")
CreatePodCmd.MarkFlagRequired("gpuType") //nolint
CreatePodCmd.MarkFlagRequired("imageName") //nolint
}
6 changes: 6 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.PHONY: proto

dev:
env GOOS=darwin GOARCH=arm64 go build -ldflags "-X 'main.Version=1.0.0'" -o bin/runpodctl .
lint:
golangci-lint run

0 comments on commit 53baa35

Please sign in to comment.