remove username/password from json output

This commit is contained in:
Steven Masley 2024-03-28 12:47:45 -05:00
parent 6f51a5497b
commit 5fec06303a
No known key found for this signature in database
2 changed files with 13 additions and 3 deletions

View File

@ -67,7 +67,17 @@ func (r *RootCmd) externalAuthLink() *serpent.Command {
}
return []agentsdk.ExternalAuthResponse{auth}, nil
}),
cliui.JSONFormat(),
cliui.ChangeFormatterData(cliui.JSONFormat(), func(data any) (any, error) {
auth, ok := data.(agentsdk.ExternalAuthResponse)
if !ok {
return nil, xerrors.Errorf("expected data to be of type codersdk.ExternalAuth, got %T", data)
}
// Deprecated fields, omit them from any output.
auth.Username = ""
auth.Password = ""
return auth, nil
}),
)
)

View File

@ -569,8 +569,8 @@ type ExternalAuthResponse struct {
// Deprecated: Only supported on `/workspaceagents/me/gitauth`
// for backwards compatibility.
Username string `json:"username" table:"-"`
Password string `json:"password" table:"-"`
Username string `json:"username,omitempty" table:"-"`
Password string `json:"password,omitempty" table:"-"`
}
// ExternalAuthRequest is used to request an access token for a provider.