File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 88 "net/http"
99 "os"
1010 "runtime"
11+ "strings"
1112 "time"
1213
1314 "github.com/spf13/viper"
@@ -40,15 +41,17 @@ func Query(input Input) (res *http.Response, err error) {
4041 return nil , errors .New ("API key not found" )
4142 }
4243
43- req , err := http .NewRequest ("POST" , apiUrl + "?api_key=" + apiKey , bytes .NewBuffer (jsonValue ))
44+ req , err := http .NewRequest ("POST" , apiUrl , bytes .NewBuffer (jsonValue ))
4445 if err != nil {
4546 return
4647 }
4748
48- userAgent := "RunPod-CLI/" + Version + " (" + runtime .GOOS + "; " + runtime .GOARCH + ")"
49+ sanitizedVersion := strings .TrimRight (Version , "\r \n " )
50+ userAgent := "RunPod-CLI/" + sanitizedVersion + " (" + runtime .GOOS + "; " + runtime .GOARCH + ")"
4951
5052 req .Header .Add ("Content-Type" , "application/json" )
5153 req .Header .Set ("User-Agent" , userAgent )
54+ req .Header .Set ("Authorization" , "Bearer " + apiKey )
5255
5356 client := & http.Client {Timeout : time .Second * 10 }
5457 return client .Do (req )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package cmd
33import (
44 "fmt"
55 "os"
6+ "strings"
67
78 "github.com/runpod/runpodctl/api"
89 "github.com/runpod/runpodctl/cmd/config"
@@ -61,16 +62,21 @@ func registerCommands() {
6162// Execute adds all child commands to the root command and sets flags appropriately.
6263// This is called by main.main(). It only needs to happen once to the rootCmd.
6364func Execute (ver string ) {
64- version = ver
65- api .Version = ver
66- rootCmd .Version = ver
65+ sanitizedVersion := sanitizeVersion (ver )
66+ version = sanitizedVersion
67+ api .Version = sanitizedVersion
68+ rootCmd .Version = sanitizedVersion
6769
6870 if err := rootCmd .Execute (); err != nil {
6971 fmt .Fprintf (os .Stderr , "Error: %v\n " , err )
7072 os .Exit (1 )
7173 }
7274}
7375
76+ func sanitizeVersion (ver string ) string {
77+ return strings .TrimRight (ver , "\r \n " )
78+ }
79+
7480// initConfig reads in config file and ENV variables if set.
7581func initConfig () {
7682 home , err := os .UserHomeDir ()
You can’t perform that action at this time.
0 commit comments