@@ -29,19 +29,11 @@ import (
2929)
3030
3131type opts struct {
32- cli.ConfigOpts
33- OpsManagerURL string
34- }
35-
36- func (opts * opts ) SetUpAccess () {
37- opts .SetUpServiceAndKeys ()
38- if opts .OpsManagerURL != "" {
39- config .SetOpsManagerURL (opts .OpsManagerURL )
40- }
32+ cli.DigestConfigOpts
4133}
4234
4335func (opts * opts ) Run (ctx context.Context ) error {
44- fmt .Printf ( `You are configuring a profile for %s.
36+ _ , _ = fmt .Fprintf ( opts . OutWriter , `You are configuring a profile for %s.
4537
4638All values are optional and you can use environment variables (MCLI_*) instead.
4739
@@ -53,7 +45,7 @@ Enter [?] on any option to get help.
5345 if err := survey .Ask (q , opts ); err != nil {
5446 return err
5547 }
56- opts .SetUpAccess ()
48+ opts .SetUpDigestAccess ()
5749
5850 if err := opts .InitStore (ctx ); err != nil {
5951 return err
@@ -85,16 +77,16 @@ Enter [?] on any option to get help.
8577 return err
8678 }
8779
88- fmt .Printf ( "\n Your profile is now configured.\n " )
80+ _ , _ = fmt .Fprintf ( opts . OutWriter , "\n Your profile is now configured.\n " )
8981 if config .Name () != config .DefaultProfile {
90- fmt .Printf ( "To use this profile, you must set the flag [-%s %s] for every command.\n " , flag .ProfileShort , config .Name ())
82+ _ , _ = fmt .Fprintf ( opts . OutWriter , "To use this profile, you must set the flag [-%s %s] for every command.\n " , flag .ProfileShort , config .Name ())
9183 }
92- fmt .Printf ( "You can use [%s config set] to change these settings at a later time.\n " , config .ToolName )
84+ _ , _ = fmt .Fprintf ( opts . OutWriter , "You can use [%s config set] to change these settings at a later time.\n " , config .ToolName )
9385 return nil
9486}
9587
9688func Builder () * cobra.Command {
97- opts := & opts {}
89+ opt := & opts {}
9890 cmd := & cobra.Command {
9991 Use : "config" ,
10092 Short : "Configure a profile to store access settings for your MongoDB deployment." ,
@@ -117,15 +109,18 @@ To find out more, see the documentation: https://docs.mongodb.com/mongocli/stabl
117109 To configure the tool to work with Ops Manager
118110 $ mongocli config --service ops-manager
119111` ,
112+ PreRun : func (cmd * cobra.Command , args []string ) {
113+ opt .OutWriter = cmd .OutOrStdout ()
114+ },
120115 RunE : func (cmd * cobra.Command , args []string ) error {
121- return opts .Run (cmd .Context ())
116+ return opt .Run (cmd .Context ())
122117 },
123118 Annotations : map [string ]string {
124119 "toc" : "true" ,
125120 },
126121 Args : require .NoArgs ,
127122 }
128- cmd .Flags ().StringVar (& opts .Service , flag .Service , config .CloudService , usage .Service )
123+ cmd .Flags ().StringVar (& opt .Service , flag .Service , config .CloudService , usage .Service )
129124 cmd .AddCommand (
130125 SetBuilder (),
131126 ListBuilder (),
0 commit comments