Skip to content

Commit 2d50567

Browse files
authored
Merge pull request #9 from arvancloud/data_center_migration
Data center migration
2 parents d4740ce + c85f350 commit 2d50567

7 files changed

Lines changed: 388 additions & 17 deletions

File tree

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
1717
github.com/moby/buildkit v0.8.0 // indirect
1818
github.com/moby/term v0.0.0-20201110203204-bea5bbe245bf // indirect
19+
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5
1920
github.com/openshift/api v3.9.0+incompatible
2021
github.com/openshift/client-go v3.9.0+incompatible // indirect
2122
github.com/openshift/library-go v0.0.0-20201211095848-8399bf6288d6

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
835835
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
836836
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
837837
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
838+
github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o=
838839
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
839840
github.com/mattn/go-shellwords v1.0.5/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
840841
github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
@@ -915,6 +916,7 @@ github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/
915916
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
916917
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
917918
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
919+
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5 h1:58+kh9C6jJVXYjt8IE48G2eWl6BjwU5Gj0gqY84fy78=
918920
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
919921
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
920922
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@@ -1451,7 +1453,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
14511453
golang.org/x/sys v0.0.0-20201013081832-0aaa2718063a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14521454
golang.org/x/sys v0.0.0-20201110211018-35f3e6cf4a65/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14531455
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1454-
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3 h1:kzM6+9dur93BcC2kVlYl34cHU+TYZLanmpSJHVMmL64=
14551456
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14561457
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs=
14571458
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

pkg/api/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package api
33
import (
44
"encoding/json"
55
"errors"
6+
"fmt"
67
"io/ioutil"
78
"net/http"
89
"net/url"
@@ -66,7 +67,7 @@ func GetZones() (config.Region, error) {
6667
arvanConfig := config.GetConfigInfo()
6768
arvanURL, err := url.Parse(arvanConfig.GetServer())
6869
if err != nil {
69-
return regions, nil
70+
return regions, fmt.Errorf("invalid config")
7071
}
7172

7273
httpReq, err := http.NewRequest("GET", arvanURL.Scheme + "://" + arvanURL.Host+regionsEndpoint, nil)

pkg/cli/cli.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ package cli
22

33
import (
44
"fmt"
5-
"github.com/arvancloud/cli/pkg/api"
6-
"github.com/arvancloud/cli/pkg/utl"
7-
"github.com/inconshreveable/go-update"
85
"net/http"
96
"os"
107
"path/filepath"
118
"runtime"
129

13-
"github.com/spf13/cobra"
14-
15-
"github.com/openshift/oc/pkg/helpers/term"
16-
10+
"github.com/arvancloud/cli/pkg/api"
1711
"github.com/arvancloud/cli/pkg/config"
1812
"github.com/arvancloud/cli/pkg/paas"
13+
"github.com/arvancloud/cli/pkg/utl"
14+
"github.com/inconshreveable/go-update"
15+
16+
"github.com/openshift/oc/pkg/helpers/term"
17+
"github.com/spf13/cobra"
1918
)
2019

2120
var (
@@ -60,7 +59,7 @@ func NewCommandCLI() *cobra.Command {
6059
cmd.AddCommand(loginCommand)
6160

6261
paasCommand := paas.NewCmdPaas()
63-
cmd.AddCommand(paasCommand)
62+
cmd.AddCommand(paasCommand)
6463

6564
cmd.AddCommand(updateCmd())
6665
return cmd

pkg/paas/login.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func NewCmdSwitchRegion(in io.Reader, out, errout io.Writer) *cobra.Command {
8383

8484
region, err := getSelectedRegion(in, explainOut)
8585
utl.CheckErr(err)
86-
86+
8787
_, err = config.LoadConfigFile()
8888
if err != nil {
8989
log.Println(err)
@@ -189,18 +189,17 @@ func (r regionValidator) validate(input string) (bool, error) {
189189

190190
func sprintRegions(activeZones, inactiveRegions []config.Zone) string {
191191
result := ""
192-
var activeZoneIndex int
192+
var activeZoneIndex int
193193
for i := 0; i < len(activeZones); i++ {
194194
if activeZones[i].Default {
195195
activeZoneIndex++
196-
log.Println(activeZones[i].Release)
197196

198197
if activeZones[i].Release == "STABLE" {
199198
result += fmt.Sprintf(" [%d] %s-%s\n", activeZoneIndex, activeZones[i].RegionName, activeZones[i].Name)
200199
} else {
201200
result += fmt.Sprintf(" [%d] %s-%s(%s)\n", activeZoneIndex, activeZones[i].RegionName, activeZones[i].Name, activeZones[i].Release)
202201
}
203-
202+
204203
}
205204
}
206205
for i := 0; i < len(activeZones); i++ {
@@ -211,7 +210,8 @@ func sprintRegions(activeZones, inactiveRegions []config.Zone) string {
211210
} else {
212211
result += fmt.Sprintf(" [%d] %s-%s(%s)\n", activeZoneIndex, activeZones[i].RegionName, activeZones[i].Name, activeZones[i].Release)
213212
}
214-
} }
213+
}
214+
}
215215
for i := 0; i < len(inactiveRegions); i++ {
216216
result += fmt.Sprintf(" [-] %s-%s (inactive)\n", inactiveRegions[i].RegionName, inactiveRegions[i].Name)
217217
}

0 commit comments

Comments
 (0)