Skip to content

Commit 33244cd

Browse files
authored
Revert change for interactive prompt to store cloud to pixie config file (#1964) (#1990)
Summary: Revert change for interactive prompt to store cloud to pixie config file (#1964) We've received feedback from users that is confusing to no longer have a default cloud for the pixie cli. We will be restoring the previous behavior in a follow up PR. With that new direction in mind, it no longer makes sense to have the functionality added in #1964. Relevant Issues: N/A Type of change: /kind cleanup Test Plan: None since this was a `git revert` Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent 795b7cb commit 33244cd

5 files changed

Lines changed: 2 additions & 169 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ require (
4545
github.com/mattn/go-isatty v0.0.17
4646
github.com/mattn/go-runewidth v0.0.9
4747
github.com/mikefarah/yq/v4 v4.30.8
48-
github.com/mitchellh/mapstructure v1.5.0
4948
github.com/nats-io/nats-server/v2 v2.10.4
5049
github.com/nats-io/nats.go v1.31.0
5150
github.com/olekukonko/tablewriter v0.0.5
@@ -215,6 +214,7 @@ require (
215214
github.com/mitchellh/copystructure v1.0.0 // indirect
216215
github.com/mitchellh/go-homedir v1.1.0 // indirect
217216
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
217+
github.com/mitchellh/mapstructure v1.5.0 // indirect
218218
github.com/mitchellh/reflectwalk v1.0.0 // indirect
219219
github.com/moby/spdystream v0.2.0 // indirect
220220
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect

src/pixie_cli/pkg/cmd/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ go_library(
2323
"auth.go",
2424
"bindata.gen.go",
2525
"collect_logs.go",
26-
"config.go",
2726
"create_bundle.go",
2827
"create_cloud_certs.go",
2928
"debug.go",
@@ -74,7 +73,6 @@ go_library(
7473
"@com_github_lestrrat_go_jwx//jwt",
7574
"@com_github_manifoldco_promptui//:promptui",
7675
"@com_github_mattn_go_isatty//:go-isatty",
77-
"@com_github_mitchellh_mapstructure//:mapstructure",
7876
"@com_github_segmentio_analytics_go_v3//:analytics-go",
7977
"@com_github_sirupsen_logrus//:logrus",
8078
"@com_github_spf13_cobra//:cobra",

src/pixie_cli/pkg/cmd/config.go

Lines changed: 0 additions & 108 deletions
This file was deleted.

src/pixie_cli/pkg/cmd/root.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ func init() {
7272
viper.BindPFlag("direct_vizier_key", RootCmd.PersistentFlags().Lookup("direct_vizier_key"))
7373

7474
RootCmd.AddCommand(VersionCmd)
75-
RootCmd.AddCommand(ConfigCmd)
7675
RootCmd.AddCommand(AuthCmd)
7776
RootCmd.AddCommand(CollectLogsCmd)
7877
RootCmd.AddCommand(CreateCloudCertsCmd)
@@ -202,8 +201,6 @@ var RootCmd = &cobra.Command{
202201
// Name a variable to store a slice of commands that don't require cloudAddr
203202
var cmdsCloudAddrNotReqd = []*cobra.Command{
204203
CollectLogsCmd,
205-
ConfigListCmd,
206-
ConfigSetCmd,
207204
VersionCmd,
208205
}
209206

@@ -215,12 +212,6 @@ func getCloudAddrIfRequired(cmd *cobra.Command) string {
215212
}
216213

217214
cloudAddr := viper.GetString("cloud_addr")
218-
cfg := pxconfig.Cfg()
219-
defaultCloudAddr = cfg.CloudAddr
220-
if cloudAddr == "" && defaultCloudAddr != "" {
221-
cloudAddr = defaultCloudAddr
222-
viper.Set("cloud_addr", cloudAddr)
223-
}
224215
if cloudAddr == "" {
225216
if !isatty.IsTerminal(os.Stdin.Fd()) {
226217
utils.Errorf("No cloud address provided during run within non-interactive shell. Please set the cloud address using the `--cloud_addr` flag or `PX_CLOUD_ADDR` environment variable.")
@@ -238,26 +229,6 @@ func getCloudAddrIfRequired(cmd *cobra.Command) string {
238229

239230
cloudAddr = selectedCloud
240231
viper.Set("cloud_addr", cloudAddr)
241-
242-
defaultCloudPrompt := promptui.Select{
243-
Label: "Set as default cloud address?",
244-
Items: []string{"Yes", "No"},
245-
}
246-
_, storeDefault, err := defaultCloudPrompt.Run()
247-
if err != nil {
248-
utils.WithError(err).Fatal("Failed to select default cloud address")
249-
os.Exit(1)
250-
}
251-
252-
if storeDefault == "Yes" {
253-
cfg.CloudAddr = cloudAddr
254-
err := pxconfig.UpdateConfig(cfg)
255-
256-
if err != nil {
257-
utils.WithError(err).Fatal("Failed to update config file with default cloud address")
258-
os.Exit(1)
259-
}
260-
}
261232
}
262233
}
263234
return cloudAddr

src/pixie_cli/pkg/pxconfig/config.go

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package pxconfig
2121
import (
2222
"encoding/json"
2323
"os"
24-
"reflect"
2524
"sync"
2625

2726
"github.com/gofrs/uuid"
@@ -32,41 +31,14 @@ import (
3231
// ConfigInfo store the config about the CLI.
3332
type ConfigInfo struct {
3433
// UniqueClientID is the ID assigned to this user on first startup when auth information is not know. This can be later associated with the UserID.
35-
UniqueClientID string `json:"uniqueClientID"`
36-
ConfigInfoSettable `mapstructure:",squash"`
37-
}
38-
39-
type ConfigInfoSettable struct {
40-
CloudAddr string `json:"cloudAddr,omitempty"`
34+
UniqueClientID string `json:"uniqueClientID"`
4135
}
4236

4337
var (
4438
config *ConfigInfo
4539
once sync.Once
4640
)
4741

48-
func GetSettableConfigKeys() []string {
49-
val := reflect.ValueOf(ConfigInfoSettable{})
50-
keys := []string{}
51-
for i := 0; i < val.NumField(); i++ {
52-
keys = append(keys, val.Type().Field(i).Name)
53-
}
54-
return keys
55-
}
56-
57-
func UpdateConfig(cfg *ConfigInfo) error {
58-
configPath, err := utils.EnsureDefaultConfigFilePath()
59-
if err != nil {
60-
utils.WithError(err).Fatal("Failed to load/create config file path")
61-
}
62-
f, err := os.OpenFile(configPath, os.O_RDWR|os.O_TRUNC, 0600)
63-
if err != nil {
64-
return err
65-
}
66-
defer f.Close()
67-
return json.NewEncoder(f).Encode(cfg)
68-
}
69-
7042
func writeDefaultConfig(path string) (*ConfigInfo, error) {
7143
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600)
7244
if err != nil {

0 commit comments

Comments
 (0)