From 39d50d20babc1c9d428a7c6548400cc882e3c290 Mon Sep 17 00:00:00 2001 From: Gustavo Bazan Date: Tue, 12 Mar 2024 11:40:10 +0000 Subject: [PATCH] task: delete mongosh integrations --- internal/cli/config/set.go | 8 ---- internal/mongosh/mongosh.go | 54 ------------------------- internal/mongosh/mongosh_bin.go | 19 --------- internal/mongosh/mongosh_bin_windows.go | 17 -------- 4 files changed, 98 deletions(-) delete mode 100644 internal/mongosh/mongosh.go delete mode 100644 internal/mongosh/mongosh_bin.go delete mode 100644 internal/mongosh/mongosh_bin_windows.go diff --git a/internal/cli/config/set.go b/internal/cli/config/set.go index 65fc823297..9cca7a22d2 100644 --- a/internal/cli/config/set.go +++ b/internal/cli/config/set.go @@ -21,7 +21,6 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/cli" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/cli/require" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/config" - "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mongosh" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/search" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/validate" "github.com/spf13/cobra" @@ -55,13 +54,6 @@ func (opts *SetOpts) Run() error { opts.store.Set(opts.prop, value) } - if opts.prop == config.TelemetryEnabledProperty && mongosh.Detect() { - err := mongosh.SetTelemetry(value.(bool)) - if err != nil { - return fmt.Errorf("error enabling telemetry on mongosh: %w", err) - } - } - if err := opts.store.Save(); err != nil { return err } diff --git a/internal/mongosh/mongosh.go b/internal/mongosh/mongosh.go deleted file mode 100644 index 8ccd2ae072..0000000000 --- a/internal/mongosh/mongosh.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2020 MongoDB Inc -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mongosh - -import ( - "os" - "os/exec" - "syscall" -) - -func Detect() bool { - return binPath() != "" -} - -func binPath() string { - if p, err := exec.LookPath(mongoshBin); err == nil { - return p - } - - return "" -} - -func execCommand(args ...string) error { - a := append([]string{mongoshBin}, args...) - env := os.Environ() - return syscall.Exec(binPath(), a, env) //nolint:gosec // false positive, this path won't be tampered -} - -func SetTelemetry(enable bool) error { - cmd := "disableTelemetry()" - if enable { - cmd = "enableTelemetry()" - } - return execCommand("--nodb", "--eval", cmd) -} - -func Run(username, password, mongoURI string) error { - if username != "" && password != "" { - return execCommand("-u", username, "-p", password, mongoURI) - } - return execCommand(mongoURI) -} diff --git a/internal/mongosh/mongosh_bin.go b/internal/mongosh/mongosh_bin.go deleted file mode 100644 index 71982123bb..0000000000 --- a/internal/mongosh/mongosh_bin.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2020 MongoDB Inc -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build !windows - -package mongosh - -const mongoshBin = "mongosh" diff --git a/internal/mongosh/mongosh_bin_windows.go b/internal/mongosh/mongosh_bin_windows.go deleted file mode 100644 index 723c3edfa5..0000000000 --- a/internal/mongosh/mongosh_bin_windows.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2020 MongoDB Inc -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mongosh - -const mongoshBin = "mongosh.exe"