Skip to content

Commit 5fec063

Browse files
committed
remove username/password from json output
1 parent 6f51a54 commit 5fec063

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

cli/externalauth.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,17 @@ func (r *RootCmd) externalAuthLink() *serpent.Command {
6767
}
6868
return []agentsdk.ExternalAuthResponse{auth}, nil
6969
}),
70-
cliui.JSONFormat(),
70+
cliui.ChangeFormatterData(cliui.JSONFormat(), func(data any) (any, error) {
71+
auth, ok := data.(agentsdk.ExternalAuthResponse)
72+
if !ok {
73+
return nil, xerrors.Errorf("expected data to be of type codersdk.ExternalAuth, got %T", data)
74+
}
75+
76+
// Deprecated fields, omit them from any output.
77+
auth.Username = ""
78+
auth.Password = ""
79+
return auth, nil
80+
}),
7181
)
7282
)
7383

codersdk/agentsdk/agentsdk.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,8 @@ type ExternalAuthResponse struct {
569569

570570
// Deprecated: Only supported on `/workspaceagents/me/gitauth`
571571
// for backwards compatibility.
572-
Username string `json:"username" table:"-"`
573-
Password string `json:"password" table:"-"`
572+
Username string `json:"username,omitempty" table:"-"`
573+
Password string `json:"password,omitempty" table:"-"`
574574
}
575575

576576
// ExternalAuthRequest is used to request an access token for a provider.

0 commit comments

Comments
 (0)