Skip to content

Commit

Permalink
add new user fields to grpc and list command (#2202)
Browse files Browse the repository at this point in the history
Updates #2166

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
  • Loading branch information
kradalby authored Oct 18, 2024
1 parent b6dc6eb commit 028d9aa
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 52 deletions.
4 changes: 3 additions & 1 deletion cmd/headscale/cli/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@ var listUsersCmd = &cobra.Command{
SuccessOutput(response.GetUsers(), "", output)
}

tableData := pterm.TableData{{"ID", "Name", "Created"}}
tableData := pterm.TableData{{"ID", "Name", "Username", "Email", "Created"}}
for _, user := range response.GetUsers() {
tableData = append(
tableData,
[]string{
user.GetId(),
user.GetDisplayName(),
user.GetName(),
user.GetEmail(),
user.GetCreatedAt().AsTime().Format("2006-01-02 15:04:05"),
},
)
Expand Down
138 changes: 94 additions & 44 deletions gen/go/headscale/v1/user.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions gen/openapiv2/headscale/v1/headscale.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,21 @@
"createdAt": {
"type": "string",
"format": "date-time"
},
"displayName": {
"type": "string"
},
"email": {
"type": "string"
},
"providerId": {
"type": "string"
},
"provider": {
"type": "string"
},
"profilePicUrl": {
"type": "string"
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions hscontrol/types/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ func (u *User) TailscaleUserProfile() tailcfg.UserProfile {
}
}

func (n *User) Proto() *v1.User {
func (u *User) Proto() *v1.User {
return &v1.User{
Id: strconv.FormatUint(uint64(n.ID), util.Base10),
Name: n.Name,
CreatedAt: timestamppb.New(n.CreatedAt),
Id: strconv.FormatUint(uint64(u.ID), util.Base10),
Name: u.Name,
CreatedAt: timestamppb.New(u.CreatedAt),
DisplayName: u.DisplayName,
Email: u.Email,
ProviderId: u.ProviderIdentifier,
Provider: u.Provider,
ProfilePicUrl: u.ProfilePicURL,
}
}

Expand Down
11 changes: 8 additions & 3 deletions proto/headscale/v1/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ option go_package = "github.com/juanfont/headscale/gen/go/v1";
import "google/protobuf/timestamp.proto";

message User {
string id = 1;
string name = 2;
google.protobuf.Timestamp created_at = 3;
string id = 1;
string name = 2;
google.protobuf.Timestamp created_at = 3;
string display_name = 4;
string email = 5;
string provider_id = 6;
string provider = 7;
string profile_pic_url = 8;
}

message GetUserRequest {
Expand Down

0 comments on commit 028d9aa

Please sign in to comment.