Skip to content

Commit 9fbcd2c

Browse files
author
Gustavo Bazan
authored
task: remove config.BinName (#2801)
1 parent 7cbb7e6 commit 9fbcd2c

File tree

13 files changed

+74
-99
lines changed

13 files changed

+74
-99
lines changed

internal/cli/atlas/backup/exports/buckets/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ func CreateBuilder() *cobra.Command {
7575
Use: "create <bucketName>",
7676
Short: "Create an export destination for Atlas backups using an existing AWS S3 bucket.",
7777
Long: fmt.Sprintf(usage.RequiredRole, "Project Owner"),
78-
Example: fmt.Sprintf(` # The following command creates an export destination for Atlas backups using the existing AWS S3 bucket named test-bucket:
79-
%s backup export buckets create test-bucket --cloudProvider AWS --iamRoleId 12345678f901a234dbdb00ca`, config.BinName()),
78+
Example: ` # The following command creates an export destination for Atlas backups using the existing AWS S3 bucket named test-bucket:
79+
atlas backup export buckets create test-bucket --cloudProvider AWS --iamRoleId 12345678f901a234dbdb00ca`,
8080
Args: require.ExactArgs(1),
8181
Annotations: map[string]string{
8282
"bucketNameDesc": "Name of the existing S3 bucket that the provided role ID is authorized to access.",

internal/cli/atlas/backup/exports/jobs/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ func CreateBuilder() *cobra.Command {
8686
Use: "create",
8787
Short: "Export one backup snapshot for an M10 or higher Atlas cluster to an existing AWS S3 bucket.",
8888
Long: fmt.Sprintf(usage.RequiredRole, "Project Owner"),
89-
Example: fmt.Sprintf(` # The following command exports one backup snapshot of the ExampleCluster cluster to an existing AWS S3 bucket:
90-
%s backup export jobs create --clusterName ExampleCluster --bucketId 62c569f85b7a381c093cc539 --snapshotId 62c808ceeb4e021d850dfe1b --customData name=test,info=test`, config.BinName()),
89+
Example: ` # The following command exports one backup snapshot of the ExampleCluster cluster to an existing AWS S3 bucket:
90+
atlas backup export jobs create --clusterName ExampleCluster --bucketId 62c569f85b7a381c093cc539 --snapshotId 62c808ceeb4e021d850dfe1b --customData name=test,info=test`,
9191
Annotations: map[string]string{
9292
"output": createTemplate,
9393
},

internal/cli/auth/login.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ func (opts *LoginOpts) setUpProfile(ctx context.Context) error {
185185
return ErrOrgIDNotFound
186186
}
187187

188-
_, _ = fmt.Fprintf(opts.OutWriter, `
188+
_, _ = fmt.Fprint(opts.OutWriter, `
189189
You have successfully configured your profile.
190-
You can use [%s config set] to change your profile settings later.
191-
`, config.BinName())
190+
You can use [atlas config set] to change your profile settings later.
191+
`)
192192
}
193193

194194
return opts.config.Save()
@@ -289,9 +289,9 @@ func LoginBuilder() *cobra.Command {
289289
cmd := &cobra.Command{
290290
Use: "login",
291291
Short: "Authenticate with MongoDB Atlas.",
292-
Example: fmt.Sprintf(` # Log in to your MongoDB Atlas account in interactive mode:
293-
%s auth login
294-
`, config.BinName()),
292+
Example: ` # Log in to your MongoDB Atlas account in interactive mode:
293+
atlas auth login
294+
`,
295295
PreRunE: func(cmd *cobra.Command, _ []string) error {
296296
opts.OutWriter = cmd.OutOrStdout()
297297
defaultProfile := config.Default()

internal/cli/auth/whoami.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func WhoAmIBuilder() *cobra.Command {
5050
cmd := &cobra.Command{
5151
Use: "whoami",
5252
Short: "Verifies and displays information about your authentication state.",
53-
Example: fmt.Sprintf(` # See the logged account:
54-
%s auth whoami
55-
`, config.BinName()),
53+
Example: ` # See the logged account:
54+
atlas auth whoami
55+
`,
5656
PreRun: func(cmd *cobra.Command, _ []string) {
5757
opts.OutWriter = cmd.OutOrStdout()
5858
},

internal/cli/config/edit.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package config
1616

1717
import (
18-
"fmt"
1918
"os"
2019
"os/exec"
2120

@@ -48,9 +47,9 @@ func EditBuilder() *cobra.Command {
4847
Use: "edit",
4948
Short: "Opens the config file with the default text editor.",
5049
Long: `Uses the default editor to open the config file. You can use EDITOR or VISUAL envs to change the default.`,
51-
Example: fmt.Sprintf(` # To open the config
52-
%s config edit
53-
`, config.BinName()),
50+
Example: ` # To open the config
51+
atlas config edit
52+
`,
5453
RunE: func(_ *cobra.Command, _ []string) error {
5554
return opt.Run()
5655
},

internal/cli/config/list.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
package config
1616

1717
import (
18-
"fmt"
19-
2018
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
2119
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/config"
2220
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag"
@@ -44,7 +42,7 @@ func ListBuilder() *cobra.Command {
4442
Aliases: []string{"ls"},
4543
Short: "Return a list of available profiles by name.",
4644
Long: `If you did not specify a name for your profile, it displays as the default profile.`,
47-
Example: fmt.Sprintf(" %s config ls", config.BinName()),
45+
Example: " atlas config ls",
4846
PreRun: func(cmd *cobra.Command, _ []string) {
4947
o.OutWriter = cmd.OutOrStdout()
5048
},

internal/cli/config/rename.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ func RenameBuilder() *cobra.Command {
6666
Use: "rename <oldProfileName> <newProfileName>",
6767
Aliases: []string{"mv"},
6868
Short: "Rename a profile.",
69-
Example: fmt.Sprintf(` # Rename a profile called myProfile to testProfile:
70-
%s config rename myProfile testProfile`, config.BinName()),
69+
Example: ` # Rename a profile called myProfile to testProfile:
70+
atlas config rename myProfile testProfile`,
7171
Annotations: map[string]string{
7272
"oldProfileNameDesc": "Name of the profile to rename.",
7373
"newProfileNameDesc": "New name of the profile.",

internal/cli/config/set.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ func SetBuilder() *cobra.Command {
8383
}
8484
return nil
8585
},
86-
Example: fmt.Sprintf(`
86+
Example: `
8787
Set the organization ID in the default profile to 5dd5aaef7a3e5a6c5bd12de4:
88-
%s config set org_id 5dd5aaef7a3e5a6c5bd12de4`, config.BinName()),
88+
atlas config set org_id 5dd5aaef7a3e5a6c5bd12de4`,
8989
Annotations: map[string]string{
9090
"propertyNameDesc": "Property to set in the profile. Valid values for Atlas CLI and MongoDB CLI are project_id, org_id, service, public_api_key, private_api_key, output, mongosh_path, skip_update_check, telemetry_enabled, access_token, and refresh_token. Additionally, values that are only valid for MongoDB CLI include ops_manager_url base_url, ops_manager_ca_certificate, and ops_manager_skip_verify.",
9191
"valueDesc": "Value for the property to set in the profile.",

internal/cli/refresher_opts.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ func (opts *RefresherOpts) RefreshAccessToken(ctx context.Context) error {
6868
var target *atlas.ErrorResponse
6969
if errors.As(err, &target) && target.ErrorCode == "INVALID_REFRESH_TOKEN" {
7070
return fmt.Errorf(
71-
"%w\n\nPlease note that your session expires periodically. If you use Atlas CLI for automation, see https://www.mongodb.com/docs/atlas/cli/stable/atlas-cli-automate/ for best practices.\nTo login, run: %s auth login",
72-
ErrInvalidRefreshToken,
73-
config.BinName())
71+
`%w
72+
73+
Please note that your session expires periodically.
74+
If you use Atlas CLI for automation, see https://www.mongodb.com/docs/atlas/cli/stable/atlas-cli-automate/ for best practices.
75+
To login, run: atlas auth login`,
76+
ErrInvalidRefreshToken)
7477
}
7578
return err
7679
}

internal/cli/root/atlas/builder.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,12 @@ func (n *Notifier) notifyIfApplicable(isHb bool) error {
348348
} else {
349349
upgradeInstructions = "To upgrade, see: https://dochub.mongodb.org/core/install-atlas-cli"
350350
}
351-
352-
newVersionTemplate := `
353-
A new version of atlascli is available '%s'!
351+
_, err = fmt.Fprintf(n.writer, `
352+
A new version of atlascli is available %q!
354353
%s
355354
356-
To disable this alert, run "%s config set skip_update_check true"
357-
`
358-
_, err = fmt.Fprintf(n.writer, newVersionTemplate, release.Version, upgradeInstructions, config.BinName())
355+
To disable this alert, run "atlas config set skip_update_check true"
356+
`, release.Version, upgradeInstructions)
359357
return err
360358
}
361359

0 commit comments

Comments
 (0)