Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestAccBundleInitHelpers(t *testing.T) {
},
{
funcName: "{{is_service_principal}}",
expected: strconv.FormatBool(auth.IsServicePrincipal(me.Id)),
expected: strconv.FormatBool(auth.IsServicePrincipal(me.UserName)),
},
{
funcName: "{{smallest_node_type}}",
Expand Down
8 changes: 4 additions & 4 deletions libs/auth/service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"github.com/google/uuid"
)

// Determines whether a given user id is a service principal.
// This function uses a heuristic: if the user id is a UUID, then we assume
// Determines whether a given user name is a service principal.
// This function uses a heuristic: if the user name is a UUID, then we assume
// it's a service principal. Unfortunately, the service principal listing API is too
// slow for our purposes. And the "users" and "service principals get" APIs
// only allow access by workspace admins.
func IsServicePrincipal(userId string) bool {
_, err := uuid.Parse(userId)
func IsServicePrincipal(userName string) bool {
_, err := uuid.Parse(userName)
return err == nil
}
2 changes: 1 addition & 1 deletion libs/template/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func loadHelpers(ctx context.Context) template.FuncMap {
return false, err
}
}
result := auth.IsServicePrincipal(cachedUser.Id)
result := auth.IsServicePrincipal(cachedUser.UserName)
cachedIsServicePrincipal = &result
return result, nil
},
Expand Down