@@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7676 return fmt .Errorf ("create OpenSearch credentials: %w" , err )
7777 }
7878
79- return outputResult (params .Printer , model . OutputFormat , model . ShowPassword , instanceLabel , resp )
79+ return outputResult (params .Printer , * model , instanceLabel , resp )
8080 },
8181 }
8282 configureFlags (cmd )
@@ -112,23 +112,26 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *opensearch.
112112 return req
113113}
114114
115- func outputResult (p * print.Printer , outputFormat string , showPassword bool , instanceLabel string , resp * opensearch.CredentialsResponse ) error {
115+ func outputResult (p * print.Printer , model inputModel , instanceLabel string , resp * opensearch.CredentialsResponse ) error {
116+ if model .GlobalFlagModel == nil {
117+ return fmt .Errorf ("no global flags defined" )
118+ }
116119 if resp == nil || resp .Raw == nil {
117120 return fmt .Errorf ("response or response content is nil" )
118121 }
119122
120- if ! showPassword {
123+ if ! model . ShowPassword {
121124 resp .Raw .Credentials .Password = "hidden"
122125 }
123126
124- return p .OutputResult (outputFormat , resp , func () error {
127+ return p .OutputResult (model . OutputFormat , resp , func () error {
125128 p .Outputf ("Created credentials for instance %q. Credentials ID: %s\n \n " , instanceLabel , resp .Id )
126129 // The username field cannot be set by the user so we only display it if it's not returned empty
127130 if resp .HasRaw () {
128131 if username := resp .Raw .Credentials .Username ; username != "" {
129132 p .Outputf ("Username: %s\n " , username )
130133 }
131- if ! showPassword {
134+ if ! model . ShowPassword {
132135 p .Outputf ("Password: <hidden>\n " )
133136 } else {
134137 p .Outputf ("Password: %s\n " , resp .Raw .Credentials .Password )
0 commit comments