Skip to content

Commit

Permalink
chore(core): remove v1 config (#2675)
Browse files Browse the repository at this point in the history
  • Loading branch information
Codelax authored Dec 14, 2022
1 parent 03dad56 commit 64e0c85
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 53 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ See more in-depth information about running the CLI in Docker [here](./docs/dock
This repository is at its early stage and is still in active development.
If you are looking for a way to contribute please read [CONTRIBUTING.md](./.github/CONTRIBUTING.md).

# Legacy version

If you are looking for the legacy CLIv1 you can take a look at the [v1 branch](https://github.com/scaleway/scaleway-cli/blob/v1/README.md).
We also wrote [a migration guide](./docs/migration_guide_v2.md) to help transition to the CLIv2.

# Reach Us

We love feedback.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/kubernetes-client/go-base v0.0.0-20190205182333-3d0e39759d98
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.16
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221130161646-e0f8387f73a0
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221214161016-653cd5e743a9
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221130161646-e0f8387f73a0 h1:pSsfbPPYDUGIeqhoIzHIMrynJPOXTPwnjiVH6sXfZ8c=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221130161646-e0f8387f73a0/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221214161016-653cd5e743a9 h1:rkMAWlN4gd7KuWvL77KLTi4Xwff6u26R9sTVIzx6554=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221214161016-653cd5e743a9/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
Expand Down
4 changes: 0 additions & 4 deletions internal/core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (

// createClient creates a Scaleway SDK client.
func createClient(ctx context.Context, httpClient *http.Client, buildInfo *BuildInfo, profileName string) (*scw.Client, error) {
if _, err := scw.MigrateLegacyConfig(); err != nil {
return nil, err
}

profile := scw.LoadEnvProfile()

// Default path is based on the following priority order:
Expand Down
9 changes: 4 additions & 5 deletions internal/namespaces/init/custom_init_autocomplete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ const (

func Test_InitAutocomplete(t *testing.T) {
defaultSettings := map[string]string{
"access-key": "{{ .AccessKey }}",
"secret-key": "{{ .SecretKey }}",
"send-telemetry": "false",
"remove-v1-config": "false",
"with-ssh-key": "false",
"access-key": "{{ .AccessKey }}",
"secret-key": "{{ .SecretKey }}",
"send-telemetry": "false",
"with-ssh-key": "false",
}

runAllShells := func(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/namespaces/init/custom_init_ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func Test_InitSSH(t *testing.T) {
"access-key": "{{ .AccessKey }}",
"secret-key": "{{ .SecretKey }}",
"send-telemetry": "false",
"remove-v1-config": "false",
"install-autocomplete": "false",
}
cmds := GetCommands()
Expand Down
36 changes: 0 additions & 36 deletions internal/namespaces/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package init
import (
"context"
"fmt"
"os"
"path"
"reflect"
"strings"

Expand Down Expand Up @@ -67,7 +65,6 @@ type initArgs struct {
SendTelemetry *bool
WithSSHKey *bool
InstallAutocomplete *bool
RemoveV1Config *bool
}

func initCommand() *core.Command {
Expand Down Expand Up @@ -102,10 +99,6 @@ Default path for configuration file is based on the following priority order:
Name: "install-autocomplete",
Short: "Whether the autocomplete script should be installed during initialisation",
},
{
Name: "remove-v1-config",
Short: "Whether to remove the v1 configuration file if it exists",
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1),
},
Expand Down Expand Up @@ -229,26 +222,6 @@ Default path for configuration file is based on the following priority order:
args.InstallAutocomplete = scw.BoolPtr(installAutocomplete)
}

// Ask whether to remove v1 configuration file if it exists
if args.RemoveV1Config == nil {
homeDir := core.ExtractUserHomeDir(ctx)
if err == nil {
configPath := path.Join(homeDir, ".scwrc")
if _, err := os.Stat(configPath); err == nil {
removeV1ConfigFile, err := interactive.PromptBoolWithConfig(&interactive.PromptBoolConfig{
Ctx: ctx,
Prompt: "Do you want to permanently remove old configuration file (" + configPath + ")?",
DefaultValue: false,
})
if err != nil {
return err
}

args.RemoveV1Config = &removeV1ConfigFile
}
}
}

return nil
},
Run: func(ctx context.Context, argsI interface{}) (i interface{}, e error) {
Expand Down Expand Up @@ -328,15 +301,6 @@ Default path for configuration file is based on the following priority order:
}
}

// Remove old configuration file
if args.RemoveV1Config != nil && *args.RemoveV1Config {
homeDir := core.ExtractUserHomeDir(ctx)
err = os.Remove(path.Join(homeDir, ".scwrc"))
if err != nil {
successDetails = append(successDetails, "Except for removing old configuration: "+err.Error())
}
}

_, _ = interactive.Println()

return &core.SuccessResult{
Expand Down
1 change: 0 additions & 1 deletion internal/namespaces/init/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestInit(t *testing.T) {
"secret-key": "{{ .SecretKey }}",
"send-telemetry": "true",
"install-autocomplete": "false",
"remove-v1-config": "false",
"with-ssh-key": "false",
}

Expand Down

0 comments on commit 64e0c85

Please sign in to comment.