Skip to content

Commit

Permalink
Merge pull request #9 from arvancloud/data_center_migration
Browse files Browse the repository at this point in the history
Data center migration
  • Loading branch information
pjfa authored Oct 29, 2022
2 parents d4740ce + c85f350 commit 2d50567
Show file tree
Hide file tree
Showing 7 changed files with 388 additions and 17 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/moby/buildkit v0.8.0 // indirect
github.com/moby/term v0.0.0-20201110203204-bea5bbe245bf // indirect
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5
github.com/openshift/api v3.9.0+incompatible
github.com/openshift/client-go v3.9.0+incompatible // indirect
github.com/openshift/library-go v0.0.0-20201211095848-8399bf6288d6
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-shellwords v1.0.5/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
Expand Down Expand Up @@ -915,6 +916,7 @@ github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5 h1:58+kh9C6jJVXYjt8IE48G2eWl6BjwU5Gj0gqY84fy78=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down Expand Up @@ -1451,7 +1453,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201013081832-0aaa2718063a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201110211018-35f3e6cf4a65/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3 h1:kzM6+9dur93BcC2kVlYl34cHU+TYZLanmpSJHVMmL64=
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -66,7 +67,7 @@ func GetZones() (config.Region, error) {
arvanConfig := config.GetConfigInfo()
arvanURL, err := url.Parse(arvanConfig.GetServer())
if err != nil {
return regions, nil
return regions, fmt.Errorf("invalid config")
}

httpReq, err := http.NewRequest("GET", arvanURL.Scheme + "://" + arvanURL.Host+regionsEndpoint, nil)
Expand Down
15 changes: 7 additions & 8 deletions pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ package cli

import (
"fmt"
"github.com/arvancloud/cli/pkg/api"
"github.com/arvancloud/cli/pkg/utl"
"github.com/inconshreveable/go-update"
"net/http"
"os"
"path/filepath"
"runtime"

"github.com/spf13/cobra"

"github.com/openshift/oc/pkg/helpers/term"

"github.com/arvancloud/cli/pkg/api"
"github.com/arvancloud/cli/pkg/config"
"github.com/arvancloud/cli/pkg/paas"
"github.com/arvancloud/cli/pkg/utl"
"github.com/inconshreveable/go-update"

"github.com/openshift/oc/pkg/helpers/term"
"github.com/spf13/cobra"
)

var (
Expand Down Expand Up @@ -60,7 +59,7 @@ func NewCommandCLI() *cobra.Command {
cmd.AddCommand(loginCommand)

paasCommand := paas.NewCmdPaas()
cmd.AddCommand(paasCommand)
cmd.AddCommand(paasCommand)

cmd.AddCommand(updateCmd())
return cmd
Expand Down
10 changes: 5 additions & 5 deletions pkg/paas/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func NewCmdSwitchRegion(in io.Reader, out, errout io.Writer) *cobra.Command {

region, err := getSelectedRegion(in, explainOut)
utl.CheckErr(err)

_, err = config.LoadConfigFile()
if err != nil {
log.Println(err)
Expand Down Expand Up @@ -189,18 +189,17 @@ func (r regionValidator) validate(input string) (bool, error) {

func sprintRegions(activeZones, inactiveRegions []config.Zone) string {
result := ""
var activeZoneIndex int
var activeZoneIndex int
for i := 0; i < len(activeZones); i++ {
if activeZones[i].Default {
activeZoneIndex++
log.Println(activeZones[i].Release)

if activeZones[i].Release == "STABLE" {
result += fmt.Sprintf(" [%d] %s-%s\n", activeZoneIndex, activeZones[i].RegionName, activeZones[i].Name)
} else {
result += fmt.Sprintf(" [%d] %s-%s(%s)\n", activeZoneIndex, activeZones[i].RegionName, activeZones[i].Name, activeZones[i].Release)
}

}
}
for i := 0; i < len(activeZones); i++ {
Expand All @@ -211,7 +210,8 @@ func sprintRegions(activeZones, inactiveRegions []config.Zone) string {
} else {
result += fmt.Sprintf(" [%d] %s-%s(%s)\n", activeZoneIndex, activeZones[i].RegionName, activeZones[i].Name, activeZones[i].Release)
}
} }
}
}
for i := 0; i < len(inactiveRegions); i++ {
result += fmt.Sprintf(" [-] %s-%s (inactive)\n", inactiveRegions[i].RegionName, inactiveRegions[i].Name)
}
Expand Down
Loading

0 comments on commit 2d50567

Please sign in to comment.