@@ -11,6 +11,7 @@ import (
1111 "os"
1212 "strconv"
1313 "strings"
14+ "net/url"
1415
1516 "github.com/arvancloud/cli/pkg/api"
1617 "github.com/arvancloud/cli/pkg/config"
@@ -23,7 +24,7 @@ import (
2324)
2425
2526const (
26- migrationEndpoint = "/paas/v1/migrations "
27+ migrationEndpoint = "/paas/v1/migrate "
2728 redColor = "\033 [31m"
2829 greenColor = "\033 [32m"
2930 yellowColor = "\033 [33m"
@@ -95,10 +96,13 @@ func NewCmdMigrate(in io.Reader, out, errout io.Writer) *cobra.Command {
9596 requset := Request {
9697 Namespace : project ,
9798 Source : currentRegionName ,
98- Destination : destinationRegion .RegionName ,
99+ Destination : fmt . Sprintf ( "%s-%s" , destinationRegion .RegionName , destinationRegion . Name ) ,
99100 }
100101
101- migrate (requset )
102+ err = migrate (requset )
103+ if err != nil {
104+ log .Println (err )
105+ }
102106 },
103107 }
104108
@@ -233,11 +237,21 @@ func httpPost(endpoint string, payload interface{}) (*Response, error) {
233237 if err != nil {
234238 return nil , err
235239 }
240+ arvanConfig := config .GetConfigInfo ()
241+ arvanURL , err := url .Parse (arvanConfig .GetServer ())
242+ if err != nil {
243+ return nil , fmt .Errorf ("invalid config" )
244+ }
236245
237- httpReq , err := http .NewRequest (http .MethodPost , getArvanPaasServerBase () + endpoint , bytes .NewBuffer (requestBody ))
246+ httpReq , err := http .NewRequest (http .MethodPost , arvanURL . Scheme + "://" + arvanURL . Host + endpoint , bytes .NewBuffer (requestBody ))
238247 if err != nil {
239248 return nil , err
240249 }
250+ apikey := arvanConfig .GetApiKey ()
251+ if apikey != "" {
252+ httpReq .Header .Add ("Authorization" , apikey )
253+ }
254+
241255 httpReq .Header .Add ("accept" , "application/json" )
242256 httpReq .Header .Add ("User-Agent" , rest .DefaultKubernetesUserAgent ())
243257 httpResp , err := http .DefaultClient .Do (httpReq )
0 commit comments